Handle native callbacks without getters.

TEST=cctest/test-api/SetterOnly,cctest/test-api/NoAccessors

Review URL: https://chromiumcodereview.appspot.com/10831388

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12344 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent bac8e56f
...@@ -1067,7 +1067,6 @@ static i::Handle<i::AccessorInfo> MakeAccessorInfo( ...@@ -1067,7 +1067,6 @@ static i::Handle<i::AccessorInfo> MakeAccessorInfo(
v8::PropertyAttribute attributes, v8::PropertyAttribute attributes,
v8::Handle<AccessorSignature> signature) { v8::Handle<AccessorSignature> signature) {
i::Handle<i::AccessorInfo> obj = FACTORY->NewAccessorInfo(); i::Handle<i::AccessorInfo> obj = FACTORY->NewAccessorInfo();
ASSERT(getter != NULL);
SET_FIELD_WRAPPED(obj, set_getter, getter); SET_FIELD_WRAPPED(obj, set_getter, getter);
SET_FIELD_WRAPPED(obj, set_setter, setter); SET_FIELD_WRAPPED(obj, set_setter, setter);
if (data.IsEmpty()) data = v8::Undefined(); if (data.IsEmpty()) data = v8::Undefined();
......
...@@ -190,6 +190,7 @@ MaybeObject* JSObject::GetPropertyWithCallback(Object* receiver, ...@@ -190,6 +190,7 @@ MaybeObject* JSObject::GetPropertyWithCallback(Object* receiver,
} }
Object* fun_obj = data->getter(); Object* fun_obj = data->getter();
v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj);
if (call_fun == NULL) return isolate->heap()->undefined_value();
HandleScope scope(isolate); HandleScope scope(isolate);
JSObject* self = JSObject::cast(receiver); JSObject* self = JSObject::cast(receiver);
Handle<String> key(name); Handle<String> key(name);
...@@ -9129,6 +9130,7 @@ MaybeObject* JSObject::GetElementWithCallback(Object* receiver, ...@@ -9129,6 +9130,7 @@ MaybeObject* JSObject::GetElementWithCallback(Object* receiver,
Handle<AccessorInfo> data(AccessorInfo::cast(structure)); Handle<AccessorInfo> data(AccessorInfo::cast(structure));
Object* fun_obj = data->getter(); Object* fun_obj = data->getter();
v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj);
if (call_fun == NULL) return isolate->heap()->undefined_value();
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<JSObject> self(JSObject::cast(receiver)); Handle<JSObject> self(JSObject::cast(receiver));
Handle<JSObject> holder_handle(JSObject::cast(holder)); Handle<JSObject> holder_handle(JSObject::cast(holder));
......
...@@ -3742,6 +3742,36 @@ THREADED_TEST(SimplePropertyWrite) { ...@@ -3742,6 +3742,36 @@ THREADED_TEST(SimplePropertyWrite) {
} }
THREADED_TEST(SetterOnly) {
v8::HandleScope scope;
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut"));
LocalContext context;
context->Global()->Set(v8_str("obj"), templ->NewInstance());
Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x"));
for (int i = 0; i < 10; i++) {
CHECK(xValue.IsEmpty());
script->Run();
CHECK_EQ(v8_num(4), xValue);
xValue.Dispose();
xValue = v8::Persistent<Value>();
}
}
THREADED_TEST(NoAccessors) {
v8::HandleScope scope;
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->SetAccessor(v8_str("x"), NULL, NULL, v8_str("donut"));
LocalContext context;
context->Global()->Set(v8_str("obj"), templ->NewInstance());
Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x"));
for (int i = 0; i < 10; i++) {
script->Run();
}
}
static v8::Handle<Value> XPropertyGetter(Local<String> property, static v8::Handle<Value> XPropertyGetter(Local<String> property,
const AccessorInfo& info) { const AccessorInfo& info) {
ApiTestFuzzer::Fuzz(); ApiTestFuzzer::Fuzz();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment