diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 067e5b76386..c3dc4d2311a 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2374,7 +2374,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): if self.descriptor.interface.isCallback(): assert not self.descriptor.interface.ctor() and self.descriptor.interface.hasConstants() return CGGeneric("""\ -create_callback_interface_object(cx, receiver, throwing_constructor, 0, sConstants, %s);""" % str_to_const_array(name)) +create_callback_interface_object(cx, receiver, sConstants, %s);""" % str_to_const_array(name)) protoChain = self.descriptor.prototypeChain if len(protoChain) == 1: diff --git a/components/script/dom/bindings/interface.rs b/components/script/dom/bindings/interface.rs index a7420c2aeb4..cf4b7cc7924 100644 --- a/components/script/dom/bindings/interface.rs +++ b/components/script/dom/bindings/interface.rs @@ -5,10 +5,11 @@ //! Machinery to initialise interface prototype objects and interface objects. use dom::bindings::utils::{ConstantSpec, NonNullJSNative, define_constants}; -use js::jsapi::{HandleObject, JSClass, JSContext, JSFunctionSpec, JSObject}; -use js::jsapi::{JSPropertySpec, JS_DefineProperty1, JS_GetFunctionObject}; -use js::jsapi::{JS_LinkConstructorAndPrototype, JS_NewFunction}; -use js::jsapi::{JS_NewObjectWithUniqueType, MutableHandleObject, RootedObject}; +use js::jsapi::{HandleObject, JSClass, JSContext, JSFunctionSpec}; +use js::jsapi::{JSObject, JSPropertySpec, JS_DefineProperty1, JS_DefineProperty2}; +use js::jsapi::{JS_GetFunctionObject, JS_InternString, JS_LinkConstructorAndPrototype}; +use js::jsapi::{JS_NewFunction, JS_NewObject, JS_NewObjectWithUniqueType}; +use js::jsapi::{MutableHandleObject, RootedObject, RootedString}; use js::rust::{define_methods, define_properties}; use js::{JSFUN_CONSTRUCTOR, JSPROP_PERMANENT, JSPROP_READONLY}; use libc; @@ -18,15 +19,13 @@ use std::ptr; pub unsafe fn create_callback_interface_object( cx: *mut JSContext, receiver: HandleObject, - constructor_native: NonNullJSNative, - length: u32, constants: &'static [ConstantSpec], name: &'static [u8]) { assert!(!constants.is_empty()); - let interface_object = - RootedObject::new(cx, create_constructor(cx, constructor_native, length, name)); + let interface_object = RootedObject::new(cx, JS_NewObject(cx, ptr::null())); assert!(!interface_object.ptr.is_null()); define_constants(cx, interface_object.handle(), constants); + define_name(cx, interface_object.handle(), name); define_on_global_object(cx, receiver, name, interface_object.handle()); } @@ -140,6 +139,19 @@ unsafe fn create_object( define_constants(cx, rval.handle(), constants); } +unsafe fn define_name(cx: *mut JSContext, obj: HandleObject, name: &'static [u8]) { + assert!(*name.last().unwrap() == b'\0'); + let name = + RootedString::new(cx, JS_InternString(cx, name.as_ptr() as *const libc::c_char)); + assert!(!name.ptr.is_null()); + assert!(JS_DefineProperty2(cx, + obj, + b"name\0".as_ptr() as *const libc::c_char, + name.handle(), + JSPROP_READONLY, + None, None)); +} + unsafe fn define_on_global_object( cx: *mut JSContext, receiver: HandleObject, diff --git a/tests/wpt/metadata/dom/interfaces.html.ini b/tests/wpt/metadata/dom/interfaces.html.ini index 7e5e7b17fec..d6fde8eb167 100644 --- a/tests/wpt/metadata/dom/interfaces.html.ini +++ b/tests/wpt/metadata/dom/interfaces.html.ini @@ -195,9 +195,6 @@ [Range interface: stringifier] expected: FAIL - [NodeFilter interface: existence and properties of interface object] - expected: FAIL - [DOMSettableTokenList interface: existence and properties of interface prototype object] expected: FAIL