mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Update WebIDL.py (#32495)
* Update WebIDL.py * Update WebIDL.py * Add builtin-array.patch * Fix CodegenRust.py and Configuration.py * Fix missing downcasts * mach fmt * Update check and comment to explain why we need this check * Update Global of DissimilarOriginWindow.webidl
This commit is contained in:
parent
19067366df
commit
8eed3b442b
77 changed files with 1658 additions and 793 deletions
132
third_party/WebIDL/tests/test_union_callback_dict.py
vendored
Normal file
132
third_party/WebIDL/tests/test_union_callback_dict.py
vendored
Normal file
|
@ -0,0 +1,132 @@
|
|||
import WebIDL
|
||||
|
||||
|
||||
def WebIDLTest(parser, harness):
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse(
|
||||
"""
|
||||
dictionary TestDict {
|
||||
DOMString member;
|
||||
};
|
||||
[LegacyTreatNonObjectAsNull] callback TestCallback = undefined ();
|
||||
typedef (TestCallback or TestDict) TestUnionCallbackDict;
|
||||
"""
|
||||
)
|
||||
results = parser.finish()
|
||||
except WebIDL.WebIDLError:
|
||||
threw = True
|
||||
harness.ok(
|
||||
threw,
|
||||
"Should not allow Dict/Callback union where callback is [LegacyTreatNonObjectAsNull]",
|
||||
)
|
||||
|
||||
parser = parser.reset()
|
||||
|
||||
threw = False
|
||||
try:
|
||||
parser.parse(
|
||||
"""
|
||||
dictionary TestDict {
|
||||
DOMString member;
|
||||
};
|
||||
[LegacyTreatNonObjectAsNull] callback TestCallback = undefined ();
|
||||
typedef (TestDict or TestCallback) TestUnionCallbackDict;
|
||||
"""
|
||||
)
|
||||
results = parser.finish()
|
||||
except WebIDL.WebIDLError:
|
||||
threw = True
|
||||
harness.ok(
|
||||
threw,
|
||||
"Should not allow Dict/Callback union where callback is [LegacyTreatNonObjectAsNull]",
|
||||
)
|
||||
|
||||
parser = parser.reset()
|
||||
|
||||
parser.parse(
|
||||
"""
|
||||
dictionary TestDict {
|
||||
DOMString member;
|
||||
};
|
||||
callback TestCallback = undefined ();
|
||||
typedef (TestCallback or TestDict) TestUnionCallbackDict;
|
||||
"""
|
||||
)
|
||||
results = parser.finish()
|
||||
|
||||
harness.ok(True, "TestUnionCallbackDict interface parsed without error")
|
||||
harness.check(len(results), 3, "Document should have 3 types")
|
||||
|
||||
myDict = results[0]
|
||||
harness.ok(isinstance(myDict, WebIDL.IDLDictionary), "Expect an IDLDictionary")
|
||||
|
||||
myCallback = results[1]
|
||||
harness.ok(isinstance(myCallback, WebIDL.IDLCallback), "Expect an IDLCallback")
|
||||
|
||||
myUnion = results[2]
|
||||
harness.ok(isinstance(myUnion, WebIDL.IDLTypedef), "Expect a IDLTypedef")
|
||||
harness.ok(
|
||||
isinstance(myUnion.innerType, WebIDL.IDLUnionType), "Expect a IDLUnionType"
|
||||
)
|
||||
harness.ok(
|
||||
isinstance(myUnion.innerType.memberTypes[0], WebIDL.IDLCallbackType),
|
||||
"Expect a IDLCallbackType",
|
||||
)
|
||||
harness.ok(
|
||||
isinstance(myUnion.innerType.memberTypes[1], WebIDL.IDLWrapperType),
|
||||
"Expect a IDLDictionary",
|
||||
)
|
||||
harness.ok(
|
||||
(myUnion.innerType.memberTypes[0].callback == myCallback),
|
||||
"Expect left Union member to be MyCallback",
|
||||
)
|
||||
harness.ok(
|
||||
(myUnion.innerType.memberTypes[1].inner == myDict),
|
||||
"Expect right Union member to be MyDict",
|
||||
)
|
||||
|
||||
parser = parser.reset()
|
||||
|
||||
parser.parse(
|
||||
"""
|
||||
dictionary TestDict {
|
||||
DOMString member;
|
||||
};
|
||||
callback TestCallback = undefined ();
|
||||
typedef (TestDict or TestCallback) TestUnionCallbackDict;
|
||||
"""
|
||||
)
|
||||
results = parser.finish()
|
||||
|
||||
harness.ok(True, "TestUnionCallbackDict interface parsed without error")
|
||||
harness.check(len(results), 3, "Document should have 3 types")
|
||||
|
||||
myDict = results[0]
|
||||
harness.ok(isinstance(myDict, WebIDL.IDLDictionary), "Expect an IDLDictionary")
|
||||
|
||||
myCallback = results[1]
|
||||
harness.ok(isinstance(myCallback, WebIDL.IDLCallback), "Expect an IDLCallback")
|
||||
|
||||
myUnion = results[2]
|
||||
harness.ok(isinstance(myUnion, WebIDL.IDLTypedef), "Expect a IDLTypedef")
|
||||
harness.ok(
|
||||
isinstance(myUnion.innerType, WebIDL.IDLUnionType), "Expect a IDLUnionType"
|
||||
)
|
||||
harness.ok(
|
||||
isinstance(myUnion.innerType.memberTypes[0], WebIDL.IDLWrapperType),
|
||||
"Expect a IDLDictionary",
|
||||
)
|
||||
harness.ok(
|
||||
isinstance(myUnion.innerType.memberTypes[1], WebIDL.IDLCallbackType),
|
||||
"Expect a IDLCallbackType",
|
||||
)
|
||||
harness.ok(
|
||||
(myUnion.innerType.memberTypes[0].inner == myDict),
|
||||
"Expect right Union member to be MyDict",
|
||||
)
|
||||
harness.ok(
|
||||
(myUnion.innerType.memberTypes[1].callback == myCallback),
|
||||
"Expect left Union member to be MyCallback",
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue