Mark @@iterator as nonenumerable

This commit is contained in:
Kagami Sascha Rosylight 2019-10-17 20:35:21 +09:00
parent c5d6bb604d
commit 1c717bc086
5 changed files with 15 additions and 48 deletions

View file

@ -1633,6 +1633,7 @@ class MethodDefiner(PropertyDefiner):
self.regular = [{"name": m.identifier.name, self.regular = [{"name": m.identifier.name,
"methodInfo": not m.isStatic(), "methodInfo": not m.isStatic(),
"length": methodLength(m), "length": methodLength(m),
"flags": "JSPROP_ENUMERATE",
"condition": PropertyDefiner.getControllingCondition(m, descriptor)} "condition": PropertyDefiner.getControllingCondition(m, descriptor)}
for m in methods] for m in methods]
@ -1642,6 +1643,7 @@ class MethodDefiner(PropertyDefiner):
"methodInfo": False, "methodInfo": False,
"selfHostedName": "ArrayValues", "selfHostedName": "ArrayValues",
"length": 0, "length": 0,
"flags": "0", # Not enumerable, per spec.
"condition": "Condition::Satisfied"}) "condition": "Condition::Satisfied"})
# Generate the keys/values/entries aliases for value iterables. # Generate the keys/values/entries aliases for value iterables.
@ -1656,6 +1658,7 @@ class MethodDefiner(PropertyDefiner):
"methodInfo": False, "methodInfo": False,
"selfHostedName": "ArrayKeys", "selfHostedName": "ArrayKeys",
"length": 0, "length": 0,
"flags": "JSPROP_ENUMERATE",
"condition": PropertyDefiner.getControllingCondition(m, "condition": PropertyDefiner.getControllingCondition(m,
descriptor) descriptor)
}) })
@ -1664,6 +1667,7 @@ class MethodDefiner(PropertyDefiner):
"methodInfo": False, "methodInfo": False,
"selfHostedName": "ArrayValues", "selfHostedName": "ArrayValues",
"length": 0, "length": 0,
"flags": "JSPROP_ENUMERATE",
"condition": PropertyDefiner.getControllingCondition(m, "condition": PropertyDefiner.getControllingCondition(m,
descriptor) descriptor)
}) })
@ -1672,6 +1676,7 @@ class MethodDefiner(PropertyDefiner):
"methodInfo": False, "methodInfo": False,
"selfHostedName": "ArrayEntries", "selfHostedName": "ArrayEntries",
"length": 0, "length": 0,
"flags": "JSPROP_ENUMERATE",
"condition": PropertyDefiner.getControllingCondition(m, "condition": PropertyDefiner.getControllingCondition(m,
descriptor) descriptor)
}) })
@ -1680,6 +1685,7 @@ class MethodDefiner(PropertyDefiner):
"methodInfo": False, "methodInfo": False,
"selfHostedName": "ArrayForEach", "selfHostedName": "ArrayForEach",
"length": 1, "length": 1,
"flags": "JSPROP_ENUMERATE",
"condition": PropertyDefiner.getControllingCondition(m, "condition": PropertyDefiner.getControllingCondition(m,
descriptor) descriptor)
}) })
@ -1692,6 +1698,7 @@ class MethodDefiner(PropertyDefiner):
"name": "toString", "name": "toString",
"nativeName": stringifier.identifier.name, "nativeName": stringifier.identifier.name,
"length": 0, "length": 0,
"flags": "JSPROP_ENUMERATE",
"condition": PropertyDefiner.getControllingCondition(stringifier, descriptor) "condition": PropertyDefiner.getControllingCondition(stringifier, descriptor)
}) })
self.unforgeable = unforgeable self.unforgeable = unforgeable
@ -1703,13 +1710,10 @@ class MethodDefiner(PropertyDefiner):
def condition(m, d): def condition(m, d):
return m["condition"] return m["condition"]
flags = "JSPROP_ENUMERATE" def specData(m):
flags = m["flags"]
if self.unforgeable: if self.unforgeable:
flags += " | JSPROP_PERMANENT | JSPROP_READONLY" flags += " | JSPROP_PERMANENT | JSPROP_READONLY"
def specData(m):
# TODO: Use something like JS_FNSPEC
# https://github.com/servo/servo/issues/6391
if "selfHostedName" in m: if "selfHostedName" in m:
selfHostedName = '%s as *const u8 as *const libc::c_char' % str_to_const_array(m["selfHostedName"]) selfHostedName = '%s as *const u8 as *const libc::c_char' % str_to_const_array(m["selfHostedName"])
assert not m.get("methodInfo", True) assert not m.get("methodInfo", True)
@ -3071,12 +3075,14 @@ assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null());
symbolJSID=symbolJSID)) symbolJSID=symbolJSID))
defineFn = "JS_DefinePropertyById2" defineFn = "JS_DefinePropertyById2"
prop = "iteratorId.handle()" prop = "iteratorId.handle()"
enumFlags = "0" # Not enumerable, per spec.
elif alias.startswith("@@"): elif alias.startswith("@@"):
raise TypeError("Can't handle any well-known Symbol other than @@iterator") raise TypeError("Can't handle any well-known Symbol other than @@iterator")
else: else:
getSymbolJSID = None getSymbolJSID = None
defineFn = "JS_DefineProperty" defineFn = "JS_DefineProperty"
prop = '"%s"' % alias prop = '"%s"' % alias
enumFlags = "JSPROP_ENUMERATE"
return CGList([ return CGList([
getSymbolJSID, getSymbolJSID,
# XXX If we ever create non-enumerable properties that can # XXX If we ever create non-enumerable properties that can
@ -3085,10 +3091,11 @@ assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null());
CGGeneric(fill( CGGeneric(fill(
""" """
assert!(${defineFn}(*cx, prototype.handle(), ${prop}, aliasedVal.handle(), assert!(${defineFn}(*cx, prototype.handle(), ${prop}, aliasedVal.handle(),
JSPROP_ENUMERATE as u32)); ${enumFlags} as u32));
""", """,
defineFn=defineFn, defineFn=defineFn,
prop=prop)) prop=prop,
enumFlags=enumFlags))
], "\n") ], "\n")
def defineAliasesFor(m): def defineAliasesFor(m):

View file

@ -229,9 +229,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
[DOMTokenList interface: iterable<DOMString>]
expected: FAIL
[Document interface: existence and properties of interface prototype object's @@unscopables property] [Document interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL expected: FAIL
@ -487,9 +484,6 @@
[AbstractRange interface: attribute endOffset] [AbstractRange interface: attribute endOffset]
expected: FAIL expected: FAIL
[NodeList interface: iterable<Node>]
expected: FAIL
[CharacterData interface: operation before([object Object\],[object Object\])] [CharacterData interface: operation before([object Object\],[object Object\])]
expected: FAIL expected: FAIL

View file

@ -64,9 +64,6 @@
[Request interface: new Request('about:blank') must inherit property "isReloadNavigation" with the proper type] [Request interface: new Request('about:blank') must inherit property "isReloadNavigation" with the proper type]
expected: FAIL expected: FAIL
[Headers interface: iterable<ByteString, ByteString>]
expected: FAIL
[Request interface: new Request('about:blank') must inherit property "signal" with the proper type] [Request interface: new Request('about:blank') must inherit property "signal" with the proper type]
expected: FAIL expected: FAIL
@ -147,9 +144,6 @@
[Request interface: new Request('about:blank') must inherit property "isReloadNavigation" with the proper type] [Request interface: new Request('about:blank') must inherit property "isReloadNavigation" with the proper type]
expected: FAIL expected: FAIL
[Headers interface: iterable<ByteString, ByteString>]
expected: FAIL
[Request interface: new Request('about:blank') must inherit property "signal" with the proper type] [Request interface: new Request('about:blank') must inherit property "signal" with the proper type]
expected: FAIL expected: FAIL

View file

@ -8,9 +8,6 @@
[URL interface: legacy window alias] [URL interface: legacy window alias]
expected: FAIL expected: FAIL
[URLSearchParams interface: iterable<USVString, USVString>]
expected: FAIL
[idlharness.any.worker.html] [idlharness.any.worker.html]
[idlharness] [idlharness]
@ -19,6 +16,3 @@
[Testing Symbol.iterator property of iterable interface URLSearchParams] [Testing Symbol.iterator property of iterable interface URLSearchParams]
expected: FAIL expected: FAIL
[URLSearchParams interface: iterable<USVString, USVString>]
expected: FAIL

View file

@ -1,26 +1,4 @@
[idlharness.any.html]
[idlharness]
expected: FAIL
[Testing Symbol.iterator property of iterable interface FormData]
expected: FAIL
[FormData interface: iterable<USVString, FormDataEntryValue>]
expected: FAIL
[idlharness.any.sharedworker.html] [idlharness.any.sharedworker.html]
[idlharness] [idlharness]
expected: FAIL expected: FAIL
[idlharness.any.worker.html]
[idlharness]
expected: FAIL
[Testing Symbol.iterator property of iterable interface FormData]
expected: FAIL
[FormData interface: iterable<USVString, FormDataEntryValue>]
expected: FAIL