mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
script: Properly implement LegacyPlatformGetOwnProperty in WebIDL.
We were missing the "ignoreNamedProperties" bit, which my previous patch uncovers.
This commit is contained in:
parent
6edefb829c
commit
90fb284720
2 changed files with 24 additions and 17 deletions
|
@ -4817,15 +4817,14 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
"bool", args)
|
"bool", args)
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
|
|
||||||
|
# https://heycam.github.io/webidl/#LegacyPlatformObjectGetOwnProperty
|
||||||
def getBody(self):
|
def getBody(self):
|
||||||
indexedGetter = self.descriptor.operations['IndexedGetter']
|
indexedGetter = self.descriptor.operations['IndexedGetter']
|
||||||
indexedSetter = self.descriptor.operations['IndexedSetter']
|
|
||||||
|
|
||||||
get = ""
|
get = ""
|
||||||
if indexedGetter or indexedSetter:
|
if indexedGetter:
|
||||||
get = "let index = get_array_index_from_id(cx, id);\n"
|
get = "let index = get_array_index_from_id(cx, id);\n"
|
||||||
|
|
||||||
if indexedGetter:
|
|
||||||
attrs = "JSPROP_ENUMERATE"
|
attrs = "JSPROP_ENUMERATE"
|
||||||
if self.descriptor.operations['IndexedSetter'] is None:
|
if self.descriptor.operations['IndexedSetter'] is None:
|
||||||
attrs += " | JSPROP_READONLY"
|
attrs += " | JSPROP_READONLY"
|
||||||
|
@ -4864,11 +4863,16 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
'successCode': fillDescriptor,
|
'successCode': fillDescriptor,
|
||||||
'pre': 'rooted!(in(cx) let mut result_root = UndefinedValue());'
|
'pre': 'rooted!(in(cx) let mut result_root = UndefinedValue());'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# See the similar-looking in CGDOMJSProxyHandler_get for the spec quote.
|
||||||
|
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
|
||||||
|
if indexedGetter:
|
||||||
|
condition = "index.is_none() && (%s)" % condition
|
||||||
# Once we start supporting OverrideBuiltins we need to make
|
# Once we start supporting OverrideBuiltins we need to make
|
||||||
# ResolveOwnProperty or EnumerateOwnProperties filter out named
|
# ResolveOwnProperty or EnumerateOwnProperties filter out named
|
||||||
# properties that shadow prototype properties.
|
# properties that shadow prototype properties.
|
||||||
namedGet = """
|
namedGet = """
|
||||||
if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {
|
if %s {
|
||||||
let mut has_on_proto = false;
|
let mut has_on_proto = false;
|
||||||
if !has_property_on_prototype(cx, proxy, id, &mut has_on_proto) {
|
if !has_property_on_prototype(cx, proxy, id, &mut has_on_proto) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -4877,7 +4881,7 @@ if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {
|
||||||
%s
|
%s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""" % CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues), 8).define()
|
""" % (condition, CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues), 8).define())
|
||||||
else:
|
else:
|
||||||
namedGet = ""
|
namedGet = ""
|
||||||
|
|
||||||
|
@ -5093,9 +5097,12 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
||||||
indexed = ""
|
indexed = ""
|
||||||
|
|
||||||
namedGetter = self.descriptor.operations['NamedGetter']
|
namedGetter = self.descriptor.operations['NamedGetter']
|
||||||
|
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
|
||||||
|
if indexedGetter:
|
||||||
|
condition = "index.is_none() && (%s)" % condition
|
||||||
if namedGetter:
|
if namedGetter:
|
||||||
named = """\
|
named = """\
|
||||||
if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {
|
if %s {
|
||||||
let mut has_on_proto = false;
|
let mut has_on_proto = false;
|
||||||
if !has_property_on_prototype(cx, proxy, id, &mut has_on_proto) {
|
if !has_property_on_prototype(cx, proxy, id, &mut has_on_proto) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -5107,7 +5114,7 @@ if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
""" % CGIndenter(CGProxyNamedGetter(self.descriptor), 8).define()
|
""" % (condition, CGIndenter(CGProxyNamedGetter(self.descriptor), 8).define())
|
||||||
else:
|
else:
|
||||||
named = ""
|
named = ""
|
||||||
|
|
||||||
|
@ -5136,6 +5143,7 @@ class CGDOMJSProxyHandler_get(CGAbstractExternMethod):
|
||||||
CGAbstractExternMethod.__init__(self, descriptor, "get", "bool", args)
|
CGAbstractExternMethod.__init__(self, descriptor, "get", "bool", args)
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
|
|
||||||
|
# https://heycam.github.io/webidl/#LegacyPlatformObjectGetOwnProperty
|
||||||
def getBody(self):
|
def getBody(self):
|
||||||
getFromExpando = """\
|
getFromExpando = """\
|
||||||
rooted!(in(cx) let mut expando = ptr::null_mut());
|
rooted!(in(cx) let mut expando = ptr::null_mut());
|
||||||
|
@ -5175,9 +5183,16 @@ if !expando.is_null() {
|
||||||
|
|
||||||
namedGetter = self.descriptor.operations['NamedGetter']
|
namedGetter = self.descriptor.operations['NamedGetter']
|
||||||
if namedGetter:
|
if namedGetter:
|
||||||
getNamed = ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n" +
|
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
|
||||||
|
# From step 1:
|
||||||
|
# If O supports indexed properties and P is an array index, then:
|
||||||
|
#
|
||||||
|
# 3. Set ignoreNamedProps to true.
|
||||||
|
if indexedGetter:
|
||||||
|
condition = "index.is_none() && (%s)" % condition
|
||||||
|
getNamed = ("if %s {\n" +
|
||||||
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() +
|
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() +
|
||||||
"}\n")
|
"}\n") % condition
|
||||||
else:
|
else:
|
||||||
getNamed = ""
|
getNamed = ""
|
||||||
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
[storage_indexing.html]
|
|
||||||
type: testharness
|
|
||||||
[Getting existing number-valued properties on localStorage]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Getting existing number-valued properties on sessionStorage]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue