diff options
author | Ngo Iok Ui (Wu Yu Wei) <yuweiwu@pm.me> | 2024-06-15 13:22:42 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-15 04:22:42 +0000 |
commit | 8eed3b442b214f678b80dbcc7dca07eeaa1e26ff (patch) | |
tree | f8a232e86616e8e5fd234e7bbb32bed4ff7077f2 /third_party/WebIDL/tests | |
parent | 19067366df28c9131dcbc436bc96a27e64e0a194 (diff) | |
download | servo-8eed3b442b214f678b80dbcc7dca07eeaa1e26ff.tar.gz servo-8eed3b442b214f678b80dbcc7dca07eeaa1e26ff.zip |
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
Diffstat (limited to 'third_party/WebIDL/tests')
70 files changed, 1090 insertions, 624 deletions
diff --git a/third_party/WebIDL/tests/test_any_null.py b/third_party/WebIDL/tests/test_any_null.py index f9afdacb02f..e76935d0056 100644 --- a/third_party/WebIDL/tests/test_any_null.py +++ b/third_party/WebIDL/tests/test_any_null.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -9,8 +12,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_argument_identifier_conflicts.py b/third_party/WebIDL/tests/test_argument_identifier_conflicts.py index 3f50cb05158..b6d60345160 100644 --- a/third_party/WebIDL/tests/test_argument_identifier_conflicts.py +++ b/third_party/WebIDL/tests/test_argument_identifier_conflicts.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -9,8 +12,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_argument_novoid.py b/third_party/WebIDL/tests/test_argument_novoid.py new file mode 100644 index 00000000000..a72865e35b4 --- /dev/null +++ b/third_party/WebIDL/tests/test_argument_novoid.py @@ -0,0 +1,19 @@ +import WebIDL + + +def WebIDLTest(parser, harness): + threw = False + try: + parser.parse( + """ + interface VoidArgument1 { + void foo(void arg2); + }; + """ + ) + + parser.finish() + except WebIDL.WebIDLError: + threw = True + + harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_attr.py b/third_party/WebIDL/tests/test_attr.py index e19689a81a9..b8dbccf41e7 100644 --- a/third_party/WebIDL/tests/test_attr.py +++ b/third_party/WebIDL/tests/test_attr.py @@ -147,7 +147,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow [SetterThrows] on readonly attributes") @@ -162,7 +162,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should spell [Throws] correctly") @@ -177,7 +177,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "Should not allow [SameObject] on attributes not of interface type" @@ -194,6 +194,6 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(not threw, "Should allow [SameObject] on attributes of interface type") diff --git a/third_party/WebIDL/tests/test_attr_sequence_type.py b/third_party/WebIDL/tests/test_attr_sequence_type.py index f3249de900a..7a23265daf6 100644 --- a/third_party/WebIDL/tests/test_attr_sequence_type.py +++ b/third_party/WebIDL/tests/test_attr_sequence_type.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -9,8 +12,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Attribute type must not be a sequence type") @@ -27,8 +30,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Attribute type must not be a union with a sequence member type") @@ -45,8 +48,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -59,15 +62,15 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse( - """ - interface AttrUnionWithUnionWithSequenceType { - attribute ((sequence<object> or DOMString) or AttrUnionWithUnionWithSequenceType) foo; - }; - """ + "\n" + " interface AttrUnionWithUnionWithSequenceType {\n" + " attribute ((sequence<object> or DOMString) or " + "AttrUnionWithUnionWithSequenceType) foo;\n" + " };\n" ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( diff --git a/third_party/WebIDL/tests/test_attributes_on_types.py b/third_party/WebIDL/tests/test_attributes_on_types.py index 97a7f47859a..d47fc87110e 100644 --- a/third_party/WebIDL/tests/test_attributes_on_types.py +++ b/third_party/WebIDL/tests/test_attributes_on_types.py @@ -1,4 +1,3 @@ -# Import the WebIDL module, so we can do isinstance checks and whatnot import WebIDL @@ -46,7 +45,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(not threw, "Should not have thrown on parsing normal") @@ -182,7 +181,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(not threw, "Should not have thrown on parsing normal") @@ -341,22 +340,22 @@ def WebIDLTest(parser, harness): ), ] - for (name, template) in TEMPLATES: + for name, template in TEMPLATES: parser = parser.reset() threw = False try: parser.parse(template % ("", "long")) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(not threw, "Template for %s parses without attributes" % name) - for (attribute, type) in ATTRIBUTES: + for attribute, type in ATTRIBUTES: parser = parser.reset() threw = False try: parser.parse(template % (attribute, type)) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow %s on %s" % (attribute, name)) @@ -369,7 +368,7 @@ def WebIDLTest(parser, harness): """ ) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow mixing [Clamp] and [EnforceRange]") @@ -383,7 +382,7 @@ def WebIDLTest(parser, harness): """ ) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow mixing [Clamp] and [EnforceRange]") @@ -398,7 +397,7 @@ def WebIDLTest(parser, harness): """ ) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow mixing [Clamp] and [EnforceRange] via typedefs") @@ -413,7 +412,7 @@ def WebIDLTest(parser, harness): """ ) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow mixing [Clamp] and [EnforceRange] via typedefs") @@ -437,7 +436,7 @@ def WebIDLTest(parser, harness): % type ) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow [Clamp] on %s" % type) @@ -452,7 +451,7 @@ def WebIDLTest(parser, harness): % type ) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow [EnforceRange] on %s" % type) @@ -466,7 +465,7 @@ def WebIDLTest(parser, harness): """ ) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow [LegacyNullToEmptyString] on long") @@ -480,7 +479,7 @@ def WebIDLTest(parser, harness): """ ) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow [LegacyNullToEmptyString] on JSString") @@ -494,7 +493,7 @@ def WebIDLTest(parser, harness): """ ) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -510,7 +509,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "[AllowShared] only allowed on buffer source types") @@ -523,7 +522,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "[AllowShared] must take no arguments") @@ -539,7 +538,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(not threw, "Should allow type attributes on unresolved types") harness.check( @@ -560,11 +559,12 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(not threw, "Should allow type attributes on typedefs") harness.check( results[0].members[0].signatures()[0][1][0].type.hasClamp(), True, - "Unresolved types that resolve to typedefs with attributes should correctly resolve with attributes", + "Unresolved types that resolve to typedefs with attributes should correctly resolve with " + "attributes", ) diff --git a/third_party/WebIDL/tests/test_builtin_filename.py b/third_party/WebIDL/tests/test_builtin_filename.py index 6c913bba822..97e8cb061f5 100644 --- a/third_party/WebIDL/tests/test_builtin_filename.py +++ b/third_party/WebIDL/tests/test_builtin_filename.py @@ -1,6 +1,3 @@ -import WebIDL - - def WebIDLTest(parser, harness): parser.parse( """ @@ -11,4 +8,4 @@ def WebIDLTest(parser, harness): ) attr = parser.finish()[0].members[0] - harness.check(attr.type.filename(), "<builtin>", "Filename on builtin type") + harness.check(attr.type.filename, "<builtin>", "Filename on builtin type") diff --git a/third_party/WebIDL/tests/test_bytestring.py b/third_party/WebIDL/tests/test_bytestring.py index a6f9f6ab9cb..248d2716f36 100644 --- a/third_party/WebIDL/tests/test_bytestring.py +++ b/third_party/WebIDL/tests/test_bytestring.py @@ -79,7 +79,7 @@ def WebIDLTest(parser, harness): }; """ ) - results2 = parser.finish() + parser.finish() except WebIDL.WebIDLError as e: harness.ok( False, @@ -96,7 +96,7 @@ def WebIDLTest(parser, harness): }; """ ) - results3 = parser.finish() + parser.finish() except WebIDL.WebIDLError as e: harness.ok( False, @@ -114,8 +114,8 @@ def WebIDLTest(parser, harness): }; """ ) - results4 = parser.finish() - except WebIDL.WebIDLError as e: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( diff --git a/third_party/WebIDL/tests/test_callback_constructor.py b/third_party/WebIDL/tests/test_callback_constructor.py index 832a92bb147..67ea8ff755a 100644 --- a/third_party/WebIDL/tests/test_callback_constructor.py +++ b/third_party/WebIDL/tests/test_callback_constructor.py @@ -59,7 +59,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -76,7 +76,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( diff --git a/third_party/WebIDL/tests/test_callback_interface.py b/third_party/WebIDL/tests/test_callback_interface.py index 0d657f48032..102e96401bf 100644 --- a/third_party/WebIDL/tests/test_callback_interface.py +++ b/third_party/WebIDL/tests/test_callback_interface.py @@ -28,8 +28,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow non-callback parent of callback interface") @@ -46,8 +46,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow callback parent of non-callback interface") @@ -97,7 +97,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - for (i, iface) in enumerate(results): + for i, iface in enumerate(results): harness.check( iface.isSingleOperationInterface(), i < 4, diff --git a/third_party/WebIDL/tests/test_cereactions.py b/third_party/WebIDL/tests/test_cereactions.py index c56c3dbde10..2aa4da40c82 100644 --- a/third_party/WebIDL/tests/test_cereactions.py +++ b/third_party/WebIDL/tests/test_cereactions.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -9,8 +12,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown for [CEReactions] with an argument") @@ -26,8 +29,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown for [CEReactions] with an argument") @@ -43,7 +46,7 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() + parser.finish() except Exception as e: harness.ok( False, @@ -63,7 +66,7 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() + parser.finish() except Exception as e: harness.ok( False, @@ -83,8 +86,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -102,8 +105,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown for [CEReactions] used on a interface") @@ -118,8 +121,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown for [CEReactions] used on a named getter") @@ -134,8 +137,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown for [CEReactions] used on a legacycaller") @@ -150,8 +153,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown for [CEReactions] used on a stringifier") diff --git a/third_party/WebIDL/tests/test_const.py b/third_party/WebIDL/tests/test_const.py index f2d4b79d467..da83db41ef5 100644 --- a/third_party/WebIDL/tests/test_const.py +++ b/third_party/WebIDL/tests/test_const.py @@ -64,7 +64,7 @@ def WebIDLTest(parser, harness): len(iface.members), len(expected), "Expect %s members" % len(expected) ) - for (const, (QName, name, type, value)) in zip(iface.members, expected): + for const, (QName, name, type, value) in zip(iface.members, expected): harness.ok(isinstance(const, WebIDL.IDLConst), "Should be an IDLConst") harness.ok(const.isConst(), "Const is a const") harness.ok(not const.isAttr(), "Const is not an attr") @@ -91,6 +91,6 @@ def WebIDLTest(parser, harness): """ ) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Nullable types are not allowed for consts.") diff --git a/third_party/WebIDL/tests/test_constructor.py b/third_party/WebIDL/tests/test_constructor.py index de5d52f1412..1a08a828fd1 100644 --- a/third_party/WebIDL/tests/test_constructor.py +++ b/third_party/WebIDL/tests/test_constructor.py @@ -87,7 +87,7 @@ def WebIDLTest(parser, harness): ) sigpairs = zip(method.signatures(), signatures) - for (gotSignature, expectedSignature) in sigpairs: + for gotSignature, expectedSignature in sigpairs: (gotRetType, gotArgs) = gotSignature (expectedRetType, expectedArgs) = expectedSignature @@ -264,7 +264,7 @@ def WebIDLTest(parser, harness): parser.parse( """ interface TestFuncConstructor { - [Func="Document::IsWebAnimationsEnabled"] constructor(); + [Func="IsNotUAWidget"] constructor(); }; """ ) @@ -277,17 +277,19 @@ def WebIDLTest(parser, harness): "::TestFuncConstructor::constructor", "constructor", [("TestFuncConstructor (Wrapper)", [])], - func=["Document::IsWebAnimationsEnabled"], + func=["IsNotUAWidget"], ) parser = parser.reset() parser.parse( - """ - interface TestPrefChromeOnlySCFuncConstructor { - [ChromeOnly, Pref="dom.webidl.test1", SecureContext, Func="Document::IsWebAnimationsEnabled"] - constructor(); - }; - """ + ( + "\n" + " interface TestPrefChromeOnlySCFuncConstructor {\n" + ' [ChromeOnly, Pref="dom.webidl.test1", SecureContext, ' + 'Func="IsNotUAWidget"]\n' + " constructor();\n" + " };\n" + ) ) results = parser.finish() harness.check(len(results), 1, "Should be one production") @@ -298,7 +300,7 @@ def WebIDLTest(parser, harness): "::TestPrefChromeOnlySCFuncConstructor::constructor", "constructor", [("TestPrefChromeOnlySCFuncConstructor (Wrapper)", [])], - func=["Document::IsWebAnimationsEnabled"], + func=["IsNotUAWidget"], pref=["dom.webidl.test1"], chromeOnly=True, secureContext=True, @@ -336,7 +338,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Can't have both a constructor and a ChromeOnly constructor") @@ -353,7 +355,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "HTMLConstructor should take no argument") @@ -370,7 +372,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "HTMLConstructor can't be used on a callback interface") @@ -388,7 +390,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Can't have both a constructor and a HTMLConstructor") @@ -406,7 +408,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Can't have both a throwing constructor and a HTMLConstructor") @@ -423,7 +425,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Can't have both a HTMLConstructor and a constructor operation") @@ -441,7 +443,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -463,7 +465,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Can't have both a ChromeOnly constructor and a HTMLConstructor") @@ -481,7 +483,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -502,7 +504,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -523,7 +525,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -544,7 +546,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -567,7 +569,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Can't have a constructor operation on a partial interface") @@ -588,7 +590,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Can't have a constructor operation on a mixin") diff --git a/third_party/WebIDL/tests/test_constructor_global.py b/third_party/WebIDL/tests/test_constructor_global.py index 5f3663602e4..387698d9dd5 100644 --- a/third_party/WebIDL/tests/test_constructor_global.py +++ b/third_party/WebIDL/tests/test_constructor_global.py @@ -1,4 +1,4 @@ -import traceback +import WebIDL def WebIDLTest(parser, harness): @@ -6,15 +6,15 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=TestConstructorGlobal] + [Global=TestConstructorGlobal, Exposed=TestConstructorGlobal] interface TestConstructorGlobal { constructor(); }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -24,14 +24,14 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=TestLegacyFactoryFunctionGlobal, + [Global=TestLegacyFactoryFunctionGlobal, Exposed=TestLegacyFactoryFunctionGlobal, LegacyFactoryFunction=FooBar] interface TestLegacyFactoryFunctionGlobal { }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -41,14 +41,14 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [LegacyFactoryFunction=FooBar, Global, + [LegacyFactoryFunction=FooBar, Global=TestLegacyFactoryFunctionGlobal, Exposed=TestLegacyFactoryFunctionGlobal] interface TestLegacyFactoryFunctionGlobal { }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -58,15 +58,15 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=TestHTMLConstructorGlobal] + [Global=TestHTMLConstructorGlobal, Exposed=TestHTMLConstructorGlobal] interface TestHTMLConstructorGlobal { [HTMLConstructor] constructor(); }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_constructor_no_interface_object.py b/third_party/WebIDL/tests/test_constructor_no_interface_object.py index 9855352a9d4..b8f8589f280 100644 --- a/third_party/WebIDL/tests/test_constructor_no_interface_object.py +++ b/third_party/WebIDL/tests/test_constructor_no_interface_object.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -10,8 +13,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -40,8 +43,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_deduplicate.py b/third_party/WebIDL/tests/test_deduplicate.py index 6649f4ec05d..2308f6201e4 100644 --- a/third_party/WebIDL/tests/test_deduplicate.py +++ b/third_party/WebIDL/tests/test_deduplicate.py @@ -1,6 +1,3 @@ -import WebIDL - - def WebIDLTest(parser, harness): parser.parse( """ diff --git a/third_party/WebIDL/tests/test_dictionary.py b/third_party/WebIDL/tests/test_dictionary.py index e7d04f995a9..80c13a4238e 100644 --- a/third_party/WebIDL/tests/test_dictionary.py +++ b/third_party/WebIDL/tests/test_dictionary.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): parser.parse( """ @@ -67,8 +70,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow name duplication in a dictionary") @@ -87,8 +90,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -112,8 +115,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -132,8 +135,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow non-dictionary parents for dictionaries") @@ -148,8 +151,8 @@ def WebIDLTest(parser, harness): dictionary B : A {}; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow cycles in dictionary inheritance chains") @@ -164,8 +167,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -184,8 +187,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Trailing dictionary arg must be optional") @@ -202,8 +205,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Trailing dictionary arg must have a default value") @@ -220,8 +223,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Trailing union arg containing a dictionary must be optional") @@ -238,8 +241,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -258,8 +261,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Dictionary arg followed by optional arg must be optional") @@ -276,8 +279,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Dictionary arg followed by optional arg must have default value") @@ -294,8 +297,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -315,8 +318,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -336,8 +339,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -356,7 +359,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() harness.ok(True, "Dictionary arg followed by required arg can be required") parser = parser.reset() @@ -371,7 +374,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() except Exception as x: threw = x @@ -394,7 +397,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() except Exception as x: threw = x @@ -416,7 +419,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() except Exception as x: threw = x @@ -440,7 +443,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() except Exception as x: threw = x @@ -463,8 +466,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(not threw, "Nullable union should be allowed in a sequence argument") @@ -481,8 +484,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Dictionary must not be in a union with a nullable type") @@ -498,8 +501,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "A nullable type must not be in a union with a dictionary") @@ -513,7 +516,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() harness.ok(True, "Dictionary return value can be nullable") parser = parser.reset() @@ -526,7 +529,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() harness.ok(True, "Dictionary arg should actually parse") parser = parser.reset() @@ -539,7 +542,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() harness.ok(True, "Union arg containing a dictionary should actually parse") parser = parser.reset() @@ -552,7 +555,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() harness.ok( True, "Union arg containing a dictionary with string default should actually parse", @@ -568,8 +571,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Member type must not be its Dictionary.") @@ -596,8 +599,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -615,8 +618,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -635,8 +638,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -655,8 +658,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -675,8 +678,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -707,8 +710,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -731,8 +734,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Member type must not be a nullable dictionary") @@ -759,7 +762,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() harness.ok(True, "Parsing default values for unrestricted types succeeded.") parser = parser.reset() @@ -772,8 +775,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Only unrestricted values can be initialized to Infinity") @@ -788,8 +791,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Only unrestricted values can be initialized to -Infinity") @@ -804,8 +807,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Only unrestricted values can be initialized to NaN") @@ -820,8 +823,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Only unrestricted values can be initialized to Infinity") @@ -836,8 +839,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Only unrestricted values can be initialized to -Infinity") @@ -852,8 +855,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Only unrestricted values can be initialized to NaN") @@ -868,8 +871,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(not threw, "Should be able to use 'module' as a dictionary member name") diff --git a/third_party/WebIDL/tests/test_distinguishability.py b/third_party/WebIDL/tests/test_distinguishability.py index e96026c2a09..caf726c16b8 100644 --- a/third_party/WebIDL/tests/test_distinguishability.py +++ b/third_party/WebIDL/tests/test_distinguishability.py @@ -1,4 +1,4 @@ -import traceback +import WebIDL def firstArgType(method): @@ -143,8 +143,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -167,8 +167,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should throw when there is no distinguishing index") @@ -228,7 +228,9 @@ def WebIDLTest(parser, harness): and (a != "any" and a != "Promise<any>" and a != "Promise<any>?") ] - unions = ["(long or Callback)", "(long or Dict)"] + unionsWithCallback = ["(long or Callback)"] + unionsNoCallback = ["(long or Dict)"] + unions = unionsWithCallback + unionsNoCallback numerics = ["long", "short", "long?", "short?"] booleans = ["boolean", "boolean?"] undefineds = ["undefined", "undefined?"] @@ -246,7 +248,6 @@ def WebIDLTest(parser, harness): ] nonStrings = allBut(argTypes, strings) nonObjects = undefineds + primitives + strings - objects = allBut(argTypes, nonObjects) bufferSourceTypes = ["ArrayBuffer", "ArrayBufferView", "Uint8Array", "Uint16Array"] interfaces = [ "Interface", @@ -266,7 +267,7 @@ def WebIDLTest(parser, harness): "Date?", "any", "Promise<any>?", - ] + allBut(unions, ["(long or Callback)"]) + ] + unionsNoCallback sequences = ["sequence<long>", "sequence<short>"] nonUserObjects = nonObjects + interfaces + sequences otherObjects = allBut(argTypes, nonUserObjects + ["object"]) @@ -283,17 +284,14 @@ def WebIDLTest(parser, harness): "record<ByteString, long>", "record<UTF8String, long>", ] # JSString not supported in records - dictionaryLike = ( - [ - "Dict", - "Dict2", - "CallbackInterface", - "CallbackInterface?", - "CallbackInterface2", - ] - + records - + allBut(unions, ["(long or Callback)"]) - ) + dicts = ["Dict", "Dict2"] + callbacks = ["Callback", "Callback2"] + callbackInterfaces = [ + "CallbackInterface", + "CallbackInterface?", + "CallbackInterface2", + ] + dictionaryLike = dicts + callbackInterfaces + records + unionsNoCallback # Build a representation of the distinguishability table as a dict # of dicts, holding True values where needed, holes elsewhere. @@ -328,23 +326,60 @@ def WebIDLTest(parser, harness): setDistinguishable( "UnrelatedInterface", allBut(argTypes, ["object", "UnrelatedInterface"]) ) - setDistinguishable("CallbackInterface", allBut(nonUserObjects, undefineds)) setDistinguishable( - "CallbackInterface?", allBut(nonUserObjects, nullables + undefineds) + "CallbackInterface", + allBut(nonUserObjects + callbacks + unionsWithCallback, undefineds), + ) + setDistinguishable( + "CallbackInterface?", + allBut(nonUserObjects + callbacks + unionsWithCallback, nullables + undefineds), + ) + setDistinguishable( + "CallbackInterface2", + allBut(nonUserObjects + callbacks + unionsWithCallback, undefineds), ) - setDistinguishable("CallbackInterface2", allBut(nonUserObjects, undefineds)) setDistinguishable("object", nonObjects) - setDistinguishable("Callback", nonUserObjects) - setDistinguishable("Callback2", nonUserObjects) - setDistinguishable("Dict", allBut(nonUserObjects, nullables + undefineds)) - setDistinguishable("Dict2", allBut(nonUserObjects, nullables + undefineds)) - setDistinguishable("sequence<long>", allBut(argTypes, sequences + ["object"])) - setDistinguishable("sequence<short>", allBut(argTypes, sequences + ["object"])) - setDistinguishable("record<DOMString, object>", allBut(nonUserObjects, undefineds)) - setDistinguishable("record<USVString, Dict>", allBut(nonUserObjects, undefineds)) + setDistinguishable( + "Callback", + nonUserObjects + unionsNoCallback + dicts + records + callbackInterfaces, + ) + setDistinguishable( + "Callback2", + nonUserObjects + unionsNoCallback + dicts + records + callbackInterfaces, + ) + setDistinguishable( + "Dict", + allBut(nonUserObjects + unionsWithCallback + callbacks, nullables + undefineds), + ) + setDistinguishable( + "Dict2", + allBut(nonUserObjects + unionsWithCallback + callbacks, nullables + undefineds), + ) + setDistinguishable( + "sequence<long>", + allBut(argTypes, sequences + ["object"]), + ) + setDistinguishable( + "sequence<short>", + allBut(argTypes, sequences + ["object"]), + ) + setDistinguishable( + "record<DOMString, object>", + allBut(nonUserObjects + unionsWithCallback + callbacks, undefineds), + ) + setDistinguishable( + "record<USVString, Dict>", + allBut(nonUserObjects + unionsWithCallback + callbacks, undefineds), + ) # JSString not supported in records - setDistinguishable("record<ByteString, long>", allBut(nonUserObjects, undefineds)) - setDistinguishable("record<UTF8String, long>", allBut(nonUserObjects, undefineds)) + setDistinguishable( + "record<ByteString, long>", + allBut(nonUserObjects + unionsWithCallback + callbacks, undefineds), + ) + setDistinguishable( + "record<UTF8String, long>", + allBut(nonUserObjects + unionsWithCallback + callbacks, undefineds), + ) setDistinguishable("any", []) setDistinguishable("Promise<any>", []) setDistinguishable("Promise<any>?", []) @@ -359,9 +394,13 @@ def WebIDLTest(parser, harness): setDistinguishable( "Uint16Array", allBut(argTypes, ["ArrayBufferView", "Uint16Array", "object"]) ) - setDistinguishable("(long or Callback)", allBut(nonUserObjects, numerics)) setDistinguishable( - "(long or Dict)", allBut(nonUserObjects, numerics + nullables + undefineds) + "(long or Callback)", + allBut(nonUserObjects + dicts + records + callbackInterfaces, numerics), + ) + setDistinguishable( + "(long or Dict)", + allBut(nonUserObjects + callbacks, numerics + nullables + undefineds), ) def areDistinguishable(type1, type2): @@ -378,6 +417,7 @@ def WebIDLTest(parser, harness): callback interface CallbackInterface2 {}; callback Callback = any(); callback Callback2 = long(short arg); + [LegacyTreatNonObjectAsNull] callback LegacyCallback1 = any(); // Give our dictionaries required members so we don't need to // mess with optional and default values. dictionary Dict { required long member; }; @@ -401,8 +441,8 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(idl) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True if areDistinguishable(type1, type2): diff --git a/third_party/WebIDL/tests/test_double_null.py b/third_party/WebIDL/tests/test_double_null.py index a8876a7fd2d..28166020c10 100644 --- a/third_party/WebIDL/tests/test_double_null.py +++ b/third_party/WebIDL/tests/test_double_null.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -9,8 +12,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_duplicate_qualifiers.py b/third_party/WebIDL/tests/test_duplicate_qualifiers.py index 89a4e1acf0b..bb02f96acfb 100644 --- a/third_party/WebIDL/tests/test_duplicate_qualifiers.py +++ b/third_party/WebIDL/tests/test_duplicate_qualifiers.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -9,8 +12,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -25,8 +28,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -41,8 +44,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -57,8 +60,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_empty_enum.py b/third_party/WebIDL/tests/test_empty_enum.py index 09333a659cd..ad002caa4ee 100644 --- a/third_party/WebIDL/tests/test_empty_enum.py +++ b/third_party/WebIDL/tests/test_empty_enum.py @@ -11,7 +11,7 @@ def WebIDLTest(parser, harness): ) harness.ok(False, "Should have thrown!") - except: + except WebIDL.WebIDLError: harness.ok(True, "Parsing TestEmptyEnum enum should fail") - results = parser.finish() + parser.finish() diff --git a/third_party/WebIDL/tests/test_empty_sequence_default_value.py b/third_party/WebIDL/tests/test_empty_sequence_default_value.py index 21837743523..4771a6b1e54 100644 --- a/third_party/WebIDL/tests/test_empty_sequence_default_value.py +++ b/third_party/WebIDL/tests/test_empty_sequence_default_value.py @@ -13,7 +13,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Constant cannot have [] as a default value") diff --git a/third_party/WebIDL/tests/test_enum.py b/third_party/WebIDL/tests/test_enum.py index 56c6b3f64aa..4eb26f7eaf9 100644 --- a/third_party/WebIDL/tests/test_enum.py +++ b/third_party/WebIDL/tests/test_enum.py @@ -86,8 +86,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow a bogus default value for an enum") diff --git a/third_party/WebIDL/tests/test_enum_duplicate_values.py b/third_party/WebIDL/tests/test_enum_duplicate_values.py index 8969281e1c7..f40a178442b 100644 --- a/third_party/WebIDL/tests/test_enum_duplicate_values.py +++ b/third_party/WebIDL/tests/test_enum_duplicate_values.py @@ -12,5 +12,5 @@ def WebIDLTest(parser, harness): """ ) harness.ok(False, "Should have thrown!") - except: + except WebIDL.WebIDLError: harness.ok(True, "Enum TestEnumDuplicateValue should throw") diff --git a/third_party/WebIDL/tests/test_error_colno.py b/third_party/WebIDL/tests/test_error_colno.py index 1c9bb065580..b08ba7cc172 100644 --- a/third_party/WebIDL/tests/test_error_colno.py +++ b/third_party/WebIDL/tests/test_error_colno.py @@ -8,7 +8,7 @@ def WebIDLTest(parser, harness): input = "interface ?" try: parser.parse(input) - results = parser.finish() + parser.finish() except WebIDL.WebIDLError as e: threw = True lines = str(e).split("\n") diff --git a/third_party/WebIDL/tests/test_error_lineno.py b/third_party/WebIDL/tests/test_error_lineno.py index 0d10e006787..30629be30c0 100644 --- a/third_party/WebIDL/tests/test_error_lineno.py +++ b/third_party/WebIDL/tests/test_error_lineno.py @@ -14,7 +14,7 @@ interface Foo { interface ?""" try: parser.parse(input) - results = parser.finish() + parser.finish() except WebIDL.WebIDLError as e: threw = True lines = str(e).split("\n") diff --git a/third_party/WebIDL/tests/test_exposed_extended_attribute.py b/third_party/WebIDL/tests/test_exposed_extended_attribute.py index c5ea8e4b88b..015b495be28 100644 --- a/third_party/WebIDL/tests/test_exposed_extended_attribute.py +++ b/third_party/WebIDL/tests/test_exposed_extended_attribute.py @@ -4,7 +4,7 @@ import WebIDL def WebIDLTest(parser, harness): parser.parse( """ - [Global, Exposed=Foo] interface Foo {}; + [Global=Foo, Exposed=Foo] interface Foo {}; [Global=(Bar, Bar1,Bar2), Exposed=Bar] interface Bar {}; [Global=(Baz, Baz2), Exposed=Baz] interface Baz {}; @@ -70,7 +70,7 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse( """ - [Global, Exposed=Foo] interface Foo {}; + [Global=Foo, Exposed=Foo] interface Foo {}; [Global=(Bar, Bar1, Bar2), Exposed=Bar] interface Bar {}; [Global=(Baz, Baz2), Exposed=Baz] interface Baz {}; @@ -108,7 +108,7 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse( """ - [Global, Exposed=Foo] interface Foo {}; + [Global=Foo, Exposed=Foo] interface Foo {}; [Global=(Bar, Bar1, Bar2), Exposed=Bar] interface Bar {}; [Global=(Baz, Baz2), Exposed=Baz] interface Baz {}; @@ -162,7 +162,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown on invalid Exposed value on interface.") @@ -180,7 +180,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown on invalid Exposed value on attribute.") @@ -198,7 +198,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown on invalid Exposed value on operation.") @@ -216,7 +216,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown on invalid Exposed value on constant.") @@ -226,8 +226,8 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=Foo] interface Foo {}; - [Global, Exposed=Bar] interface Bar {}; + [Global=Foo, Exposed=Foo] interface Foo {}; + [Global=Bar, Exposed=Bar] interface Bar {}; [Exposed=Foo] interface Baz { @@ -238,7 +238,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -248,8 +248,8 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse( """ - [Global, Exposed=Foo] interface Foo {}; - [Global, Exposed=Bar] interface Bar {}; + [Global=Foo, Exposed=Foo] interface Foo {}; + [Global=Bar, Exposed=Bar] interface Bar {}; [Exposed=Foo] interface Baz { @@ -294,8 +294,8 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse( """ - [Global, Exposed=Foo] interface Foo {}; - [Global, Exposed=Bar] interface Bar {}; + [Global=Foo, Exposed=Foo] interface Foo {}; + [Global=Bar, Exposed=Bar] interface Bar {}; [Exposed=*] interface Baz { @@ -342,8 +342,8 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=Foo] interface Foo {}; - [Global, Exposed=Bar] interface Bar {}; + [Global=Foo, Exposed=Foo] interface Foo {}; + [Global=Bar, Exposed=Bar] interface Bar {}; [Exposed=Foo] interface Baz { @@ -354,7 +354,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -366,8 +366,8 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=Foo] interface Foo {}; - [Global, Exposed=Bar] interface Bar {}; + [Global=Foo, Exposed=Foo] interface Foo {}; + [Global=Bar, Exposed=Bar] interface Bar {}; [Exposed=(Foo,*)] interface Baz { @@ -377,7 +377,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown on a wildcard in an identifier list.") diff --git a/third_party/WebIDL/tests/test_extended_attributes.py b/third_party/WebIDL/tests/test_extended_attributes.py index 423a67540c7..96c8ee9acbb 100644 --- a/third_party/WebIDL/tests/test_extended_attributes.py +++ b/third_party/WebIDL/tests/test_extended_attributes.py @@ -11,7 +11,7 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() + parser.finish() parser = parser.reset() parser.parse( @@ -23,7 +23,7 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() + parser.finish() parser = parser.reset() parser.parse( @@ -49,8 +49,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "[LegacyLenientThis] must take no arguments") @@ -86,8 +86,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "[Clamp] must take no arguments") @@ -124,8 +124,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "[EnforceRange] must take no arguments") diff --git a/third_party/WebIDL/tests/test_float_types.py b/third_party/WebIDL/tests/test_float_types.py index d37443819d8..1b3b6556d85 100644 --- a/third_party/WebIDL/tests/test_float_types.py +++ b/third_party/WebIDL/tests/test_float_types.py @@ -55,7 +55,7 @@ def WebIDLTest(parser, harness): method = iface.members[6] harness.ok(isinstance(method, WebIDL.IDLMethod), "Should be an IDLMethod") argtypes = [a.type for a in method.signatures()[0][1]] - for (idx, type) in enumerate(argtypes): + for idx, type in enumerate(argtypes): harness.ok(type.isFloat(), "Type %d should be float" % idx) harness.check( type.isUnrestricted(), @@ -74,7 +74,7 @@ def WebIDLTest(parser, harness): }; """ ) - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "[LenientFloat] only allowed on methods returning undefined") @@ -89,7 +89,7 @@ def WebIDLTest(parser, harness): }; """ ) - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "[LenientFloat] only allowed on methods with unrestricted float args" @@ -106,7 +106,7 @@ def WebIDLTest(parser, harness): }; """ ) - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "[LenientFloat] only allowed on methods with unrestricted float args (2)" @@ -123,7 +123,7 @@ def WebIDLTest(parser, harness): }; """ ) - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "[LenientFloat] only allowed on methods with unrestricted float args (3)" @@ -140,6 +140,6 @@ def WebIDLTest(parser, harness): }; """ ) - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "[LenientFloat] only allowed on writable attributes") diff --git a/third_party/WebIDL/tests/test_forward_decl.py b/third_party/WebIDL/tests/test_forward_decl.py index 1c81718400a..1ba19e42fc7 100644 --- a/third_party/WebIDL/tests/test_forward_decl.py +++ b/third_party/WebIDL/tests/test_forward_decl.py @@ -1,6 +1,3 @@ -import WebIDL - - def WebIDLTest(parser, harness): parser.parse( """ @@ -13,6 +10,6 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() + parser.finish() harness.ok(True, "TestForwardDeclared interface parsed without error.") diff --git a/third_party/WebIDL/tests/test_global_extended_attr.py b/third_party/WebIDL/tests/test_global_extended_attr.py index 9ee27efbc8d..9d52747a1da 100644 --- a/third_party/WebIDL/tests/test_global_extended_attr.py +++ b/third_party/WebIDL/tests/test_global_extended_attr.py @@ -1,7 +1,10 @@ +import WebIDL + + def WebIDLTest(parser, harness): parser.parse( """ - [Global, Exposed=Foo] + [Global=Foo, Exposed=Foo] interface Foo : Bar { getter any(DOMString name); }; @@ -26,15 +29,15 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=Foo] + [Global=Foo, Exposed=Foo] interface Foo { getter any(DOMString name); setter undefined(DOMString name, any arg); }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -47,15 +50,15 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=Foo] + [Global=Foo, Exposed=Foo] interface Foo { getter any(DOMString name); deleter undefined(DOMString name); }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -68,13 +71,13 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, LegacyOverrideBuiltIns, Exposed=Foo] + [Global=Foo, LegacyOverrideBuiltIns, Exposed=Foo] interface Foo { }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -88,7 +91,7 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=Foo] + [Global=Foo, Exposed=Foo] interface Foo : Bar { }; [LegacyOverrideBuiltIns, Exposed=Foo] @@ -96,8 +99,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -111,7 +114,7 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=Foo] + [Global=Foo, Exposed=Foo] interface Foo { }; [Exposed=Foo] @@ -119,11 +122,30 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( threw, "Should have thrown for [Global] used on an interface with a " "descendant", ) + + parser = parser.reset() + threw = False + try: + parser.parse( + """ + [Global, Exposed=Foo] + interface Foo { + }; + """ + ) + parser.finish() + except WebIDL.WebIDLError: + threw = True + + harness.ok( + threw, + "Should have thrown for [Global] without a right hand side value", + ) diff --git a/third_party/WebIDL/tests/test_identifier_conflict.py b/third_party/WebIDL/tests/test_identifier_conflict.py index 7404c86f944..424f4d6285b 100644 --- a/third_party/WebIDL/tests/test_identifier_conflict.py +++ b/third_party/WebIDL/tests/test_identifier_conflict.py @@ -1,7 +1,3 @@ -# Import the WebIDL module, so we can do isinstance checks and whatnot -import WebIDL - - def WebIDLTest(parser, harness): try: parser.parse( @@ -10,7 +6,7 @@ def WebIDLTest(parser, harness): interface Foo; """ ) - results = parser.finish() + parser.finish() harness.ok(False, "Should fail to parse") except Exception as e: harness.ok( @@ -25,7 +21,7 @@ def WebIDLTest(parser, harness): enum Foo { "a" }; """ ) - results = parser.finish() + parser.finish() harness.ok(False, "Should fail to parse") except Exception as e: harness.ok( @@ -40,7 +36,7 @@ def WebIDLTest(parser, harness): enum Foo { "b" }; """ ) - results = parser.finish() + parser.finish() harness.ok(False, "Should fail to parse") except Exception as e: harness.ok( diff --git a/third_party/WebIDL/tests/test_incomplete_parent.py b/third_party/WebIDL/tests/test_incomplete_parent.py index ed476b8ed4c..80662a7848f 100644 --- a/third_party/WebIDL/tests/test_incomplete_parent.py +++ b/third_party/WebIDL/tests/test_incomplete_parent.py @@ -1,6 +1,3 @@ -import WebIDL - - def WebIDLTest(parser, harness): parser.parse( """ diff --git a/third_party/WebIDL/tests/test_interface.py b/third_party/WebIDL/tests/test_interface.py index 85748848e1b..5b32a27f4d3 100644 --- a/third_party/WebIDL/tests/test_interface.py +++ b/third_party/WebIDL/tests/test_interface.py @@ -70,7 +70,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow cycles in interface inheritance chains") @@ -86,7 +86,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -103,7 +103,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -223,7 +223,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow two non-partial interfaces with the same name") @@ -241,7 +241,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Must have a non-partial interface for a given name") @@ -259,7 +259,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -281,7 +281,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "Should not allow a name collision between interface " "and other object" @@ -299,7 +299,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -319,7 +319,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -351,14 +351,14 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow unknown extended attributes on interfaces") parser = parser.reset() parser.parse( """ - [Global, Exposed=Window] interface Window {}; + [Global=Window, Exposed=Window] interface Window {}; [Exposed=Window, LegacyWindowAlias=A] interface B {}; [Exposed=Window, LegacyWindowAlias=(C, D)] @@ -383,7 +383,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow [LegacyWindowAlias] with no value") @@ -397,7 +397,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow [LegacyWindowAlias] without Window exposure") @@ -406,7 +406,7 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=Window] interface Window {}; + [Global=Window, Exposed=Window] interface Window {}; [Exposed=Window] interface A {}; [Exposed=Window, LegacyWindowAlias=A] @@ -414,7 +414,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "Should not allow [LegacyWindowAlias] to conflict with other identifiers" @@ -425,7 +425,7 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=Window] interface Window {}; + [Global=Window, Exposed=Window] interface Window {}; [Exposed=Window, LegacyWindowAlias=A] interface B {}; [Exposed=Window] @@ -433,7 +433,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "Should not allow [LegacyWindowAlias] to conflict with other identifiers" @@ -444,7 +444,7 @@ def WebIDLTest(parser, harness): try: parser.parse( """ - [Global, Exposed=Window] interface Window {}; + [Global=Window, Exposed=Window] interface Window {}; [Exposed=Window, LegacyWindowAlias=A] interface B {}; [Exposed=Window, LegacyWindowAlias=A] @@ -452,7 +452,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "Should not allow [LegacyWindowAlias] to conflict with other identifiers" diff --git a/third_party/WebIDL/tests/test_interface_const_identifier_conflicts.py b/third_party/WebIDL/tests/test_interface_const_identifier_conflicts.py index 5750f87a6fc..84f9eeb1f45 100644 --- a/third_party/WebIDL/tests/test_interface_const_identifier_conflicts.py +++ b/third_party/WebIDL/tests/test_interface_const_identifier_conflicts.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -10,8 +13,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_interface_identifier_conflicts_across_members.py b/third_party/WebIDL/tests/test_interface_identifier_conflicts_across_members.py index c1a544ce718..32c0b24704f 100644 --- a/third_party/WebIDL/tests/test_interface_identifier_conflicts_across_members.py +++ b/third_party/WebIDL/tests/test_interface_identifier_conflicts_across_members.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -10,12 +13,13 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True - harness.ok(threw, "Should have thrown.") + harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers1.") + parser = parser.reset() threw = False try: parser.parse( @@ -27,12 +31,13 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True - harness.ok(threw, "Should have thrown.") + harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers2.") + parser = parser.reset() threw = False try: parser.parse( @@ -44,25 +49,123 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True - harness.ok(threw, "Should have thrown.") + harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers3.") + parser = parser.reset() threw = False try: parser.parse( """ - interface IdentifierConflictAcrossMembers1 { + interface IdentifierConflictAcrossMembers4 { const byte thing1 = 1; long thing1(); }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: + threw = True + + harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers4.") + + parser = parser.reset() + threw = False + try: + parser.parse( + """ + interface IdentifierConflictAcrossMembers5 { + static long thing1(); + undefined thing1(); + }; + """ + ) + + parser.finish() + except WebIDL.WebIDLError: + threw = True + + harness.ok( + not threw, "Should not have thrown for IdentifierConflictAcrossMembers5." + ) + + parser = parser.reset() + threw = False + try: + parser.parse( + """ + interface mixin IdentifierConflictAcrossMembers6Mixin { + undefined thing1(); + }; + interface IdentifierConflictAcrossMembers6 { + static long thing1(); + }; + IdentifierConflictAcrossMembers6 includes IdentifierConflictAcrossMembers6Mixin; + """ + ) + + parser.finish() + except WebIDL.WebIDLError: + threw = True + + harness.ok( + not threw, "Should not have thrown for IdentifierConflictAcrossMembers6." + ) + + parser = parser.reset() + threw = False + try: + parser.parse( + """ + interface IdentifierConflictAcrossMembers7 { + const byte thing1 = 1; + static readonly attribute long thing1; + }; + """ + ) + + parser.finish() + except WebIDL.WebIDLError: + threw = True + + harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers7.") + + parser = parser.reset() + threw = False + try: + parser.parse( + """ + interface IdentifierConflictAcrossMembers8 { + readonly attribute long thing1 = 1; + static readonly attribute long thing1; + }; + """ + ) + + parser.finish() + except WebIDL.WebIDLError: + threw = True + + harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers8.") + + parser = parser.reset() + threw = False + try: + parser.parse( + """ + interface IdentifierConflictAcrossMembers9 { + void thing1(); + static readonly attribute long thing1; + }; + """ + ) + + parser.finish() + except WebIDL.WebIDLError: threw = True - harness.ok(threw, "Should have thrown.") + harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers9.") diff --git a/third_party/WebIDL/tests/test_interface_maplikesetlikeiterable.py b/third_party/WebIDL/tests/test_interface_maplikesetlikeiterable.py index 18c6023dd3b..fdd9c009653 100644 --- a/third_party/WebIDL/tests/test_interface_maplikesetlikeiterable.py +++ b/third_party/WebIDL/tests/test_interface_maplikesetlikeiterable.py @@ -1,5 +1,4 @@ import WebIDL -import traceback def WebIDLTest(parser, harness): @@ -20,7 +19,10 @@ def WebIDLTest(parser, harness): expectedMembers = list(expectedMembers) for m in results[0].members: name = m.identifier.name - if (name, type(m)) in expectedMembers: + if m.isMethod() and m.isStatic(): + # None of the expected members are static methods, so ignore those. + harness.ok(True, "%s - %s - Should be a %s" % (prefix, name, type(m))) + elif (name, type(m)) in expectedMembers: harness.ok(True, "%s - %s - Should be a %s" % (prefix, name, type(m))) expectedMembers.remove((name, type(m))) else: @@ -45,7 +47,7 @@ def WebIDLTest(parser, harness): p.parse(iface) p.finish() harness.ok(False, prefix + " - Interface passed when should've failed") - except WebIDL.WebIDLError as e: + except WebIDL.WebIDLError: harness.ok(True, prefix + " - Interface failed as expected") except Exception as e: harness.ok( @@ -66,12 +68,6 @@ def WebIDLTest(parser, harness): setRWMembers = [ (x, WebIDL.IDLMethod) for x in ["add", "clear", "delete"] ] + setROMembers - setROChromeMembers = [ - (x, WebIDL.IDLMethod) for x in ["__add", "__clear", "__delete"] - ] + setROMembers - setRWChromeMembers = [ - (x, WebIDL.IDLMethod) for x in ["__add", "__clear", "__delete"] - ] + setRWMembers mapROMembers = ( [(x, WebIDL.IDLMethod) for x in ["get", "has"]] + [("__maplike", WebIDL.IDLMaplikeOrSetlike)] @@ -81,9 +77,6 @@ def WebIDLTest(parser, harness): mapRWMembers = [ (x, WebIDL.IDLMethod) for x in ["set", "clear", "delete"] ] + mapROMembers - mapRWChromeMembers = [ - (x, WebIDL.IDLMethod) for x in ["__set", "__clear", "__delete"] - ] + mapRWMembers # OK, now that we've used iterableMembers to set up the above, append # __iterable to it for the iterable<> case. @@ -101,12 +94,23 @@ def WebIDLTest(parser, harness): valueAsyncIterableMembers = [("__iterable", WebIDL.IDLAsyncIterable)] valueAsyncIterableMembers.append(("values", WebIDL.IDLMethod)) - disallowedIterableNames = ["keys", "entries", "values"] - disallowedMemberNames = ["forEach", "has", "size"] + disallowedIterableNames - mapDisallowedMemberNames = ["get"] + disallowedMemberNames - disallowedNonMethodNames = ["clear", "delete"] - mapDisallowedNonMethodNames = ["set"] + disallowedNonMethodNames - setDisallowedNonMethodNames = ["add"] + disallowedNonMethodNames + disallowedIterableNames = [ + ("keys", WebIDL.IDLMethod), + ("entries", WebIDL.IDLMethod), + ("values", WebIDL.IDLMethod), + ] + disallowedMemberNames = [ + ("forEach", WebIDL.IDLMethod), + ("has", WebIDL.IDLMethod), + ("size", WebIDL.IDLAttribute), + ] + disallowedIterableNames + mapDisallowedMemberNames = [("get", WebIDL.IDLMethod)] + disallowedMemberNames + disallowedNonMethodNames = [ + ("clear", WebIDL.IDLMethod), + ("delete", WebIDL.IDLMethod), + ] + mapDisallowedNonMethodNames = [("set", WebIDL.IDLMethod)] + disallowedNonMethodNames + setDisallowedNonMethodNames = [("add", WebIDL.IDLMethod)] + disallowedNonMethodNames unrelatedMembers = [ ("unrelatedAttribute", WebIDL.IDLAttribute), ("unrelatedMethod", WebIDL.IDLMethod), @@ -570,7 +574,9 @@ def WebIDLTest(parser, harness): # Member name collision tests # - def testConflictingMembers(likeMember, conflictName, expectedMembers, methodPasses): + def testConflictingMembers( + likeMember, conflict, expectedMembers, methodPasses, numProductions=1 + ): """ Tests for maplike/setlike member generation against conflicting member names. If methodPasses is True, this means we expect the interface to @@ -578,6 +584,7 @@ def WebIDLTest(parser, harness): list of interface members to check against on the passing interface. """ + (conflictName, conflictType) = conflict if methodPasses: shouldPass( "Conflicting method: %s and %s" % (likeMember, conflictName), @@ -616,16 +623,30 @@ def WebIDLTest(parser, harness): """ % (conflictName, likeMember), ) - shouldFail( - "Conflicting static method: %s and %s" % (likeMember, conflictName), - """ - interface Foo1 { - %s; - static undefined %s(long test1, double test2, double test3); - }; - """ - % (likeMember, conflictName), - ) + if conflictType == WebIDL.IDLAttribute: + shouldFail( + "Conflicting static method: %s and %s" % (likeMember, conflictName), + """ + interface Foo1 { + %s; + static undefined %s(long test1, double test2, double test3); + }; + """ + % (likeMember, conflictName), + ) + else: + shouldPass( + "Conflicting static method: %s and %s" % (likeMember, conflictName), + """ + interface Foo1 { + %s; + static undefined %s(long test1, double test2, double test3); + }; + """ + % (likeMember, conflictName), + expectedMembers, + numProductions=numProductions, + ) shouldFail( "Conflicting attribute: %s and %s" % (likeMember, conflictName), """ @@ -658,7 +679,9 @@ def WebIDLTest(parser, harness): ) for member in disallowedIterableNames: - testConflictingMembers("iterable<long, long>", member, iterableMembers, False) + testConflictingMembers( + "iterable<long, long>", member, iterableMembers, False, numProductions=2 + ) for member in mapDisallowedMemberNames: testConflictingMembers("maplike<long, long>", member, mapRWMembers, False) for member in disallowedMemberNames: diff --git a/third_party/WebIDL/tests/test_interfacemixin.py b/third_party/WebIDL/tests/test_interfacemixin.py index b3c8573fa59..297cc109150 100644 --- a/third_party/WebIDL/tests/test_interfacemixin.py +++ b/third_party/WebIDL/tests/test_interfacemixin.py @@ -155,7 +155,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "Should not allow two non-partial interface mixins with the same name" @@ -175,7 +175,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Must have a non-partial interface mixin for a given name") @@ -193,7 +193,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -215,7 +215,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -234,7 +234,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -254,7 +254,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "Should not allow unknown extended attributes on interface mixins" @@ -271,7 +271,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow getters on interface mixins") @@ -286,7 +286,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow setters on interface mixins") @@ -301,7 +301,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow deleters on interface mixins") @@ -316,7 +316,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow legacycallers on interface mixins") @@ -331,7 +331,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow inherited attribute on interface mixins") @@ -348,7 +348,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should fail if the right side does not point an interface mixin") @@ -365,7 +365,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should fail if the left side does not point an interface") @@ -380,7 +380,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should fail if an interface mixin includes iterable") @@ -395,7 +395,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should fail if an interface mixin includes setlike") @@ -410,7 +410,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should fail if an interface mixin includes maplike") @@ -429,7 +429,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "Should fail if the included mixin interface has duplicated member" @@ -452,7 +452,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "Should fail if the included mixin interfaces have duplicated member" @@ -461,8 +461,8 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse( """ - [Global, Exposed=Window] interface Window {}; - [Global, Exposed=Worker] interface Worker {}; + [Global=Window, Exposed=Window] interface Window {}; + [Global=Worker, Exposed=Worker] interface Worker {}; [Exposed=Window] interface Base {}; interface mixin Mixin { @@ -483,8 +483,8 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse( """ - [Global, Exposed=Window] interface Window {}; - [Global, Exposed=Worker] interface Worker {}; + [Global=Window, Exposed=Window] interface Window {}; + [Global=Worker, Exposed=Worker] interface Worker {}; [Exposed=Window] interface Base {}; [Exposed=Window] @@ -504,8 +504,8 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse( """ - [Global, Exposed=Window] interface Window {}; - [Global, Exposed=Worker] interface Worker {}; + [Global=Window, Exposed=Window] interface Window {}; + [Global=Worker, Exposed=Worker] interface Worker {}; [Exposed=Window] interface Base1 {}; [Exposed=Worker] diff --git a/third_party/WebIDL/tests/test_legacyTreatNonObjectAsNull.py b/third_party/WebIDL/tests/test_legacyTreatNonObjectAsNull.py new file mode 100644 index 00000000000..380ccdc4e72 --- /dev/null +++ b/third_party/WebIDL/tests/test_legacyTreatNonObjectAsNull.py @@ -0,0 +1,11 @@ +def WebIDLTest(parser, harness): + parser.parse( + """ + [LegacyTreatNonObjectAsNull] callback Function = any(any... arguments); + """ + ) + + results = parser.finish() + + callback = results[0] + harness.check(callback._treatNonObjectAsNull, True, "Got the expected value") diff --git a/third_party/WebIDL/tests/test_lenientSetter.py b/third_party/WebIDL/tests/test_lenientSetter.py index 9d2230c3bec..9059255594f 100644 --- a/third_party/WebIDL/tests/test_lenientSetter.py +++ b/third_party/WebIDL/tests/test_lenientSetter.py @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +import WebIDL + def should_throw(parser, harness, message, code): parser = parser.reset() @@ -9,7 +11,7 @@ def should_throw(parser, harness, message, code): try: parser.parse(code) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown: %s" % message) diff --git a/third_party/WebIDL/tests/test_method.py b/third_party/WebIDL/tests/test_method.py index 0ddfada28ac..80eb0043728 100644 --- a/third_party/WebIDL/tests/test_method.py +++ b/third_party/WebIDL/tests/test_method.py @@ -90,7 +90,7 @@ def WebIDLTest(parser, harness): ) sigpairs = zip(method.signatures(), signatures) - for (gotSignature, expectedSignature) in sigpairs: + for gotSignature, expectedSignature in sigpairs: (gotRetType, gotArgs) = gotSignature (expectedRetType, expectedArgs) = expectedSignature @@ -267,7 +267,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(not threw, "Should allow integer to float type corecion") @@ -282,7 +282,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow [GetterThrows] on methods") @@ -297,7 +297,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow [SetterThrows] on methods") @@ -312,7 +312,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should spell [Throws] correctly on methods") @@ -327,7 +327,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow __noSuchMethod__ methods") @@ -345,7 +345,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(not threw, "Should allow LenientFloat to be only in a specific overload") @@ -383,7 +383,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -404,7 +404,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -425,6 +425,6 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should prevent overloads from getting redundant [LenientFloat]") diff --git a/third_party/WebIDL/tests/test_namespace.py b/third_party/WebIDL/tests/test_namespace.py index 247c5b22232..5812364dddc 100644 --- a/third_party/WebIDL/tests/test_namespace.py +++ b/third_party/WebIDL/tests/test_namespace.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): parser.parse( """ @@ -71,7 +74,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -87,7 +90,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -107,7 +110,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -127,7 +130,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -147,7 +150,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -167,7 +170,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -187,7 +190,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -207,7 +210,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -227,6 +230,6 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_newobject.py b/third_party/WebIDL/tests/test_newobject.py index c12995a0e86..b30e9c58160 100644 --- a/third_party/WebIDL/tests/test_newobject.py +++ b/third_party/WebIDL/tests/test_newobject.py @@ -1,7 +1,7 @@ -# Import the WebIDL module, so we can do isinstance checks and whatnot import WebIDL +# Import the WebIDL module, so we can do isinstance checks and whatnot def WebIDLTest(parser, harness): # Basic functionality parser.parse( @@ -25,8 +25,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "[NewObject] attributes must depend on something") @@ -40,8 +40,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "[NewObject] methods must depend on something") @@ -55,8 +55,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "[NewObject] attributes must not be [Cached]") @@ -70,7 +70,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "[NewObject] attributes must not be [StoreInSlot]") diff --git a/third_party/WebIDL/tests/test_nullable_equivalency.py b/third_party/WebIDL/tests/test_nullable_equivalency.py index 012c5fcff7c..5790288ccb9 100644 --- a/third_party/WebIDL/tests/test_nullable_equivalency.py +++ b/third_party/WebIDL/tests/test_nullable_equivalency.py @@ -105,13 +105,17 @@ def checkEquivalent(iface, harness): if callable(a1): try: v1 = a1() - except: - # Can't call a1 with no args, so skip this attriute. + except AssertionError: + # Various methods assert that they're called on objects of + # the right type, skip them if the assert fails. + continue + except TypeError: + # a1 requires positional arguments, so skip this attribute. continue try: a2 = getattr(type2, attr) - except: + except WebIDL.WebIDLError: harness.ok( False, "Missing %s attribute on type %s in %s" % (attr, type2, iface), @@ -131,7 +135,7 @@ def checkEquivalent(iface, harness): else: try: a2 = getattr(type2, attr) - except: + except WebIDL.WebIDLError: harness.ok( False, "Missing %s attribute on type %s in %s" % (attr, type2, iface), diff --git a/third_party/WebIDL/tests/test_nullable_void.py b/third_party/WebIDL/tests/test_nullable_void.py new file mode 100644 index 00000000000..f2a0177ced5 --- /dev/null +++ b/third_party/WebIDL/tests/test_nullable_void.py @@ -0,0 +1,19 @@ +import WebIDL + + +def WebIDLTest(parser, harness): + threw = False + try: + parser.parse( + """ + interface NullableVoid { + void? foo(); + }; + """ + ) + + parser.finish() + except WebIDL.WebIDLError: + threw = True + + harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_observableArray.py b/third_party/WebIDL/tests/test_observableArray.py index 601f626bcf4..7fe9511e074 100644 --- a/third_party/WebIDL/tests/test_observableArray.py +++ b/third_party/WebIDL/tests/test_observableArray.py @@ -4,7 +4,6 @@ def WebIDLTest(parser, harness): - # Test dictionary as inner type harness.should_throw( parser, diff --git a/third_party/WebIDL/tests/test_optional_constraints.py b/third_party/WebIDL/tests/test_optional_constraints.py index 2044c6362c3..34f03467621 100644 --- a/third_party/WebIDL/tests/test_optional_constraints.py +++ b/third_party/WebIDL/tests/test_optional_constraints.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -9,8 +12,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( diff --git a/third_party/WebIDL/tests/test_promise.py b/third_party/WebIDL/tests/test_promise.py index 9b418d51afe..1dfb6d4643c 100644 --- a/third_party/WebIDL/tests/test_promise.py +++ b/third_party/WebIDL/tests/test_promise.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -8,9 +11,9 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow Promise return values for legacycaller.") @@ -25,8 +28,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -45,8 +48,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -64,8 +67,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow nullable Promise return values.") @@ -79,8 +82,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow nullable Promise arguments.") @@ -93,7 +96,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() harness.ok( True, "Should allow overloads which only have Promise and return " "types." @@ -109,8 +112,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow writable Promise-typed attributes.") @@ -124,8 +127,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( threw, "Should not allow [LegacyLenientSetter] Promise-typed attributes." @@ -141,8 +144,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow [PutForwards] Promise-typed attributes.") @@ -156,8 +159,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow [Replaceable] Promise-typed attributes.") @@ -171,7 +174,7 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow [SameObject] Promise-typed attributes.") diff --git a/third_party/WebIDL/tests/test_prototype_ident.py b/third_party/WebIDL/tests/test_prototype_ident.py index 5a806bf2a2d..5e4d3a20002 100644 --- a/third_party/WebIDL/tests/test_prototype_ident.py +++ b/third_party/WebIDL/tests/test_prototype_ident.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -8,8 +11,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "The identifier of a static attribute must not be 'prototype'") @@ -24,8 +27,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "The identifier of a static operation must not be 'prototype'") @@ -40,8 +43,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "The identifier of a constant must not be 'prototype'") diff --git a/third_party/WebIDL/tests/test_putForwards.py b/third_party/WebIDL/tests/test_putForwards.py index 5ec4dde280e..e32e6c14f74 100644 --- a/third_party/WebIDL/tests/test_putForwards.py +++ b/third_party/WebIDL/tests/test_putForwards.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -9,8 +12,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -28,8 +31,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -48,8 +51,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -68,8 +71,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -88,8 +91,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -112,8 +115,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_record.py b/third_party/WebIDL/tests/test_record.py index 3a31d721b27..bee5c83953d 100644 --- a/third_party/WebIDL/tests/test_record.py +++ b/third_party/WebIDL/tests/test_record.py @@ -38,7 +38,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "Should have thrown because record can't have undefined as value type." @@ -56,6 +56,6 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown on dictionary containing itself via record.") diff --git a/third_party/WebIDL/tests/test_replaceable.py b/third_party/WebIDL/tests/test_replaceable.py index 06ea6a47239..3b0a6fea360 100644 --- a/third_party/WebIDL/tests/test_replaceable.py +++ b/third_party/WebIDL/tests/test_replaceable.py @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +import WebIDL + def should_throw(parser, harness, message, code): parser = parser.reset() @@ -9,7 +11,7 @@ def should_throw(parser, harness, message, code): try: parser.parse(code) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown: %s" % message) diff --git a/third_party/WebIDL/tests/test_securecontext_extended_attribute.py b/third_party/WebIDL/tests/test_securecontext_extended_attribute.py index e0e967dd420..4dd0811ed76 100644 --- a/third_party/WebIDL/tests/test_securecontext_extended_attribute.py +++ b/third_party/WebIDL/tests/test_securecontext_extended_attribute.py @@ -41,11 +41,17 @@ def WebIDLTest(parser, harness): ) harness.ok( results[0].members[3].getExtendedAttribute("SecureContext"), - "[SecureContext] should propagate from interface to constant members from partial interface", + ( + "[SecureContext] should propagate from interface to " + "constant members from partial interface" + ), ) harness.ok( results[0].members[4].getExtendedAttribute("SecureContext"), - "[SecureContext] should propagate from interface to attribute members from partial interface", + ( + "[SecureContext] should propagate from interface to " + "attribute members from partial interface" + ), ) harness.ok( results[0].members[5].getExtendedAttribute("SecureContext"), @@ -93,15 +99,24 @@ def WebIDLTest(parser, harness): ) harness.ok( results[1].members[3].getExtendedAttribute("SecureContext"), - "[SecureContext] should propagate from interface to constant members from partial interface", + ( + "[SecureContext] should propagate from interface to constant members from " + "partial interface" + ), ) harness.ok( results[1].members[4].getExtendedAttribute("SecureContext"), - "[SecureContext] should propagate from interface to attribute members from partial interface", + ( + "[SecureContext] should propagate from interface to attribute members from " + "partial interface" + ), ) harness.ok( results[1].members[5].getExtendedAttribute("SecureContext"), - "[SecureContext] should propagate from interface to method members from partial interface", + ( + "[SecureContext] should propagate from interface to method members from partial " + "interface" + ), ) parser = parser.reset() @@ -132,15 +147,24 @@ def WebIDLTest(parser, harness): ) harness.ok( results[0].members[0].getExtendedAttribute("SecureContext") is None, - "[SecureContext] should not propagate from a partial interface to the interface's constant members", + ( + "[SecureContext] should not propagate from a partial interface to the interface's " + "constant members" + ), ) harness.ok( results[0].members[1].getExtendedAttribute("SecureContext") is None, - "[SecureContext] should not propagate from a partial interface to the interface's attribute members", + ( + "[SecureContext] should not propagate from a partial interface to the interface's " + "attribute members" + ), ) harness.ok( results[0].members[2].getExtendedAttribute("SecureContext") is None, - "[SecureContext] should not propagate from a partial interface to the interface's method members", + ( + "[SecureContext] should not propagate from a partial interface to the interface's " + "method members" + ), ) harness.ok( results[0].members[3].getExtendedAttribute("SecureContext"), @@ -297,7 +321,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "[SecureContext] must take no arguments (testing on interface)") @@ -316,11 +340,14 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, - "If [SecureContext] appears on an overloaded operation, then it MUST appear on all overloads", + ( + "If [SecureContext] appears on an overloaded operation, then it MUST appear on all " + "overloads" + ), ) parser = parser.reset() @@ -339,7 +366,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( not threw, @@ -359,7 +386,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, "[SecureContext] must not appear on an interface and interface member" @@ -380,11 +407,14 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, - "[SecureContext] must not appear on a partial interface and one of the partial interface's member's", + ( + "[SecureContext] must not appear on a partial interface and one of the partial " + "interface's member's" + ), ) parser = parser.reset() @@ -402,11 +432,14 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, - "[SecureContext] must not appear on an interface and one of its partial interface's member's", + ( + "[SecureContext] must not appear on an interface and one of its partial interface's " + "member's" + ), ) parser = parser.reset() @@ -423,11 +456,14 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, - "[SecureContext] must appear on interfaces that inherit from another [SecureContext] interface", + ( + "[SecureContext] must appear on interfaces that inherit from another [SecureContext] " + "interface" + ), ) # Test 'includes'. @@ -450,7 +486,10 @@ def WebIDLTest(parser, harness): harness.check( len(results[0].members), 4, - "TestSecureContextInterfaceThatImplementsNonSecureContextInterface should have four members", + ( + "TestSecureContextInterfaceThatImplementsNonSecureContextInterface should have four " + "members" + ), ) harness.ok( results[0].getExtendedAttribute("SecureContext"), @@ -458,7 +497,10 @@ def WebIDLTest(parser, harness): ) harness.ok( results[0].members[0].getExtendedAttribute("SecureContext"), - "[SecureContext] should propagate from interface to constant members even when other members are copied from a non-[SecureContext] interface", + ( + "[SecureContext] should propagate from interface to constant members even when other " + "members are copied from a non-[SecureContext] interface" + ), ) harness.ok( results[0].members[1].getExtendedAttribute("SecureContext") is None, diff --git a/third_party/WebIDL/tests/test_special_method_signature_mismatch.py b/third_party/WebIDL/tests/test_special_method_signature_mismatch.py index a11860b3728..5dd581985bd 100644 --- a/third_party/WebIDL/tests/test_special_method_signature_mismatch.py +++ b/third_party/WebIDL/tests/test_special_method_signature_mismatch.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -9,8 +12,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -25,8 +28,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -41,8 +44,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -57,8 +60,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -73,8 +76,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -89,8 +92,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -105,8 +108,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -121,8 +124,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -137,8 +140,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -153,8 +156,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -169,8 +172,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -185,8 +188,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -201,8 +204,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -217,8 +220,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -233,8 +236,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -249,8 +252,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_special_methods.py b/third_party/WebIDL/tests/test_special_methods.py index 9601a0a968f..911bb8ec0da 100644 --- a/third_party/WebIDL/tests/test_special_methods.py +++ b/third_party/WebIDL/tests/test_special_methods.py @@ -111,7 +111,7 @@ def WebIDLTest(parser, harness): """ ) parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "There are no indexed deleters") diff --git a/third_party/WebIDL/tests/test_special_methods_uniqueness.py b/third_party/WebIDL/tests/test_special_methods_uniqueness.py index 014737e8168..948c6392040 100644 --- a/third_party/WebIDL/tests/test_special_methods_uniqueness.py +++ b/third_party/WebIDL/tests/test_special_methods_uniqueness.py @@ -13,8 +13,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -30,8 +30,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -47,8 +47,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_stringifier.py b/third_party/WebIDL/tests/test_stringifier.py index 948be71e4dd..c2052c44e57 100644 --- a/third_party/WebIDL/tests/test_stringifier.py +++ b/third_party/WebIDL/tests/test_stringifier.py @@ -30,7 +30,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow two 'stringifier;'") @@ -48,7 +48,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow a 'stringifier;' and a 'stringifier()'") @@ -156,7 +156,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow ByteString") @@ -173,7 +173,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow a 'stringifier;' and a stringifier attribute") @@ -190,7 +190,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow multiple stringifier attributes") diff --git a/third_party/WebIDL/tests/test_toJSON.py b/third_party/WebIDL/tests/test_toJSON.py index f312667ec4d..ec81080beca 100644 --- a/third_party/WebIDL/tests/test_toJSON.py +++ b/third_party/WebIDL/tests/test_toJSON.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -8,8 +11,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(not threw, "Should allow a toJSON method.") @@ -24,8 +27,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow overloads of a toJSON method.") @@ -39,8 +42,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should not allow a toJSON method with arguments.") @@ -54,8 +57,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(not threw, "Should allow a toJSON method with 'long' as return type.") @@ -69,8 +72,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( not threw, "Should allow a default toJSON method with 'object' as return type." @@ -86,8 +89,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( threw, diff --git a/third_party/WebIDL/tests/test_treatNonCallableAsNull.py b/third_party/WebIDL/tests/test_treatNonCallableAsNull.py index 7becfdca1f3..8ad7f942b12 100644 --- a/third_party/WebIDL/tests/test_treatNonCallableAsNull.py +++ b/third_party/WebIDL/tests/test_treatNonCallableAsNull.py @@ -36,7 +36,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -57,7 +57,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -74,7 +74,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_typedef.py b/third_party/WebIDL/tests/test_typedef.py index c19d064efff..58c17135de9 100644 --- a/third_party/WebIDL/tests/test_typedef.py +++ b/third_party/WebIDL/tests/test_typedef.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): parser.parse( """ @@ -32,7 +35,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown on nullable inside nullable arg.") @@ -49,7 +52,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown on nullable inside nullable const.") @@ -66,7 +69,7 @@ def WebIDLTest(parser, harness): """ ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( diff --git a/third_party/WebIDL/tests/test_typedef_identifier_conflict.py b/third_party/WebIDL/tests/test_typedef_identifier_conflict.py index 2aab3a8a91f..90e45ddb7df 100644 --- a/third_party/WebIDL/tests/test_typedef_identifier_conflict.py +++ b/third_party/WebIDL/tests/test_typedef_identifier_conflict.py @@ -8,7 +8,7 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() + parser.finish() except Exception as e: exception = e diff --git a/third_party/WebIDL/tests/test_undefined.py b/third_party/WebIDL/tests/test_undefined.py index 4731ee1bcd7..34d1ac824ec 100644 --- a/third_party/WebIDL/tests/test_undefined.py +++ b/third_party/WebIDL/tests/test_undefined.py @@ -11,8 +11,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "undefined must not be used as the type of a dictionary member") @@ -28,8 +28,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -49,8 +49,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -70,8 +70,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -91,8 +91,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -112,8 +112,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -133,8 +133,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -152,8 +152,8 @@ def WebIDLTest(parser, harness): callback Callback = undefined (undefined foo); """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -173,8 +173,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -195,8 +195,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -216,8 +216,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -236,8 +236,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( diff --git a/third_party/WebIDL/tests/test_unenumerable_own_properties.py b/third_party/WebIDL/tests/test_unenumerable_own_properties.py index b024d317492..f465598efd5 100644 --- a/third_party/WebIDL/tests/test_unenumerable_own_properties.py +++ b/third_party/WebIDL/tests/test_unenumerable_own_properties.py @@ -1,5 +1,7 @@ -def WebIDLTest(parser, harness): +import WebIDL + +def WebIDLTest(parser, harness): parser.parse( """ interface Foo {}; @@ -27,7 +29,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -44,7 +46,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") @@ -66,6 +68,6 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_unforgeable.py b/third_party/WebIDL/tests/test_unforgeable.py index 500d123ddb2..0f7d52349a5 100644 --- a/third_party/WebIDL/tests/test_unforgeable.py +++ b/third_party/WebIDL/tests/test_unforgeable.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): parser.parse( """ @@ -95,7 +98,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -118,7 +121,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -141,7 +144,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -164,7 +167,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except Exception as x: + except WebIDL.WebIDLError: threw = True harness.ok( threw, @@ -210,7 +213,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -240,7 +243,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -270,7 +273,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -305,7 +308,7 @@ def WebIDLTest(parser, harness): ) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown for static [LegacyUnforgeable] attribute.") diff --git a/third_party/WebIDL/tests/test_union.py b/third_party/WebIDL/tests/test_union.py index 7fc1236d54e..71791207bab 100644 --- a/third_party/WebIDL/tests/test_union.py +++ b/third_party/WebIDL/tests/test_union.py @@ -1,7 +1,7 @@ -import WebIDL -import itertools import string +import WebIDL + # We'd like to use itertools.chain but it's 2.6 or higher. @@ -91,7 +91,7 @@ def WebIDLTest(parser, harness): interface PrepareForTest { """ ) - for (i, type) in enumerate(types): + for i, type in enumerate(types): interface += string.Template( """ readonly attribute ${type} attr${i}; @@ -157,7 +157,7 @@ def WebIDLTest(parser, harness): interface TestUnion { """ ) - for (i, type) in enumerate(validUnionTypes): + for i, type in enumerate(validUnionTypes): interface += string.Template( """ undefined method${i}(${type} arg); @@ -190,7 +190,7 @@ def WebIDLTest(parser, harness): try: parser.parse(interface) results = parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_union_any.py b/third_party/WebIDL/tests/test_union_any.py index caba44b55f9..7bde16a622a 100644 --- a/third_party/WebIDL/tests/test_union_any.py +++ b/third_party/WebIDL/tests/test_union_any.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -9,8 +12,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown.") diff --git a/third_party/WebIDL/tests/test_union_callback_dict.py b/third_party/WebIDL/tests/test_union_callback_dict.py new file mode 100644 index 00000000000..3e87e16ad47 --- /dev/null +++ b/third_party/WebIDL/tests/test_union_callback_dict.py @@ -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", + ) diff --git a/third_party/WebIDL/tests/test_union_nullable.py b/third_party/WebIDL/tests/test_union_nullable.py index d15ed4cfb54..d5ae2e1e74c 100644 --- a/third_party/WebIDL/tests/test_union_nullable.py +++ b/third_party/WebIDL/tests/test_union_nullable.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -9,8 +12,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Two nullable member types of a union should have thrown.") @@ -27,8 +30,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -50,8 +53,8 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( diff --git a/third_party/WebIDL/tests/test_variadic_callback.py b/third_party/WebIDL/tests/test_variadic_callback.py index 3fd3dccd37a..fab1c7ef109 100644 --- a/third_party/WebIDL/tests/test_variadic_callback.py +++ b/third_party/WebIDL/tests/test_variadic_callback.py @@ -1,6 +1,3 @@ -import WebIDL - - def WebIDLTest(parser, harness): parser.parse( """ @@ -8,6 +5,6 @@ def WebIDLTest(parser, harness): """ ) - results = parser.finish() + parser.finish() harness.ok(True, "TestVariadicCallback callback parsed without error.") diff --git a/third_party/WebIDL/tests/test_variadic_constraints.py b/third_party/WebIDL/tests/test_variadic_constraints.py index 06ce09d8236..749c4a7812a 100644 --- a/third_party/WebIDL/tests/test_variadic_constraints.py +++ b/third_party/WebIDL/tests/test_variadic_constraints.py @@ -1,3 +1,6 @@ +import WebIDL + + def WebIDLTest(parser, harness): threw = False try: @@ -8,9 +11,9 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -28,8 +31,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok( @@ -47,9 +50,9 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() + parser.finish() - except: + except WebIDL.WebIDLError: threw = True harness.ok( @@ -67,8 +70,8 @@ def WebIDLTest(parser, harness): }; """ ) - results = parser.finish() - except: + parser.finish() + except WebIDL.WebIDLError: threw = True harness.ok(threw, "Should have thrown on variadic argument with default value.") |