Commit 64bb6e6c authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[runtime] Pass global proxy as receiver to native accessors in case of contextual access

Bug:

Change-Id: I288c0d7a34b65eda6c6e46168c436b87a350f6d4
Reviewed-on: https://chromium-review.googlesource.com/483199
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44739}
parent 9d71683e
......@@ -1361,6 +1361,11 @@ MaybeHandle<Object> Object::GetPropertyWithAccessor(LookupIterator* it) {
Isolate* isolate = it->isolate();
Handle<Object> structure = it->GetAccessors();
Handle<Object> receiver = it->GetReceiver();
// In case of global IC, the receiver is the global object. Replace by the
// global proxy.
if (receiver->IsJSGlobalObject()) {
receiver = handle(JSGlobalObject::cast(*receiver)->global_proxy(), isolate);
}
// We should never get here to initialize a const with the hole value since a
// const declaration would conflict with the getter.
......@@ -1453,6 +1458,11 @@ Maybe<bool> Object::SetPropertyWithAccessor(LookupIterator* it,
Isolate* isolate = it->isolate();
Handle<Object> structure = it->GetAccessors();
Handle<Object> receiver = it->GetReceiver();
// In case of global IC, the receiver is the global object. Replace by the
// global proxy.
if (receiver->IsJSGlobalObject()) {
receiver = handle(JSGlobalObject::cast(*receiver)->global_proxy(), isolate);
}
// We should never get here to initialize a const with the hole value since a
// const declaration would conflict with the setter.
......
......@@ -26509,6 +26509,24 @@ TEST(SetPrototypeTemplate) {
ExpectTrue("Image.prototype === HTMLImageElement.prototype");
}
void ensure_receiver_is_global_proxy(
v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK(v8::Utils::OpenHandle(*info.This())->IsJSGlobalProxy());
}
THREADED_TEST(GlobalAccessorInfo) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(isolate);
global_template->SetAccessor(
v8::String::NewFromUtf8(isolate, "prop", v8::NewStringType::kInternalized)
.ToLocalChecked(),
&ensure_receiver_is_global_proxy);
LocalContext env(NULL, global_template);
CompileRun("for (var i = 0; i < 10; i++) this.prop");
CompileRun("for (var i = 0; i < 10; i++) prop");
}
UNINITIALIZED_TEST(IncreaseHeapLimitForDebugging) {
using namespace i;
v8::Isolate::CreateParams create_params;
......
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