| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 56ce83b commit d7a4b22
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,7 +41,7 @@ | |||
| 41 | 41 | ||
| 42 | 42 | # Reset this number to 0 on major V8 upgrades. | |
| 43 | 43 | # Increment by one for each non-official patch applied to deps/v8. | |
| 44 | - 'v8_embedder_string': '-node.24', | ||
| 44 | + 'v8_embedder_string': '-node.25', | ||
| 45 | 45 | ||
| 46 | 46 | ##### V8 defaults for Node.js ##### | |
| 47 | 47 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -683,6 +683,13 @@ enum class PropertyHandlerFlags { | |||
| 683 | 683 | */ | |
| 684 | 684 | kHasNoSideEffect = 1 << 2, | |
| 685 | 685 | ||
| 686 | + /** | ||
| 687 | + * The interceptor may return non-configurable (PropertyAttribute::DontDelete) | ||
| 688 | + * properties. When set on a global object's interceptor, it will be consulted | ||
| 689 | + * during HasRestrictedGlobalProperty checks for lexical declarations. | ||
| 690 | + */ | ||
| 691 | + kHasDontDeleteProperty = 1 << 3, | ||
| 692 | + | ||
| 686 | 693 | /** | |
| 687 | 694 | * This flag is used to distinguish which callbacks were provided - | |
| 688 | 695 | * GenericNamedPropertyXXXCallback (old signature) or | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1613,6 +1613,8 @@ i::DirectHandle<i::InterceptorInfo> CreateInterceptorInfo( | |||
| 1613 | 1613 | !(flags & PropertyHandlerFlags::kOnlyInterceptStrings)); | |
| 1614 | 1614 | obj->set_non_masking(flags & PropertyHandlerFlags::kNonMasking); | |
| 1615 | 1615 | obj->set_has_no_side_effect(flags & PropertyHandlerFlags::kHasNoSideEffect); | |
| 1616 | + obj->set_has_dont_delete_property( | ||
| 1617 | + flags & PropertyHandlerFlags::kHasDontDeleteProperty); | ||
| 1616 | 1618 | ||
| 1617 | 1619 | if (data.IsEmpty()) { | |
| 1618 | 1620 | data = v8::Undefined(reinterpret_cast<v8::Isolate*>(i_isolate)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -230,18 +230,14 @@ MaybeDirectHandle<Context> NewScriptContext( | |||
| 230 | 230 | } | |
| 231 | 231 | ||
| 232 | 232 | if (IsLexicalVariableMode(mode)) { | |
| 233 | - LookupIterator lookup_it(isolate, global_object, name, global_object, | ||
| 234 | - LookupIterator::OWN_SKIP_INTERCEPTOR); | ||
| 235 | - Maybe<PropertyAttributes> maybe = | ||
| 236 | - JSReceiver::GetPropertyAttributes(&lookup_it); | ||
| 237 | - // Can't fail since the we looking up own properties on the global object | ||
| 238 | - // skipping interceptors. | ||
| 239 | - CHECK(!maybe.IsNothing()); | ||
| 240 | - if ((maybe.FromJust() & DONT_DELETE) != 0) { | ||
| 241 | - // ES#sec-globaldeclarationinstantiation 5.a: | ||
| 233 | + Maybe<bool> has_restricted = JSGlobalObject::HasRestrictedGlobalProperty( | ||
| 234 | + isolate, global_object, name); | ||
| 235 | + if (has_restricted.IsNothing()) return MaybeDirectHandle<Context>(); | ||
| 236 | + if (has_restricted.FromJust()) { | ||
| 237 | + // https://tc39.es/ecma262/#sec-globaldeclarationinstantiation 3.a: | ||
| 242 | 238 | // If envRec.HasVarDeclaration(name) is true, throw a SyntaxError | |
| 243 | 239 | // exception. | |
| 244 | - // ES#sec-globaldeclarationinstantiation 5.d: | ||
| 240 | + // https://tc39.es/ecma262/#sec-globaldeclarationinstantiation 3.d: | ||
| 245 | 241 | // If hasRestrictedGlobal is true, throw a SyntaxError exception. | |
| 246 | 242 | MessageLocation location(script, 0, 1); | |
| 247 | 243 | isolate->ThrowAt(isolate->factory()->NewSyntaxError( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -203,6 +203,8 @@ BOOL_ACCESSORS(InterceptorInfo, flags, has_no_side_effect, | |||
| 203 | 203 | // TODO(ishell): remove once all the Api changes are done. | |
| 204 | 204 | BOOL_ACCESSORS(InterceptorInfo, flags, has_new_callbacks_signature, | |
| 205 | 205 | HasNewCallbacksSignatureBit::kShift) | |
| 206 | + BOOL_ACCESSORS(InterceptorInfo, flags, has_dont_delete_property, | ||
| 207 | + HasDontDeletePropertyBit::kShift) | ||
| 206 | 208 | ||
| 207 | 209 | void InterceptorInfo::RemoveCallbackRedirectionForSerialization( | |
| 208 | 210 | IsolateForSandbox isolate) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -182,6 +182,7 @@ class InterceptorInfo | |||
| 182 | 182 | // TODO(ishell): remove support for old signatures once they go through | |
| 183 | 183 | // Api deprecation process. | |
| 184 | 184 | DECL_BOOLEAN_ACCESSORS(has_new_callbacks_signature) | |
| 185 | + DECL_BOOLEAN_ACCESSORS(has_dont_delete_property) | ||
| 185 | 186 | ||
| 186 | 187 | DEFINE_TORQUE_GENERATED_INTERCEPTOR_INFO_FLAGS() | |
| 187 | 188 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ bitfield struct InterceptorInfoFlags extends uint31 { | |||
| 8 | 8 | named: bool: 1 bit; | |
| 9 | 9 | has_no_side_effect: bool: 1 bit; | |
| 10 | 10 | has_new_callbacks_signature: bool: 1 bit; | |
| 11 | + has_dont_delete_property: bool: 1 bit; | ||
| 11 | 12 | } | |
| 12 | 13 | ||
| 13 | 14 | extern class InterceptorInfo extends HeapObject { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5785,6 +5785,24 @@ void JSGlobalObject::InvalidatePropertyCell(DirectHandle<JSGlobalObject> global, | |||
| 5785 | 5785 | value); | |
| 5786 | 5786 | } | |
| 5787 | 5787 | ||
| 5788 | + // static | ||
| 5789 | + Maybe<bool> JSGlobalObject::HasRestrictedGlobalProperty( | ||
| 5790 | + Isolate* isolate, DirectHandle<JSGlobalObject> global, | ||
| 5791 | + DirectHandle<Name> name) { | ||
| 5792 | + LookupIterator::Configuration config = LookupIterator::OWN_SKIP_INTERCEPTOR; | ||
| 5793 | + if (global->HasNamedInterceptor() && | ||
| 5794 | + global->GetNamedInterceptor()->has_dont_delete_property()) { | ||
| 5795 | + config = LookupIterator::OWN; | ||
| 5796 | + } | ||
| 5797 | + LookupIterator it(isolate, global, name, global, config); | ||
| 5798 | + Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | ||
| 5799 | + if (maybe.IsNothing()) return Nothing<bool>(); | ||
| 5800 | + // Global var and function bindings (except those that are introduced by | ||
| 5801 | + // non-strict direct eval) are non-configurable and are therefore restricted | ||
| 5802 | + // global properties. | ||
| 5803 | + return Just((maybe.FromJust() & DONT_DELETE) != 0); | ||
| 5804 | + } | ||
| 5805 | + | ||
| 5788 | 5806 | // static | |
| 5789 | 5807 | MaybeDirectHandle<JSDate> JSDate::New(Isolate* isolate, | |
| 5790 | 5808 | DirectHandle<JSFunction> constructor, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1218,6 +1218,11 @@ class JSGlobalObject | |||
| 1218 | 1218 | static void InvalidatePropertyCell(DirectHandle<JSGlobalObject> object, | |
| 1219 | 1219 | DirectHandle<Name> name); | |
| 1220 | 1220 | ||
| 1221 | + // https://tc39.es/ecma262/#sec-hasrestrictedglobalproperty | ||
| 1222 | + static Maybe<bool> HasRestrictedGlobalProperty( | ||
| 1223 | + Isolate* isolate, DirectHandle<JSGlobalObject> global, | ||
| 1224 | + DirectHandle<Name> name); | ||
| 1225 | + | ||
| 1221 | 1226 | inline bool IsDetached(); | |
| 1222 | 1227 | inline Tagged<NativeContext> native_context(); | |
| 1223 | 1228 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -834,6 +834,49 @@ THREADED_TEST(InterceptorFunctionRedeclareWithQueryCallback) { | |||
| 834 | 834 | v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).ToLocalChecked(); | |
| 835 | 835 | } | |
| 836 | 836 | ||
| 837 | + // A lexical declaration must throw when the interceptor reports the property | ||
| 838 | + // as non-configurable (DontDelete), per HasRestrictedGlobalProperty checks in | ||
| 839 | + // https://tc39.es/ecma262/#sec-globaldeclarationinstantiation. | ||
| 840 | + THREADED_TEST(LexicalDeclThrowsForRestrictedGlobalViaInterceptor) { | ||
| 841 | + v8::HandleScope scope(CcTest::isolate()); | ||
| 842 | + LocalContext env; | ||
| 843 | + v8::Local<v8::FunctionTemplate> templ = | ||
| 844 | + v8::FunctionTemplate::New(CcTest::isolate()); | ||
| 845 | + | ||
| 846 | + v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate(); | ||
| 847 | + object_template->SetHandler(v8::NamedPropertyHandlerConfiguration( | ||
| 848 | + nullptr, nullptr, QueryCallbackSetDontDelete, nullptr, nullptr, | ||
| 849 | + v8::Local<v8::Value>(), | ||
| 850 | + v8::PropertyHandlerFlags::kHasDontDeleteProperty)); | ||
| 851 | + v8::Local<v8::Context> ctx = | ||
| 852 | + v8::Context::New(CcTest::isolate(), nullptr, object_template); | ||
| 853 | + | ||
| 854 | + v8::TryCatch try_catch(CcTest::isolate()); | ||
| 855 | + v8::Local<v8::String> code = v8_str("let x;"); | ||
| 856 | + CHECK(v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).IsEmpty()); | ||
| 857 | + CHECK(try_catch.HasCaught()); | ||
| 858 | + } | ||
| 859 | + | ||
| 860 | + // Without kHasDontDeleteProperty, the interceptor is not consulted for | ||
| 861 | + // HasRestrictedGlobalProperty and lexical declarations succeed. | ||
| 862 | + THREADED_TEST(LexicalDeclSucceedsWithoutRestrictedGlobalFlag) { | ||
| 863 | + v8::HandleScope scope(CcTest::isolate()); | ||
| 864 | + LocalContext env; | ||
| 865 | + v8::Local<v8::FunctionTemplate> templ = | ||
| 866 | + v8::FunctionTemplate::New(CcTest::isolate()); | ||
| 867 | + | ||
| 868 | + v8::Local<ObjectTemplate> object_template = templ->InstanceTemplate(); | ||
| 869 | + object_template->SetHandler(v8::NamedPropertyHandlerConfiguration( | ||
| 870 | + nullptr, nullptr, QueryCallbackSetDontDelete)); | ||
| 871 | + v8::Local<v8::Context> ctx = | ||
| 872 | + v8::Context::New(CcTest::isolate(), nullptr, object_template); | ||
| 873 | + | ||
| 874 | + v8::TryCatch try_catch(CcTest::isolate()); | ||
| 875 | + v8::Local<v8::String> code = v8_str("let x;"); | ||
| 876 | + CHECK(!v8::Script::Compile(ctx, code).ToLocalChecked()->Run(ctx).IsEmpty()); | ||
| 877 | + CHECK(!try_catch.HasCaught()); | ||
| 878 | + } | ||
| 879 | + | ||
| 837 | 880 | // Regression test for chromium bug 656648. | |
| 838 | 881 | // Do not crash on non-masking, intercepting setter callbacks. | |
| 839 | 882 | THREADED_TEST(NonMaskingInterceptor) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments