mirror of
https://github.com/servo/servo.git
synced 2025-07-30 02:30:21 +01:00
Support [LegacyUnenumerableNamedProperties]
This commit is contained in:
parent
cbf514d63f
commit
7f36247d03
6 changed files with 75 additions and 27 deletions
|
@ -2602,13 +2602,25 @@ class CGDefineProxyHandler(CGAbstractMethod):
|
||||||
if self.descriptor.operations['NamedDeleter']:
|
if self.descriptor.operations['NamedDeleter']:
|
||||||
customDelete = 'delete'
|
customDelete = 'delete'
|
||||||
|
|
||||||
body = """\
|
getOwnEnumerablePropertyKeys = "None"
|
||||||
|
if self.descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"):
|
||||||
|
getOwnEnumerablePropertyKeys = "Some(getOwnEnumerablePropertyKeys)"
|
||||||
|
|
||||||
|
args = {
|
||||||
|
"defineProperty": customDefineProperty,
|
||||||
|
"delete": customDelete,
|
||||||
|
"getOwnEnumerablePropertyKeys": getOwnEnumerablePropertyKeys,
|
||||||
|
"trace": TRACE_HOOK_NAME,
|
||||||
|
"finalize": FINALIZE_HOOK_NAME,
|
||||||
|
}
|
||||||
|
|
||||||
|
return CGGeneric("""\
|
||||||
let traps = ProxyTraps {
|
let traps = ProxyTraps {
|
||||||
enter: None,
|
enter: None,
|
||||||
getOwnPropertyDescriptor: Some(getOwnPropertyDescriptor),
|
getOwnPropertyDescriptor: Some(getOwnPropertyDescriptor),
|
||||||
defineProperty: Some(%s),
|
defineProperty: Some(%(defineProperty)s),
|
||||||
ownPropertyKeys: Some(own_property_keys),
|
ownPropertyKeys: Some(own_property_keys),
|
||||||
delete_: Some(%s),
|
delete_: Some(%(delete)s),
|
||||||
enumerate: None,
|
enumerate: None,
|
||||||
preventExtensions: Some(proxyhandler::prevent_extensions),
|
preventExtensions: Some(proxyhandler::prevent_extensions),
|
||||||
isExtensible: Some(proxyhandler::is_extensible),
|
isExtensible: Some(proxyhandler::is_extensible),
|
||||||
|
@ -2619,7 +2631,7 @@ let traps = ProxyTraps {
|
||||||
construct: None,
|
construct: None,
|
||||||
getPropertyDescriptor: Some(get_property_descriptor),
|
getPropertyDescriptor: Some(get_property_descriptor),
|
||||||
hasOwn: Some(hasOwn),
|
hasOwn: Some(hasOwn),
|
||||||
getOwnEnumerablePropertyKeys: None,
|
getOwnEnumerablePropertyKeys: %(getOwnEnumerablePropertyKeys)s,
|
||||||
nativeCall: None,
|
nativeCall: None,
|
||||||
hasInstance: None,
|
hasInstance: None,
|
||||||
objectClassIs: None,
|
objectClassIs: None,
|
||||||
|
@ -2627,16 +2639,15 @@ let traps = ProxyTraps {
|
||||||
fun_toString: None,
|
fun_toString: None,
|
||||||
boxedValue_unbox: None,
|
boxedValue_unbox: None,
|
||||||
defaultValue: None,
|
defaultValue: None,
|
||||||
trace: Some(%s),
|
trace: Some(%(trace)s),
|
||||||
finalize: Some(%s),
|
finalize: Some(%(finalize)s),
|
||||||
objectMoved: None,
|
objectMoved: None,
|
||||||
isCallable: None,
|
isCallable: None,
|
||||||
isConstructor: None,
|
isConstructor: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
CreateProxyHandler(&traps, &Class as *const _ as *const _)\
|
CreateProxyHandler(&traps, &Class as *const _ as *const _)\
|
||||||
""" % (customDefineProperty, customDelete, TRACE_HOOK_NAME, FINALIZE_HOOK_NAME)
|
""" % args)
|
||||||
return CGGeneric(body)
|
|
||||||
|
|
||||||
|
|
||||||
class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
||||||
|
@ -4340,9 +4351,15 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
|
|
||||||
namedGetter = self.descriptor.operations['NamedGetter']
|
namedGetter = self.descriptor.operations['NamedGetter']
|
||||||
if namedGetter:
|
if namedGetter:
|
||||||
attrs = "JSPROP_ENUMERATE"
|
attrs = []
|
||||||
|
if not self.descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"):
|
||||||
|
attrs.append("JSPROP_ENUMERATE")
|
||||||
if self.descriptor.operations['NamedSetter'] is None:
|
if self.descriptor.operations['NamedSetter'] is None:
|
||||||
attrs += " | JSPROP_READONLY"
|
attrs.append("JSPROP_READONLY")
|
||||||
|
if attrs:
|
||||||
|
attrs = " | ".join(attrs)
|
||||||
|
else:
|
||||||
|
attrs = "0"
|
||||||
fillDescriptor = ("desc.get().value = result_root.ptr;\n"
|
fillDescriptor = ("desc.get().value = result_root.ptr;\n"
|
||||||
"fill_property_descriptor(&mut *desc.ptr, *proxy.ptr, %s);\n"
|
"fill_property_descriptor(&mut *desc.ptr, *proxy.ptr, %s);\n"
|
||||||
"return true;" % attrs)
|
"return true;" % attrs)
|
||||||
|
@ -4518,6 +4535,49 @@ class CGDOMJSProxyHandler_ownPropertyKeys(CGAbstractExternMethod):
|
||||||
return CGGeneric(self.getBody())
|
return CGGeneric(self.getBody())
|
||||||
|
|
||||||
|
|
||||||
|
class CGDOMJSProxyHandler_getOwnEnumerablePropertyKeys(CGAbstractExternMethod):
|
||||||
|
def __init__(self, descriptor):
|
||||||
|
assert (descriptor.operations["IndexedGetter"] and
|
||||||
|
descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"))
|
||||||
|
args = [Argument('*mut JSContext', 'cx'),
|
||||||
|
Argument('HandleObject', 'proxy'),
|
||||||
|
Argument('*mut AutoIdVector', 'props')]
|
||||||
|
CGAbstractExternMethod.__init__(self, descriptor,
|
||||||
|
"getOwnEnumerablePropertyKeys", "bool", args)
|
||||||
|
self.descriptor = descriptor
|
||||||
|
|
||||||
|
def getBody(self):
|
||||||
|
body = dedent(
|
||||||
|
"""
|
||||||
|
let unwrapped_proxy = UnwrapProxy(proxy);
|
||||||
|
""")
|
||||||
|
|
||||||
|
if self.descriptor.operations['IndexedGetter']:
|
||||||
|
body += dedent(
|
||||||
|
"""
|
||||||
|
for i in 0..(*unwrapped_proxy).Length() {
|
||||||
|
let rooted_jsid = RootedId::new(cx, int_to_jsid(i as i32));
|
||||||
|
AppendToAutoIdVector(props, rooted_jsid.handle().get());
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
|
||||||
|
body += dedent(
|
||||||
|
"""
|
||||||
|
let expando = get_expando_object(proxy);
|
||||||
|
if !expando.is_null() {
|
||||||
|
let rooted_expando = RootedObject::new(cx, expando);
|
||||||
|
GetPropertyKeys(cx, rooted_expando.handle(), JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS, props);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
""")
|
||||||
|
|
||||||
|
return body
|
||||||
|
|
||||||
|
def definition_body(self):
|
||||||
|
return CGGeneric(self.getBody())
|
||||||
|
|
||||||
|
|
||||||
class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'proxy'),
|
args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'proxy'),
|
||||||
|
@ -4967,6 +5027,8 @@ class CGDescriptor(CGThing):
|
||||||
cgThings.append(CGProxyUnwrap(descriptor))
|
cgThings.append(CGProxyUnwrap(descriptor))
|
||||||
cgThings.append(CGDOMJSProxyHandlerDOMClass(descriptor))
|
cgThings.append(CGDOMJSProxyHandlerDOMClass(descriptor))
|
||||||
cgThings.append(CGDOMJSProxyHandler_ownPropertyKeys(descriptor))
|
cgThings.append(CGDOMJSProxyHandler_ownPropertyKeys(descriptor))
|
||||||
|
if descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"):
|
||||||
|
cgThings.append(CGDOMJSProxyHandler_getOwnEnumerablePropertyKeys(descriptor))
|
||||||
cgThings.append(CGDOMJSProxyHandler_getOwnPropertyDescriptor(descriptor))
|
cgThings.append(CGDOMJSProxyHandler_getOwnPropertyDescriptor(descriptor))
|
||||||
cgThings.append(CGDOMJSProxyHandler_className(descriptor))
|
cgThings.append(CGDOMJSProxyHandler_className(descriptor))
|
||||||
cgThings.append(CGDOMJSProxyHandler_get(descriptor))
|
cgThings.append(CGDOMJSProxyHandler_get(descriptor))
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#interface-htmlcollection
|
// https://dom.spec.whatwg.org/#interface-htmlcollection
|
||||||
|
|
||||||
|
[LegacyUnenumerableNamedProperties]
|
||||||
interface HTMLCollection {
|
interface HTMLCollection {
|
||||||
[Pure]
|
[Pure]
|
||||||
readonly attribute unsigned long length;
|
readonly attribute unsigned long length;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#htmlformcontrolscollection
|
// https://html.spec.whatwg.org/multipage/#htmlformcontrolscollection
|
||||||
|
[LegacyUnenumerableNamedProperties]
|
||||||
interface HTMLFormControlsCollection : HTMLCollection {
|
interface HTMLFormControlsCollection : HTMLCollection {
|
||||||
// inherits length and item()
|
// inherits length and item()
|
||||||
getter (RadioNodeList or Element)? namedItem(DOMString name); // shadows inherited namedItem()
|
getter (RadioNodeList or Element)? namedItem(DOMString name); // shadows inherited namedItem()
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#interface-namednodemap
|
// https://dom.spec.whatwg.org/#interface-namednodemap
|
||||||
|
|
||||||
|
[LegacyUnenumerableNamedProperties]
|
||||||
interface NamedNodeMap {
|
interface NamedNodeMap {
|
||||||
[Pure]
|
[Pure]
|
||||||
readonly attribute unsigned long length;
|
readonly attribute unsigned long length;
|
||||||
|
|
|
@ -6,18 +6,6 @@
|
||||||
[getAttributeNames tests]
|
[getAttributeNames tests]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Own property correctness with basic attributes]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Own property correctness with non-namespaced attribute before same-name namespaced one]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Own property correctness with namespaced attribute before same-name non-namespaced one]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Own property correctness with two namespaced attributes with the same name-with-prefix]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Own property names should only include all-lowercase qualified names for an HTML element in an HTML document]
|
[Own property names should only include all-lowercase qualified names for an HTML element in an HTML document]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[document.forms.html]
|
|
||||||
type: testharness
|
|
||||||
[document.forms iteration]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue