From 2b840a4d9a3f8803c8c79d4855244580bd4b1616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20W=C3=BClker?= Date: Sun, 25 May 2025 02:16:31 +0200 Subject: [PATCH] Don't set a prototype for unscopable objects (#37122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Testing: Covered by existing web platform tests Fixes: https://github.com/servo/servo/issues/25022 --------- Signed-off-by: Simon Wülker --- components/script_bindings/interface.rs | 16 ++++++++++------ tests/wpt/meta/dom/idlharness.window.js.ini | 15 --------------- .../interface-prototype-object.html.ini | 3 --- 3 files changed, 10 insertions(+), 24 deletions(-) delete mode 100644 tests/wpt/meta/webidl/ecmascript-binding/interface-prototype-object.html.ini diff --git a/components/script_bindings/interface.rs b/components/script_bindings/interface.rs index 2491924d0c0..e185cfe9cfd 100644 --- a/components/script_bindings/interface.rs +++ b/components/script_bindings/interface.rs @@ -16,11 +16,11 @@ use js::jsapi::{ GetFunctionRealm, GetNonCCWObjectGlobal, GetRealmGlobalOrNull, GetWellKnownSymbol, HandleObject as RawHandleObject, IsSharableCompartment, IsSystemCompartment, JS_AtomizeAndPinString, JS_GetFunctionObject, JS_GetProperty, JS_IterateCompartments, - JS_NewFunction, JS_NewGlobalObject, JS_NewObject, JS_NewPlainObject, JS_NewStringCopyN, - JS_SetReservedSlot, JS_WrapObject, JSAutoRealm, JSClass, JSClassOps, JSContext, - JSFUN_CONSTRUCTOR, JSFunctionSpec, JSObject, JSPROP_ENUMERATE, JSPROP_PERMANENT, - JSPROP_READONLY, JSPROP_RESOLVING, JSPropertySpec, JSString, JSTracer, ObjectOps, - OnNewGlobalHookOption, SymbolCode, TrueHandleValue, Value, jsid, + JS_NewFunction, JS_NewGlobalObject, JS_NewObject, JS_NewStringCopyN, JS_SetReservedSlot, + JS_WrapObject, JSAutoRealm, JSClass, JSClassOps, JSContext, JSFUN_CONSTRUCTOR, JSFunctionSpec, + JSObject, JSPROP_ENUMERATE, JSPROP_PERMANENT, JSPROP_READONLY, JSPROP_RESOLVING, + JSPropertySpec, JSString, JSTracer, ObjectOps, OnNewGlobalHookOption, SymbolCode, + TrueHandleValue, Value, jsid, }; use js::jsval::{JSVal, NullValue, PrivateValue}; use js::rust::wrappers::{ @@ -473,7 +473,11 @@ fn create_unscopable_object(cx: SafeJSContext, names: &[&CStr], mut rval: Mutabl assert!(!names.is_empty()); assert!(rval.is_null()); unsafe { - rval.set(JS_NewPlainObject(*cx)); + rval.set(JS_NewObjectWithGivenProto( + *cx, + ptr::null(), + HandleObject::null(), + )); assert!(!rval.is_null()); for &name in names { assert!(JS_DefineProperty( diff --git a/tests/wpt/meta/dom/idlharness.window.js.ini b/tests/wpt/meta/dom/idlharness.window.js.ini index 3ad37c3770f..298c194b5ee 100644 --- a/tests/wpt/meta/dom/idlharness.window.js.ini +++ b/tests/wpt/meta/dom/idlharness.window.js.ini @@ -5,9 +5,6 @@ [AbortSignal interface: existence and properties of interface prototype object's @@unscopables property] expected: FAIL - [Document interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - [AbortSignal interface: existence and properties of interface object] expected: FAIL @@ -35,24 +32,15 @@ [AbortSignal interface: attribute aborted] expected: FAIL - [CharacterData interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - [AbortController interface: new AbortController() must inherit property "signal" with the proper type] expected: FAIL [AbortController interface: new AbortController() must inherit property "abort()" with the proper type] expected: FAIL - [DocumentType interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - [EventTarget interface: calling dispatchEvent(Event) on new AbortController().signal with too few arguments must throw TypeError] expected: FAIL - [DocumentFragment interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - [AbortSignal interface: new AbortController().signal must inherit property "aborted" with the proper type] expected: FAIL @@ -80,9 +68,6 @@ [Stringification of new AbortController().signal] expected: FAIL - [Element interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - [XPathNSResolver interface: document.createNSResolver(document.body) must inherit property "lookupNamespaceURI(DOMString?)" with the proper type] expected: FAIL diff --git a/tests/wpt/meta/webidl/ecmascript-binding/interface-prototype-object.html.ini b/tests/wpt/meta/webidl/ecmascript-binding/interface-prototype-object.html.ini deleted file mode 100644 index d6427d91f6a..00000000000 --- a/tests/wpt/meta/webidl/ecmascript-binding/interface-prototype-object.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[interface-prototype-object.html] - [[Unscopable\] extended attribute makes @@unscopables object on the prototype object, whose prototype is null.] - expected: FAIL