Don't set a prototype for unscopable objects (#37122)

Testing: Covered by existing web platform tests
Fixes: https://github.com/servo/servo/issues/25022

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2025-05-25 02:16:31 +02:00 committed by GitHub
parent 4ae72ecb8e
commit 2b840a4d9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 24 deletions

View file

@ -16,11 +16,11 @@ use js::jsapi::{
GetFunctionRealm, GetNonCCWObjectGlobal, GetRealmGlobalOrNull, GetWellKnownSymbol, GetFunctionRealm, GetNonCCWObjectGlobal, GetRealmGlobalOrNull, GetWellKnownSymbol,
HandleObject as RawHandleObject, IsSharableCompartment, IsSystemCompartment, HandleObject as RawHandleObject, IsSharableCompartment, IsSystemCompartment,
JS_AtomizeAndPinString, JS_GetFunctionObject, JS_GetProperty, JS_IterateCompartments, JS_AtomizeAndPinString, JS_GetFunctionObject, JS_GetProperty, JS_IterateCompartments,
JS_NewFunction, JS_NewGlobalObject, JS_NewObject, JS_NewPlainObject, JS_NewStringCopyN, JS_NewFunction, JS_NewGlobalObject, JS_NewObject, JS_NewStringCopyN, JS_SetReservedSlot,
JS_SetReservedSlot, JS_WrapObject, JSAutoRealm, JSClass, JSClassOps, JSContext, JS_WrapObject, JSAutoRealm, JSClass, JSClassOps, JSContext, JSFUN_CONSTRUCTOR, JSFunctionSpec,
JSFUN_CONSTRUCTOR, JSFunctionSpec, JSObject, JSPROP_ENUMERATE, JSPROP_PERMANENT, JSObject, JSPROP_ENUMERATE, JSPROP_PERMANENT, JSPROP_READONLY, JSPROP_RESOLVING,
JSPROP_READONLY, JSPROP_RESOLVING, JSPropertySpec, JSString, JSTracer, ObjectOps, JSPropertySpec, JSString, JSTracer, ObjectOps, OnNewGlobalHookOption, SymbolCode,
OnNewGlobalHookOption, SymbolCode, TrueHandleValue, Value, jsid, TrueHandleValue, Value, jsid,
}; };
use js::jsval::{JSVal, NullValue, PrivateValue}; use js::jsval::{JSVal, NullValue, PrivateValue};
use js::rust::wrappers::{ use js::rust::wrappers::{
@ -473,7 +473,11 @@ fn create_unscopable_object(cx: SafeJSContext, names: &[&CStr], mut rval: Mutabl
assert!(!names.is_empty()); assert!(!names.is_empty());
assert!(rval.is_null()); assert!(rval.is_null());
unsafe { unsafe {
rval.set(JS_NewPlainObject(*cx)); rval.set(JS_NewObjectWithGivenProto(
*cx,
ptr::null(),
HandleObject::null(),
));
assert!(!rval.is_null()); assert!(!rval.is_null());
for &name in names { for &name in names {
assert!(JS_DefineProperty( assert!(JS_DefineProperty(

View file

@ -5,9 +5,6 @@
[AbortSignal interface: existence and properties of interface prototype object's @@unscopables property] [AbortSignal interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL expected: FAIL
[Document interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[AbortSignal interface: existence and properties of interface object] [AbortSignal interface: existence and properties of interface object]
expected: FAIL expected: FAIL
@ -35,24 +32,15 @@
[AbortSignal interface: attribute aborted] [AbortSignal interface: attribute aborted]
expected: FAIL 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] [AbortController interface: new AbortController() must inherit property "signal" with the proper type]
expected: FAIL expected: FAIL
[AbortController interface: new AbortController() must inherit property "abort()" with the proper type] [AbortController interface: new AbortController() must inherit property "abort()" with the proper type]
expected: FAIL 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] [EventTarget interface: calling dispatchEvent(Event) on new AbortController().signal with too few arguments must throw TypeError]
expected: FAIL 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] [AbortSignal interface: new AbortController().signal must inherit property "aborted" with the proper type]
expected: FAIL expected: FAIL
@ -80,9 +68,6 @@
[Stringification of new AbortController().signal] [Stringification of new AbortController().signal]
expected: FAIL 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] [XPathNSResolver interface: document.createNSResolver(document.body) must inherit property "lookupNamespaceURI(DOMString?)" with the proper type]
expected: FAIL expected: FAIL

View file

@ -1,3 +0,0 @@
[interface-prototype-object.html]
[[Unscopable\] extended attribute makes @@unscopables object on the prototype object, whose prototype is null.]
expected: FAIL