mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Hide CEF internal V8 attributes from JavaScript (issue #316).
- Add a PropertyAttribute parameter to CefV8Value::SetValue() (issue #412). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@358 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -2547,7 +2547,8 @@ public:
|
|||||||
// Associate a value with the specified identifier.
|
// Associate a value with the specified identifier.
|
||||||
///
|
///
|
||||||
/*--cef(capi_name=set_value_bykey)--*/
|
/*--cef(capi_name=set_value_bykey)--*/
|
||||||
virtual bool SetValue(const CefString& key, CefRefPtr<CefV8Value> value) =0;
|
virtual bool SetValue(const CefString& key, CefRefPtr<CefV8Value> value,
|
||||||
|
PropertyAttribute attribute) =0;
|
||||||
///
|
///
|
||||||
// Associate a value with the specified identifier.
|
// Associate a value with the specified identifier.
|
||||||
///
|
///
|
||||||
|
@ -2267,7 +2267,8 @@ typedef struct _cef_v8value_t
|
|||||||
// Associate a value with the specified identifier.
|
// Associate a value with the specified identifier.
|
||||||
///
|
///
|
||||||
int (CEF_CALLBACK *set_value_bykey)(struct _cef_v8value_t* self,
|
int (CEF_CALLBACK *set_value_bykey)(struct _cef_v8value_t* self,
|
||||||
const cef_string_t* key, struct _cef_v8value_t* value);
|
const cef_string_t* key, struct _cef_v8value_t* value,
|
||||||
|
enum cef_v8_propertyattribute_t attribute);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Associate a value with the specified identifier.
|
// Associate a value with the specified identifier.
|
||||||
|
@ -26,6 +26,13 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
static const char kCefAccessor[] = "Cef::Accessor";
|
||||||
|
static const char kCefHandler[] = "Cef::Handler";
|
||||||
|
static const char kCefUserData[] = "Cef::UserData";
|
||||||
|
static const v8::PropertyAttribute kInternalAttributes =
|
||||||
|
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum |
|
||||||
|
v8::DontDelete);
|
||||||
|
|
||||||
// Memory manager.
|
// Memory manager.
|
||||||
|
|
||||||
base::LazyInstance<CefTrackManager> g_v8_tracker(base::LINKER_INITIALIZED);
|
base::LazyInstance<CefTrackManager> g_v8_tracker(base::LINKER_INITIALIZED);
|
||||||
@ -202,7 +209,7 @@ v8::Handle<v8::Value> AccessorGetterCallbackImpl(v8::Local<v8::String> property,
|
|||||||
v8::HandleScope handle_scope;
|
v8::HandleScope handle_scope;
|
||||||
|
|
||||||
v8::Handle<v8::Object> obj = info.This();
|
v8::Handle<v8::Object> obj = info.This();
|
||||||
v8::Handle<v8::String> key = v8::String::New("Cef::Accessor");
|
v8::Handle<v8::String> key = v8::String::New(kCefAccessor);
|
||||||
|
|
||||||
CefV8Accessor* accessorPtr = NULL;
|
CefV8Accessor* accessorPtr = NULL;
|
||||||
if (obj->Has(key)) {
|
if (obj->Has(key)) {
|
||||||
@ -237,7 +244,7 @@ void AccessorSetterCallbackImpl(v8::Local<v8::String> property,
|
|||||||
v8::HandleScope handle_scope;
|
v8::HandleScope handle_scope;
|
||||||
|
|
||||||
v8::Handle<v8::Object> obj = info.This();
|
v8::Handle<v8::Object> obj = info.This();
|
||||||
v8::Handle<v8::String> key = v8::String::New("Cef::Accessor");
|
v8::Handle<v8::String> key = v8::String::New(kCefAccessor);
|
||||||
|
|
||||||
CefV8Accessor* accessorPtr = NULL;
|
CefV8Accessor* accessorPtr = NULL;
|
||||||
if (obj->Has(key)) {
|
if (obj->Has(key)) {
|
||||||
@ -547,13 +554,13 @@ CefRefPtr<CefV8Value> CefV8Value::CreateObject(
|
|||||||
// Attach the user data to the V8 object.
|
// Attach the user data to the V8 object.
|
||||||
if (user_data.get()) {
|
if (user_data.get()) {
|
||||||
v8::Local<v8::Value> data = v8::External::Wrap(user_data.get());
|
v8::Local<v8::Value> data = v8::External::Wrap(user_data.get());
|
||||||
obj->Set(v8::String::New("Cef::UserData"), data);
|
obj->Set(v8::String::New(kCefUserData), data, kInternalAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach the accessor to the V8 object.
|
// Attach the accessor to the V8 object.
|
||||||
if (accessor.get()) {
|
if (accessor.get()) {
|
||||||
v8::Local<v8::Value> data = v8::External::Wrap(accessor.get());
|
v8::Local<v8::Value> data = v8::External::Wrap(accessor.get());
|
||||||
obj->Set(v8::String::New("Cef::Accessor"), data);
|
obj->Set(v8::String::New(kCefAccessor), data, kInternalAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CefV8ValueImpl(obj, tracker);
|
return new CefV8ValueImpl(obj, tracker);
|
||||||
@ -591,7 +598,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateFunction(const CefString& name,
|
|||||||
func->SetName(GetV8String(name));
|
func->SetName(GetV8String(name));
|
||||||
|
|
||||||
// Attach the handler instance to the V8 object.
|
// Attach the handler instance to the V8 object.
|
||||||
func->Set(v8::String::New("Cef::Handler"), data);
|
func->Set(v8::String::New(kCefHandler), data, kInternalAttributes);
|
||||||
|
|
||||||
// Create the CefV8ValueImpl and provide a tracker object that will cause
|
// Create the CefV8ValueImpl and provide a tracker object that will cause
|
||||||
// the handler reference to be released when the V8 object is destroyed.
|
// the handler reference to be released when the V8 object is destroyed.
|
||||||
@ -821,7 +828,8 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::GetValue(int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CefV8ValueImpl::SetValue(const CefString& key,
|
bool CefV8ValueImpl::SetValue(const CefString& key,
|
||||||
CefRefPtr<CefV8Value> value)
|
CefRefPtr<CefV8Value> value,
|
||||||
|
PropertyAttribute attribute)
|
||||||
{
|
{
|
||||||
CEF_REQUIRE_UI_THREAD(false);
|
CEF_REQUIRE_UI_THREAD(false);
|
||||||
if(IsReservedKey(key))
|
if(IsReservedKey(key))
|
||||||
@ -835,7 +843,8 @@ bool CefV8ValueImpl::SetValue(const CefString& key,
|
|||||||
if(impl) {
|
if(impl) {
|
||||||
v8::HandleScope handle_scope;
|
v8::HandleScope handle_scope;
|
||||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||||
return obj->Set(GetV8String(key), impl->GetHandle());
|
return obj->Set(GetV8String(key), impl->GetHandle(),
|
||||||
|
static_cast<v8::PropertyAttribute>(attribute));
|
||||||
} else {
|
} else {
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
return false;
|
return false;
|
||||||
@ -919,7 +928,7 @@ CefRefPtr<CefBase> CefV8ValueImpl::GetUserData()
|
|||||||
|
|
||||||
v8::HandleScope handle_scope;
|
v8::HandleScope handle_scope;
|
||||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||||
v8::Local<v8::String> key = v8::String::New("Cef::UserData");
|
v8::Local<v8::String> key = v8::String::New(kCefUserData);
|
||||||
if(obj->Has(key))
|
if(obj->Has(key))
|
||||||
return static_cast<CefBase*>(v8::External::Unwrap(obj->Get(key)));
|
return static_cast<CefBase*>(v8::External::Unwrap(obj->Get(key)));
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -965,7 +974,7 @@ CefRefPtr<CefV8Handler> CefV8ValueImpl::GetFunctionHandler()
|
|||||||
|
|
||||||
v8::HandleScope handle_scope;
|
v8::HandleScope handle_scope;
|
||||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||||
v8::Local<v8::String> key = v8::String::New("Cef::Handler");
|
v8::Local<v8::String> key = v8::String::New(kCefHandler);
|
||||||
if (obj->Has(key))
|
if (obj->Has(key))
|
||||||
return static_cast<CefV8Handler*>(v8::External::Unwrap(obj->Get(key)));
|
return static_cast<CefV8Handler*>(v8::External::Unwrap(obj->Get(key)));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -131,8 +131,8 @@ public:
|
|||||||
virtual bool DeleteValue(int index) OVERRIDE;
|
virtual bool DeleteValue(int index) OVERRIDE;
|
||||||
virtual CefRefPtr<CefV8Value> GetValue(const CefString& key) OVERRIDE;
|
virtual CefRefPtr<CefV8Value> GetValue(const CefString& key) OVERRIDE;
|
||||||
virtual CefRefPtr<CefV8Value> GetValue(int index) OVERRIDE;
|
virtual CefRefPtr<CefV8Value> GetValue(int index) OVERRIDE;
|
||||||
virtual bool SetValue(const CefString& key, CefRefPtr<CefV8Value> value)
|
virtual bool SetValue(const CefString& key, CefRefPtr<CefV8Value> value,
|
||||||
OVERRIDE;
|
PropertyAttribute attribute) OVERRIDE;
|
||||||
virtual bool SetValue(int index, CefRefPtr<CefV8Value> value) OVERRIDE;
|
virtual bool SetValue(int index, CefRefPtr<CefV8Value> value) OVERRIDE;
|
||||||
virtual bool SetValue(const CefString& key, AccessControl settings,
|
virtual bool SetValue(const CefString& key, AccessControl settings,
|
||||||
PropertyAttribute attribute) OVERRIDE;
|
PropertyAttribute attribute) OVERRIDE;
|
||||||
|
@ -346,14 +346,16 @@ struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_byindex(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int CEF_CALLBACK v8value_set_value_bykey(struct _cef_v8value_t* self,
|
int CEF_CALLBACK v8value_set_value_bykey(struct _cef_v8value_t* self,
|
||||||
const cef_string_t* key, struct _cef_v8value_t* value)
|
const cef_string_t* key, struct _cef_v8value_t* value,
|
||||||
|
enum cef_v8_propertyattribute_t attribute)
|
||||||
{
|
{
|
||||||
DCHECK(self);
|
DCHECK(self);
|
||||||
if(!self)
|
if(!self)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(value);
|
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(value);
|
||||||
return CefV8ValueCppToC::Get(self)->SetValue(CefString(key), valuePtr);
|
return CefV8ValueCppToC::Get(self)->SetValue(CefString(key), valuePtr,
|
||||||
|
attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CEF_CALLBACK v8value_set_value_byindex(struct _cef_v8value_t* self,
|
int CEF_CALLBACK v8value_set_value_byindex(struct _cef_v8value_t* self,
|
||||||
|
@ -318,13 +318,13 @@ CefRefPtr<CefV8Value> CefV8ValueCToCpp::GetValue(int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CefV8ValueCToCpp::SetValue(const CefString& key,
|
bool CefV8ValueCToCpp::SetValue(const CefString& key,
|
||||||
CefRefPtr<CefV8Value> value)
|
CefRefPtr<CefV8Value> value, PropertyAttribute attribute)
|
||||||
{
|
{
|
||||||
if(CEF_MEMBER_MISSING(struct_, set_value_bykey))
|
if(CEF_MEMBER_MISSING(struct_, set_value_bykey))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return struct_->set_value_bykey(struct_, key.GetStruct(),
|
return struct_->set_value_bykey(struct_, key.GetStruct(),
|
||||||
CefV8ValueCToCpp::Unwrap(value))?true:false;
|
CefV8ValueCToCpp::Unwrap(value), attribute)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefV8ValueCToCpp::SetValue(int index, CefRefPtr<CefV8Value> value)
|
bool CefV8ValueCToCpp::SetValue(int index, CefRefPtr<CefV8Value> value)
|
||||||
|
@ -53,8 +53,8 @@ public:
|
|||||||
virtual bool DeleteValue(int index) OVERRIDE;
|
virtual bool DeleteValue(int index) OVERRIDE;
|
||||||
virtual CefRefPtr<CefV8Value> GetValue(const CefString& key) OVERRIDE;
|
virtual CefRefPtr<CefV8Value> GetValue(const CefString& key) OVERRIDE;
|
||||||
virtual CefRefPtr<CefV8Value> GetValue(int index) OVERRIDE;
|
virtual CefRefPtr<CefV8Value> GetValue(int index) OVERRIDE;
|
||||||
virtual bool SetValue(const CefString& key,
|
virtual bool SetValue(const CefString& key, CefRefPtr<CefV8Value> value,
|
||||||
CefRefPtr<CefV8Value> value) OVERRIDE;
|
PropertyAttribute attribute) OVERRIDE;
|
||||||
virtual bool SetValue(int index, CefRefPtr<CefV8Value> value) OVERRIDE;
|
virtual bool SetValue(int index, CefRefPtr<CefV8Value> value) OVERRIDE;
|
||||||
virtual bool SetValue(const CefString& key, AccessControl settings,
|
virtual bool SetValue(const CefString& key, AccessControl settings,
|
||||||
PropertyAttribute attribute) OVERRIDE;
|
PropertyAttribute attribute) OVERRIDE;
|
||||||
|
@ -135,17 +135,19 @@ void InitBindingTest(CefRefPtr<CefBrowser> browser,
|
|||||||
CefRefPtr<CefV8Value> testObjPtr = CefV8Value::CreateObject(NULL);
|
CefRefPtr<CefV8Value> testObjPtr = CefV8Value::CreateObject(NULL);
|
||||||
// Add the new V8 object to the global window object with the name
|
// Add the new V8 object to the global window object with the name
|
||||||
// "cef_test".
|
// "cef_test".
|
||||||
object->SetValue("cef_test", testObjPtr);
|
object->SetValue("cef_test", testObjPtr, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
// Create an instance of ClientV8FunctionHandler as the V8 handler.
|
// Create an instance of ClientV8FunctionHandler as the V8 handler.
|
||||||
CefRefPtr<CefV8Handler> handlerPtr = new ClientV8FunctionHandler();
|
CefRefPtr<CefV8Handler> handlerPtr = new ClientV8FunctionHandler();
|
||||||
|
|
||||||
// Add a new V8 function to the cef_test object with the name "Dump".
|
// Add a new V8 function to the cef_test object with the name "Dump".
|
||||||
testObjPtr->SetValue("Dump",
|
testObjPtr->SetValue("Dump",
|
||||||
CefV8Value::CreateFunction("Dump", handlerPtr));
|
CefV8Value::CreateFunction("Dump", handlerPtr),
|
||||||
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
// Add a new V8 function to the cef_test object with the name "Call".
|
// Add a new V8 function to the cef_test object with the name "Call".
|
||||||
testObjPtr->SetValue("Call",
|
testObjPtr->SetValue("Call",
|
||||||
CefV8Value::CreateFunction("Call", handlerPtr));
|
CefV8Value::CreateFunction("Call", handlerPtr),
|
||||||
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunBindingTest(CefRefPtr<CefBrowser> browser)
|
void RunBindingTest(CefRefPtr<CefBrowser> browser)
|
||||||
|
@ -49,10 +49,12 @@ public:
|
|||||||
retval = CefV8Value::CreateObject(NULL);
|
retval = CefV8Value::CreateObject(NULL);
|
||||||
// Add a string parameter to the new V8 object.
|
// Add a string parameter to the new V8 object.
|
||||||
retval->SetValue("param", CefV8Value::CreateString(
|
retval->SetValue("param", CefV8Value::CreateString(
|
||||||
"Retrieving a parameter on a native object succeeded."));
|
"Retrieving a parameter on a native object succeeded."),
|
||||||
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
// Add a function to the new V8 object.
|
// Add a function to the new V8 object.
|
||||||
retval->SetValue("GetMessage",
|
retval->SetValue("GetMessage",
|
||||||
CefV8Value::CreateFunction("GetMessage", this));
|
CefV8Value::CreateFunction("GetMessage", this),
|
||||||
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(name == "GetMessage")
|
else if(name == "GetMessage")
|
||||||
|
@ -329,8 +329,9 @@ public:
|
|||||||
{
|
{
|
||||||
CefRefPtr<CefV8Handler> handler = new V8Handler(this);
|
CefRefPtr<CefV8Handler> handler = new V8Handler(this);
|
||||||
CefRefPtr<CefV8Value> testObj = CefV8Value::CreateObject(NULL, NULL);
|
CefRefPtr<CefV8Value> testObj = CefV8Value::CreateObject(NULL, NULL);
|
||||||
testObj->SetValue("result", CefV8Value::CreateFunction("result", handler));
|
testObj->SetValue("result", CefV8Value::CreateFunction("result", handler),
|
||||||
object->SetValue("test", testObj);
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
object->SetValue("test", testObj, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
CefStorageType type_;
|
CefStorageType type_;
|
||||||
|
@ -300,7 +300,7 @@ public:
|
|||||||
// Create the new V8 object
|
// Create the new V8 object
|
||||||
CefRefPtr<CefV8Value> testObj = CefV8Value::CreateObject(NULL);
|
CefRefPtr<CefV8Value> testObj = CefV8Value::CreateObject(NULL);
|
||||||
ASSERT_TRUE(testObj.get() != NULL);
|
ASSERT_TRUE(testObj.get() != NULL);
|
||||||
ASSERT_TRUE(object->SetValue("test", testObj));
|
ASSERT_TRUE(object->SetValue("test", testObj, V8_PROPERTY_ATTRIBUTE_NONE));
|
||||||
|
|
||||||
// Create an instance of V8ExecuteV8Handler
|
// Create an instance of V8ExecuteV8Handler
|
||||||
CefRefPtr<CefV8Handler> testHandler(new V8TestV8Handler(true));
|
CefRefPtr<CefV8Handler> testHandler(new V8TestV8Handler(true));
|
||||||
@ -310,27 +310,31 @@ public:
|
|||||||
CefRefPtr<CefV8Value> testFunc;
|
CefRefPtr<CefV8Value> testFunc;
|
||||||
testFunc = CefV8Value::CreateFunction("execute", testHandler);
|
testFunc = CefV8Value::CreateFunction("execute", testHandler);
|
||||||
ASSERT_TRUE(testFunc.get() != NULL);
|
ASSERT_TRUE(testFunc.get() != NULL);
|
||||||
ASSERT_TRUE(testObj->SetValue("execute", testFunc));
|
ASSERT_TRUE(testObj->SetValue("execute", testFunc,
|
||||||
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
||||||
testFunc = CefV8Value::CreateFunction("execute2", testHandler);
|
testFunc = CefV8Value::CreateFunction("execute2", testHandler);
|
||||||
ASSERT_TRUE(testFunc.get() != NULL);
|
ASSERT_TRUE(testFunc.get() != NULL);
|
||||||
ASSERT_TRUE(testObj->SetValue("execute2", testFunc));
|
ASSERT_TRUE(testObj->SetValue("execute2", testFunc,
|
||||||
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
||||||
|
|
||||||
// Add the values
|
// Add the values
|
||||||
ASSERT_TRUE(testObj->SetValue("intVal",
|
ASSERT_TRUE(testObj->SetValue("intVal",
|
||||||
CefV8Value::CreateInt(12)));
|
CefV8Value::CreateInt(12), V8_PROPERTY_ATTRIBUTE_NONE));
|
||||||
ASSERT_TRUE(testObj->SetValue("doubleVal",
|
ASSERT_TRUE(testObj->SetValue("doubleVal",
|
||||||
CefV8Value::CreateDouble(5.432)));
|
CefV8Value::CreateDouble(5.432), V8_PROPERTY_ATTRIBUTE_NONE));
|
||||||
ASSERT_TRUE(testObj->SetValue("boolVal",
|
ASSERT_TRUE(testObj->SetValue("boolVal",
|
||||||
CefV8Value::CreateBool(true)));
|
CefV8Value::CreateBool(true), V8_PROPERTY_ATTRIBUTE_NONE));
|
||||||
ASSERT_TRUE(testObj->SetValue("stringVal",
|
ASSERT_TRUE(testObj->SetValue("stringVal",
|
||||||
CefV8Value::CreateString("the string")));
|
CefV8Value::CreateString("the string"), V8_PROPERTY_ATTRIBUTE_NONE));
|
||||||
|
|
||||||
cef_time_t date = {2010, 5, 1, 3, 12, 30, 10, 100};
|
cef_time_t date = {2010, 5, 1, 3, 12, 30, 10, 100};
|
||||||
ASSERT_TRUE(testObj->SetValue("dateVal", CefV8Value::CreateDate(date)));
|
ASSERT_TRUE(testObj->SetValue("dateVal", CefV8Value::CreateDate(date),
|
||||||
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
||||||
|
|
||||||
CefRefPtr<CefV8Value> testArray(CefV8Value::CreateArray());
|
CefRefPtr<CefV8Value> testArray(CefV8Value::CreateArray());
|
||||||
ASSERT_TRUE(testArray.get() != NULL);
|
ASSERT_TRUE(testArray.get() != NULL);
|
||||||
ASSERT_TRUE(testObj->SetValue("arrayVal", testArray));
|
ASSERT_TRUE(testObj->SetValue("arrayVal", testArray,
|
||||||
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
||||||
ASSERT_TRUE(testArray->SetValue(0, CefV8Value::CreateInt(4)));
|
ASSERT_TRUE(testArray->SetValue(0, CefV8Value::CreateInt(4)));
|
||||||
ASSERT_TRUE(testArray->SetValue(1, CefV8Value::CreateDouble(120.43)));
|
ASSERT_TRUE(testArray->SetValue(1, CefV8Value::CreateDouble(120.43)));
|
||||||
ASSERT_TRUE(testArray->SetValue(2, CefV8Value::CreateBool(true)));
|
ASSERT_TRUE(testArray->SetValue(2, CefV8Value::CreateBool(true)));
|
||||||
@ -593,31 +597,33 @@ public:
|
|||||||
CefRefPtr<CefV8Handler> funcHandler(new DelegatingV8Handler(this));
|
CefRefPtr<CefV8Handler> funcHandler(new DelegatingV8Handler(this));
|
||||||
CefRefPtr<CefV8Value> helloFunc =
|
CefRefPtr<CefV8Value> helloFunc =
|
||||||
CefV8Value::CreateFunction("hello", funcHandler);
|
CefV8Value::CreateFunction("hello", funcHandler);
|
||||||
object->SetValue("hello", helloFunc);
|
object->SetValue("hello", helloFunc, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
CefRefPtr<CefV8Value> fromIFrameFunc =
|
CefRefPtr<CefV8Value> fromIFrameFunc =
|
||||||
CefV8Value::CreateFunction("fromIFrame", funcHandler);
|
CefV8Value::CreateFunction("fromIFrame", funcHandler);
|
||||||
object->SetValue("fromIFrame", fromIFrameFunc);
|
object->SetValue("fromIFrame", fromIFrameFunc, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
CefRefPtr<CefV8Value> goFunc =
|
CefRefPtr<CefV8Value> goFunc =
|
||||||
CefV8Value::CreateFunction("begin", funcHandler);
|
CefV8Value::CreateFunction("begin", funcHandler);
|
||||||
object->SetValue("begin", goFunc);
|
object->SetValue("begin", goFunc, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
CefRefPtr<CefV8Value> doneFunc =
|
CefRefPtr<CefV8Value> doneFunc =
|
||||||
CefV8Value::CreateFunction("end", funcHandler);
|
CefV8Value::CreateFunction("end", funcHandler);
|
||||||
object->SetValue("end", doneFunc);
|
object->SetValue("end", doneFunc, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
CefRefPtr<CefV8Value> compFunc =
|
CefRefPtr<CefV8Value> compFunc =
|
||||||
CefV8Value::CreateFunction("comp", funcHandler);
|
CefV8Value::CreateFunction("comp", funcHandler);
|
||||||
object->SetValue("comp", compFunc);
|
object->SetValue("comp", compFunc, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
// Used for testing exceptions returned from accessors.
|
// Used for testing exceptions returned from accessors.
|
||||||
CefRefPtr<CefV8Value> gotGetExceptionFunc =
|
CefRefPtr<CefV8Value> gotGetExceptionFunc =
|
||||||
CefV8Value::CreateFunction("gotGetException", funcHandler);
|
CefV8Value::CreateFunction("gotGetException", funcHandler);
|
||||||
object->SetValue("gotGetException", gotGetExceptionFunc);
|
object->SetValue("gotGetException", gotGetExceptionFunc,
|
||||||
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
CefRefPtr<CefV8Value> gotSetExceptionFunc =
|
CefRefPtr<CefV8Value> gotSetExceptionFunc =
|
||||||
CefV8Value::CreateFunction("gotSetException", funcHandler);
|
CefV8Value::CreateFunction("gotSetException", funcHandler);
|
||||||
object->SetValue("gotSetException", gotSetExceptionFunc);
|
object->SetValue("gotSetException", gotSetExceptionFunc,
|
||||||
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
// Create an object with accessor based properties:
|
// Create an object with accessor based properties:
|
||||||
CefRefPtr<CefBase> blankBase;
|
CefRefPtr<CefBase> blankBase;
|
||||||
@ -629,7 +635,7 @@ public:
|
|||||||
point->SetValue("y", V8_ACCESS_CONTROL_DEFAULT,
|
point->SetValue("y", V8_ACCESS_CONTROL_DEFAULT,
|
||||||
V8_PROPERTY_ATTRIBUTE_NONE);
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
object->SetValue("point", point);
|
object->SetValue("point", point, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
// Create another object with accessor based properties:
|
// Create another object with accessor based properties:
|
||||||
CefRefPtr<CefV8Value> exceptObj =
|
CefRefPtr<CefV8Value> exceptObj =
|
||||||
@ -638,7 +644,7 @@ public:
|
|||||||
exceptObj->SetValue("makeException", V8_ACCESS_CONTROL_DEFAULT,
|
exceptObj->SetValue("makeException", V8_ACCESS_CONTROL_DEFAULT,
|
||||||
V8_PROPERTY_ATTRIBUTE_NONE);
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
object->SetValue("exceptObj", exceptObj);
|
object->SetValue("exceptObj", exceptObj, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallIFrame()
|
void CallIFrame()
|
||||||
@ -715,9 +721,9 @@ public:
|
|||||||
obj = CefV8Value::CreateObject(NULL);
|
obj = CefV8Value::CreateObject(NULL);
|
||||||
url = CefV8Value::CreateString("http://tests/end.html");
|
url = CefV8Value::CreateString("http://tests/end.html");
|
||||||
|
|
||||||
obj->SetValue("url", url);
|
obj->SetValue("url", url, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
obj->SetValue("foobar", foobarFunc);
|
obj->SetValue("foobar", foobarFunc, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
obj->SetValue("anArray", anArray);
|
obj->SetValue("anArray", anArray, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
args.push_back(obj);
|
args.push_back(obj);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user