| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 54fefda commit 46e75f4
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1032,7 +1032,7 @@ void ModuleWrap::HasAsyncGraph(Local<Name> property, | |||
| 1032 | 1032 | Isolate* isolate = args.GetIsolate(); | |
| 1033 | 1033 | Environment* env = Environment::GetCurrent(isolate); | |
| 1034 | 1034 | ModuleWrap* obj; | |
| 1035 | - ASSIGN_OR_RETURN_UNWRAP(&obj, args.This()); | ||
| 1035 | + ASSIGN_OR_RETURN_UNWRAP(&obj, args.HolderV2()); | ||
| 1036 | 1036 | ||
| 1037 | 1037 | Local<Module> module = obj->module_.Get(isolate); | |
| 1038 | 1038 | if (module->GetStatus() < Module::kInstantiated) { | |
@@ -1248,7 +1248,7 @@ void ModuleWrap::SetImportMetaResolveInitializer( | |||
| 1248 | 1248 | static void ImportMetaResolveLazyGetter( | |
| 1249 | 1249 | Local<v8::Name> name, const PropertyCallbackInfo<Value>& info) { | |
| 1250 | 1250 | Isolate* isolate = info.GetIsolate(); | |
| 1251 | - Local<Value> receiver_val = info.This(); | ||
| 1251 | + Local<Value> receiver_val = info.HolderV2(); | ||
| 1252 | 1252 | if (!receiver_val->IsObject()) { | |
| 1253 | 1253 | THROW_ERR_INVALID_INVOCATION(isolate); | |
| 1254 | 1254 | return; | |
@@ -1289,7 +1289,7 @@ static void PathHelpersLazyGetter(Local<v8::Name> name, | |||
| 1289 | 1289 | // When this getter is invoked in a vm context, the `Realm::GetCurrent(info)` | |
| 1290 | 1290 | // returns a nullptr and retrieve the creation context via `this` object and | |
| 1291 | 1291 | // get the creation Realm. | |
| 1292 | - Local<Value> receiver_val = info.This(); | ||
| 1292 | + Local<Value> receiver_val = info.HolderV2(); | ||
| 1293 | 1293 | if (!receiver_val->IsObject()) { | |
| 1294 | 1294 | THROW_ERR_INVALID_INVOCATION(isolate); | |
| 1295 | 1295 | return; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -453,7 +453,7 @@ ContextifyContext* ContextifyContext::Get(const PropertyCallbackInfo<T>& args) { | |||
| 453 | 453 | // args.GetIsolate()->GetCurrentContext() and take the pointer at | |
| 454 | 454 | // ContextEmbedderIndex::kContextifyContext, as V8 is supposed to | |
| 455 | 455 | // push the creation context before invoking these callbacks. | |
| 456 | - return Get(args.This()); | ||
| 456 | + return Get(args.HolderV2()); | ||
| 457 | 457 | } | |
| 458 | 458 | ||
| 459 | 459 | ContextifyContext* ContextifyContext::Get(Local<Object> object) { | |
@@ -587,27 +587,38 @@ Intercepted ContextifyContext::PropertySetterCallback( | |||
| 587 | 587 | return Intercepted::kNo; | |
| 588 | 588 | } | |
| 589 | 589 | ||
| 590 | - // true for x = 5 | ||
| 591 | - // false for this.x = 5 | ||
| 592 | - // false for Object.defineProperty(this, 'foo', ...) | ||
| 593 | - // false for vmResult.x = 5 where vmResult = vm.runInContext(); | ||
| 594 | - bool is_contextual_store = ctx->global_proxy() != args.This(); | ||
| 595 | - | ||
| 596 | - // Indicator to not return before setting (undeclared) function declarations | ||
| 597 | - // on the sandbox in strict mode, i.e. args.ShouldThrowOnError() = true. | ||
| 598 | - // True for 'function f() {}', 'this.f = function() {}', | ||
| 599 | - // 'var f = function()'. | ||
| 600 | - // In effect only for 'function f() {}' because | ||
| 601 | - // var f = function(), is_declared = true | ||
| 602 | - // this.f = function() {}, is_contextual_store = false. | ||
| 603 | - bool is_function = value->IsFunction(); | ||
| 604 | - | ||
| 590 | + // V8 comment: As long as the context is not detached the contextual accesses | ||
| 591 | + // are the same as regular accesses to `context->Global()`s data property. | ||
| 592 | + // The only difference is that after detaching `args.Holder()` will | ||
| 593 | + // become a new identity and will no longer be equal to `context->Global()`. | ||
| 594 | + // TODO(Node.js): revise the code below as the "contextual"-ness of the | ||
| 595 | + // store is not actually relevant here. Also, new variable declaration is | ||
| 596 | + // reported by V8 via PropertyDefinerCallback. | ||
| 605 | 597 | bool is_declared = is_declared_on_global_proxy || is_declared_on_sandbox; | |
| 606 | - if (!is_declared && args.ShouldThrowOnError() && is_contextual_store && | ||
| 607 | - !is_function) { | ||
| 608 | - return Intercepted::kNo; | ||
| 609 | - } | ||
| 610 | 598 | ||
| 599 | + /* | ||
| 600 | + // true for x = 5 | ||
| 601 | + // false for this.x = 5 | ||
| 602 | + // false for Object.defineProperty(this, 'foo', ...) | ||
| 603 | + // false for vmResult.x = 5 where vmResult = vm.runInContext(); | ||
| 604 | + | ||
| 605 | + bool is_contextual_store = ctx->global_proxy() != args.This(); | ||
| 606 | + | ||
| 607 | + // Indicator to not return before setting (undeclared) function declarations | ||
| 608 | + // on the sandbox in strict mode, i.e. args.ShouldThrowOnError() = true. | ||
| 609 | + // True for 'function f() {}', 'this.f = function() {}', | ||
| 610 | + // 'var f = function()'. | ||
| 611 | + // In effect only for 'function f() {}' because | ||
| 612 | + // var f = function(), is_declared = true | ||
| 613 | + // this.f = function() {}, is_contextual_store = false. | ||
| 614 | + bool is_function = value->IsFunction(); | ||
| 615 | + | ||
| 616 | + bool is_declared = is_declared_on_global_proxy || is_declared_on_sandbox; | ||
| 617 | + if (!is_declared && args.ShouldThrowOnError() && is_contextual_store && | ||
| 618 | + !is_function) { | ||
| 619 | + return Intercepted::kNo; | ||
| 620 | + } | ||
| 621 | + */ | ||
| 611 | 622 | if (!is_declared && property->IsSymbol()) { | |
| 612 | 623 | return Intercepted::kNo; | |
| 613 | 624 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -729,7 +729,7 @@ Intercepted DatabaseSyncLimits::LimitsGetter( | |||
| 729 | 729 | } | |
| 730 | 730 | ||
| 731 | 731 | DatabaseSyncLimits* limits; | |
| 732 | - ASSIGN_OR_RETURN_UNWRAP(&limits, info.This(), Intercepted::kNo); | ||
| 732 | + ASSIGN_OR_RETURN_UNWRAP(&limits, info.HolderV2(), Intercepted::kNo); | ||
| 733 | 733 | ||
| 734 | 734 | Environment* env = limits->env(); | |
| 735 | 735 | Isolate* isolate = env->isolate(); | |
@@ -761,7 +761,7 @@ Intercepted DatabaseSyncLimits::LimitsSetter( | |||
| 761 | 761 | } | |
| 762 | 762 | ||
| 763 | 763 | DatabaseSyncLimits* limits; | |
| 764 | - ASSIGN_OR_RETURN_UNWRAP(&limits, info.This(), Intercepted::kNo); | ||
| 764 | + ASSIGN_OR_RETURN_UNWRAP(&limits, info.HolderV2(), Intercepted::kNo); | ||
| 765 | 765 | ||
| 766 | 766 | Environment* env = limits->env(); | |
| 767 | 767 | Isolate* isolate = env->isolate(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -366,7 +366,7 @@ static void DefineLazyPropertiesGetter( | |||
| 366 | 366 | // When this getter is invoked in a vm context, the `Realm::GetCurrent(info)` | |
| 367 | 367 | // returns a nullptr and retrieve the creation context via `this` object and | |
| 368 | 368 | // get the creation Realm. | |
| 369 | - Local<Value> receiver_val = info.This(); | ||
| 369 | + Local<Value> receiver_val = info.HolderV2(); | ||
| 370 | 370 | if (!receiver_val->IsObject()) { | |
| 371 | 371 | THROW_ERR_INVALID_INVOCATION(isolate); | |
| 372 | 372 | return; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -530,7 +530,7 @@ template <typename T> | |||
| 530 | 530 | static bool ShouldIntercept(Local<Name> property, | |
| 531 | 531 | const PropertyCallbackInfo<T>& info) { | |
| 532 | 532 | Environment* env = Environment::GetCurrent(info); | |
| 533 | - Local<Value> proto = info.This()->GetPrototypeV2(); | ||
| 533 | + Local<Value> proto = info.HolderV2()->GetPrototypeV2(); | ||
| 534 | 534 | ||
| 535 | 535 | if (proto->IsObject()) { | |
| 536 | 536 | bool has_prop; | |
@@ -554,7 +554,7 @@ static Intercepted StorageGetter(Local<Name> property, | |||
| 554 | 554 | } | |
| 555 | 555 | ||
| 556 | 556 | Storage* storage; | |
| 557 | - ASSIGN_OR_RETURN_UNWRAP(&storage, info.This(), Intercepted::kNo); | ||
| 557 | + ASSIGN_OR_RETURN_UNWRAP(&storage, info.HolderV2(), Intercepted::kNo); | ||
| 558 | 558 | Local<Value> result; | |
| 559 | 559 | ||
| 560 | 560 | if (storage->Load(property).ToLocal(&result) && !result->IsNull()) { | |
@@ -568,7 +568,7 @@ static Intercepted StorageSetter(Local<Name> property, | |||
| 568 | 568 | Local<Value> value, | |
| 569 | 569 | const PropertyCallbackInfo<void>& info) { | |
| 570 | 570 | Storage* storage; | |
| 571 | - ASSIGN_OR_RETURN_UNWRAP(&storage, info.This(), Intercepted::kNo); | ||
| 571 | + ASSIGN_OR_RETURN_UNWRAP(&storage, info.HolderV2(), Intercepted::kNo); | ||
| 572 | 572 | ||
| 573 | 573 | if (storage->Store(property, value).IsNothing()) { | |
| 574 | 574 | info.GetReturnValue().SetFalse(); | |
@@ -584,7 +584,7 @@ static Intercepted StorageQuery(Local<Name> property, | |||
| 584 | 584 | } | |
| 585 | 585 | ||
| 586 | 586 | Storage* storage; | |
| 587 | - ASSIGN_OR_RETURN_UNWRAP(&storage, info.This(), Intercepted::kNo); | ||
| 587 | + ASSIGN_OR_RETURN_UNWRAP(&storage, info.HolderV2(), Intercepted::kNo); | ||
| 588 | 588 | Local<Value> result; | |
| 589 | 589 | if (!storage->Load(property).ToLocal(&result) || result->IsNull()) { | |
| 590 | 590 | return Intercepted::kNo; | |
@@ -597,7 +597,7 @@ static Intercepted StorageQuery(Local<Name> property, | |||
| 597 | 597 | static Intercepted StorageDeleter(Local<Name> property, | |
| 598 | 598 | const PropertyCallbackInfo<Boolean>& info) { | |
| 599 | 599 | Storage* storage; | |
| 600 | - ASSIGN_OR_RETURN_UNWRAP(&storage, info.This(), Intercepted::kNo); | ||
| 600 | + ASSIGN_OR_RETURN_UNWRAP(&storage, info.HolderV2(), Intercepted::kNo); | ||
| 601 | 601 | ||
| 602 | 602 | info.GetReturnValue().Set(storage->Remove(property).IsJust()); | |
| 603 | 603 | ||
@@ -606,7 +606,7 @@ static Intercepted StorageDeleter(Local<Name> property, | |||
| 606 | 606 | ||
| 607 | 607 | static void StorageEnumerator(const PropertyCallbackInfo<Array>& info) { | |
| 608 | 608 | Storage* storage; | |
| 609 | - ASSIGN_OR_RETURN_UNWRAP(&storage, info.This()); | ||
| 609 | + ASSIGN_OR_RETURN_UNWRAP(&storage, info.HolderV2()); | ||
| 610 | 610 | Local<Array> result; | |
| 611 | 611 | if (!storage->Enumerate().ToLocal(&result)) { | |
| 612 | 612 | return; | |
@@ -618,7 +618,7 @@ static Intercepted StorageDefiner(Local<Name> property, | |||
| 618 | 618 | const PropertyDescriptor& desc, | |
| 619 | 619 | const PropertyCallbackInfo<void>& info) { | |
| 620 | 620 | Storage* storage; | |
| 621 | - ASSIGN_OR_RETURN_UNWRAP(&storage, info.This(), Intercepted::kNo); | ||
| 621 | + ASSIGN_OR_RETURN_UNWRAP(&storage, info.HolderV2(), Intercepted::kNo); | ||
| 622 | 622 | ||
| 623 | 623 | if (desc.has_value()) { | |
| 624 | 624 | return StorageSetter(property, desc.value(), info); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments