diff options
author | Kagami Sascha Rosylight <saschanaz@outlook.com> | 2019-10-02 18:21:34 +0900 |
---|---|---|
committer | Kagami Sascha Rosylight <saschanaz@outlook.com> | 2019-10-03 14:25:23 +0900 |
commit | 2660f359254e7543b7c91d14728b44ac01e438e5 (patch) | |
tree | 3a46481fc1bbe22994df7186ce10d5ea6a4ec015 /components/script/dom/bindings/codegen/parser/tests | |
parent | 84693d81173b58c4afc408a7295210960842484a (diff) | |
download | servo-2660f359254e7543b7c91d14728b44ac01e438e5.tar.gz servo-2660f359254e7543b7c91d14728b44ac01e438e5.zip |
Remove [PrimaryGlobal]
Diffstat (limited to 'components/script/dom/bindings/codegen/parser/tests')
11 files changed, 181 insertions, 458 deletions
diff --git a/components/script/dom/bindings/codegen/parser/tests/test_constructor_global.py b/components/script/dom/bindings/codegen/parser/tests/test_constructor_global.py index c469d56e817..31c5d95317f 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_constructor_global.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_constructor_global.py @@ -1,8 +1,10 @@ +import traceback + def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [Global] + [Global, Exposed=TestConstructorGlobal] interface TestConstructorGlobal { constructor(); }; @@ -18,7 +20,8 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [Global, NamedConstructor=FooBar] + [Global, Exposed=TestNamedConstructorGlobal, + NamedConstructor=FooBar] interface TestNamedConstructorGlobal { }; """) @@ -32,7 +35,8 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [NamedConstructor=FooBar, Global] + [NamedConstructor=FooBar, Global, + Exposed=TestNamedConstructorGlobal] interface TestNamedConstructorGlobal { }; """) @@ -46,7 +50,7 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [Global, HTMLConstructor] + [Global, HTMLConstructor, Exposed=TestHTMLConstructorGlobal] interface TestHTMLConstructorGlobal { }; """) @@ -61,7 +65,7 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [HTMLConstructor, Global] + [HTMLConstructor, Global, Exposed=TestHTMLConstructorGlobal] interface TestHTMLConstructorGlobal { }; """) diff --git a/components/script/dom/bindings/codegen/parser/tests/test_dictionary.py b/components/script/dom/bindings/codegen/parser/tests/test_dictionary.py index cff049bea15..3cad3022389 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_dictionary.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_dictionary.py @@ -736,3 +736,17 @@ def WebIDLTest(parser, harness): threw = True harness.ok(threw, "Only unrestricted values can be initialized to NaN") + + parser = parser.reset(); + threw = False + try: + parser.parse(""" + dictionary Foo { + long module; + }; + """) + results = parser.finish() + except: + threw = True + + harness.ok(not threw, "Should be able to use 'module' as a dictionary member name") diff --git a/components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py b/components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py index 8d18b26cf2d..bd9996e34c9 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py @@ -59,8 +59,6 @@ def WebIDLTest(parser, harness): void passKid(Kid arg); void passParent(Parent arg); void passGrandparent(Grandparent arg); - void passImplemented(Implemented arg); - void passImplementedParent(ImplementedParent arg); void passUnrelated1(Unrelated1 arg); void passUnrelated2(Unrelated2 arg); void passArrayBuffer(ArrayBuffer arg); @@ -70,9 +68,6 @@ def WebIDLTest(parser, harness): interface Kid : Parent {}; interface Parent : Grandparent {}; interface Grandparent {}; - interface Implemented : ImplementedParent {}; - Parent implements Implemented; - interface ImplementedParent {}; interface Unrelated1 {}; interface Unrelated2 {}; """) @@ -156,8 +151,7 @@ def WebIDLTest(parser, harness): argTypes = [ "long", "short", "long?", "short?", "boolean", "boolean?", "DOMString", "ByteString", "Enum", "Enum2", "Interface", "Interface?", - "AncestorInterface", "UnrelatedInterface", - "ImplementedInterface", "CallbackInterface", + "AncestorInterface", "UnrelatedInterface", "CallbackInterface", "CallbackInterface?", "CallbackInterface2", "object", "Callback", "Callback2", "Dict", "Dict2", "sequence<long>", "sequence<short>", @@ -190,7 +184,7 @@ def WebIDLTest(parser, harness): bufferSourceTypes = ["ArrayBuffer", "ArrayBufferView", "Uint8Array", "Uint16Array"] sharedBufferSourceTypes = ["SharedArrayBuffer"] interfaces = [ "Interface", "Interface?", "AncestorInterface", - "UnrelatedInterface", "ImplementedInterface" ] + bufferSourceTypes + sharedBufferSourceTypes + "UnrelatedInterface" ] + bufferSourceTypes + sharedBufferSourceTypes nullables = (["long?", "short?", "boolean?", "Interface?", "CallbackInterface?", "Dict", "Dict2", "Date?", "any", "Promise<any>?"] + @@ -230,7 +224,6 @@ def WebIDLTest(parser, harness): setDistinguishable("AncestorInterface", notRelatedInterfaces) setDistinguishable("UnrelatedInterface", allBut(argTypes, ["object", "UnrelatedInterface"])) - setDistinguishable("ImplementedInterface", notRelatedInterfaces) setDistinguishable("CallbackInterface", nonUserObjects) setDistinguishable("CallbackInterface?", allBut(nonUserObjects, nullables)) setDistinguishable("CallbackInterface2", nonUserObjects) @@ -272,8 +265,6 @@ def WebIDLTest(parser, harness): interface Interface : AncestorInterface {}; interface AncestorInterface {}; interface UnrelatedInterface {}; - interface ImplementedInterface {}; - Interface implements ImplementedInterface; callback interface CallbackInterface {}; callback interface CallbackInterface2 {}; callback Callback = any(); diff --git a/components/script/dom/bindings/codegen/parser/tests/test_exposed_extended_attribute.py b/components/script/dom/bindings/codegen/parser/tests/test_exposed_extended_attribute.py index a6c04e30caf..e0241a56426 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_exposed_extended_attribute.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_exposed_extended_attribute.py @@ -2,9 +2,9 @@ import WebIDL def WebIDLTest(parser, harness): parser.parse(""" - [PrimaryGlobal] interface Foo {}; - [Global=(Bar1,Bar2)] interface Bar {}; - [Global=Baz2] interface Baz {}; + [Global, Exposed=Foo] interface Foo {}; + [Global=(Bar, Bar1,Bar2), Exposed=Bar] interface Bar {}; + [Global=(Baz, Baz2), Exposed=Baz] interface Baz {}; [Exposed=(Foo,Bar1)] interface Iface { @@ -51,10 +51,11 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse(""" - [PrimaryGlobal] interface Foo {}; - [Global=(Bar1,Bar2)] interface Bar {}; - [Global=Baz2] interface Baz {}; + [Global, Exposed=Foo] interface Foo {}; + [Global=(Bar, Bar1, Bar2), Exposed=Bar] interface Bar {}; + [Global=(Baz, Baz2), Exposed=Baz] interface Baz {}; + [Exposed=Foo] interface Iface2 { void method3(); }; @@ -80,9 +81,9 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse(""" - [PrimaryGlobal] interface Foo {}; - [Global=(Bar1,Bar2)] interface Bar {}; - [Global=Baz2] interface Baz {}; + [Global, Exposed=Foo] interface Foo {}; + [Global=(Bar, Bar1, Bar2), Exposed=Bar] interface Bar {}; + [Global=(Baz, Baz2), Exposed=Baz] interface Baz {}; [Exposed=Foo] interface Iface3 { @@ -90,11 +91,11 @@ def WebIDLTest(parser, harness): }; [Exposed=(Foo,Bar1)] - interface Mixin { + interface mixin Mixin { void method5(); }; - Iface3 implements Mixin; + Iface3 includes Mixin; """) results = parser.finish() harness.check(len(results), 6, "Should know about six things"); @@ -181,8 +182,8 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [Global] interface Foo {}; - [Global] interface Bar {}; + [Global, Exposed=Foo] interface Foo {}; + [Global, Exposed=Bar] interface Bar {}; [Exposed=Foo] interface Baz { @@ -198,25 +199,40 @@ def WebIDLTest(parser, harness): harness.ok(threw, "Should have thrown on member exposed where its interface is not.") parser = parser.reset() - threw = False - try: - parser.parse(""" - [Global] interface Foo {}; - [Global] interface Bar {}; + parser.parse(""" + [Global, Exposed=Foo] interface Foo {}; + [Global, Exposed=Bar] interface Bar {}; - [Exposed=Foo] - interface Baz { - void method(); - }; + [Exposed=Foo] + interface Baz { + void method(); + }; - [Exposed=Bar] - interface Mixin {}; + [Exposed=Bar] + interface mixin Mixin { + void otherMethod(); + }; - Baz implements Mixin; - """) + Baz includes Mixin; + """) + + results = parser.finish() + + harness.check(len(results), 5, "Should know about five things"); + iface = results[2] + harness.ok(isinstance(iface, WebIDL.IDLInterface), + "Should have an interface here"); + members = iface.members + harness.check(len(members), 2, "Should have two members") + + harness.ok(members[0].exposureSet == set(["Foo"]), + "method should have the right exposure set") + harness.ok(members[0]._exposureGlobalNames == set(["Foo"]), + "method should have the right exposure global names") + + harness.ok(members[1].exposureSet == set(["Bar"]), + "otherMethod should have the right exposure set") + harness.ok(members[1]._exposureGlobalNames == set(["Bar"]), + "otherMethod should have the right exposure global names") - results = parser.finish() - except Exception as x: - threw = True - harness.ok(threw, "Should have thrown on LHS of implements being exposed where RHS is not.") diff --git a/components/script/dom/bindings/codegen/parser/tests/test_global_extended_attr.py b/components/script/dom/bindings/codegen/parser/tests/test_global_extended_attr.py index bc20da40bbe..28b79642d86 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_global_extended_attr.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_global_extended_attr.py @@ -1,9 +1,10 @@ def WebIDLTest(parser, harness): parser.parse(""" - [Global] + [Global, Exposed=Foo] interface Foo : Bar { getter any(DOMString name); }; + [Exposed=Foo] interface Bar {}; """) @@ -18,7 +19,7 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [Global] + [Global, Exposed=Foo] interface Foo { getter any(DOMString name); setter void(DOMString name, any arg); @@ -36,7 +37,7 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [Global] + [Global, Exposed=Foo] interface Foo { getter any(DOMString name); deleter void(DOMString name); @@ -54,7 +55,7 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [Global, OverrideBuiltins] + [Global, OverrideBuiltins, Exposed=Foo] interface Foo { }; """) @@ -70,10 +71,10 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [Global] + [Global, Exposed=Foo] interface Foo : Bar { }; - [OverrideBuiltins] + [OverrideBuiltins, Exposed=Foo] interface Bar { }; """) @@ -89,9 +90,10 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [Global] + [Global, Exposed=Foo] interface Foo { }; + [Exposed=Foo] interface Bar : Foo { }; """) diff --git a/components/script/dom/bindings/codegen/parser/tests/test_implements.py b/components/script/dom/bindings/codegen/parser/tests/test_implements.py deleted file mode 100644 index 04c47d92abe..00000000000 --- a/components/script/dom/bindings/codegen/parser/tests/test_implements.py +++ /dev/null @@ -1,216 +0,0 @@ -# Import the WebIDL module, so we can do isinstance checks and whatnot -import WebIDL - -def WebIDLTest(parser, harness): - # Basic functionality - threw = False - try: - parser.parse(""" - A implements B; - interface B { - attribute long x; - }; - interface A { - attribute long y; - }; - """) - results = parser.finish() - except: - threw = True - - harness.ok(not threw, "Should not have thrown on implements statement " - "before interfaces") - harness.check(len(results), 3, "We have three statements") - harness.ok(isinstance(results[1], WebIDL.IDLInterface), "B is an interface") - harness.check(len(results[1].members), 1, "B has one member") - A = results[2] - harness.ok(isinstance(A, WebIDL.IDLInterface), "A is an interface") - harness.check(len(A.members), 2, "A has two members") - harness.check(A.members[0].identifier.name, "y", "First member is 'y'") - harness.check(A.members[1].identifier.name, "x", "Second member is 'x'") - - # Duplicated member names not allowed - threw = False - try: - parser.parse(""" - C implements D; - interface D { - attribute long x; - }; - interface C { - attribute long x; - }; - """) - parser.finish() - except: - threw = True - - harness.ok(threw, "Should have thrown on implemented interface duplicating " - "a name on base interface") - - # Same, but duplicated across implemented interfaces - threw = False - try: - parser.parse(""" - E implements F; - E implements G; - interface F { - attribute long x; - }; - interface G { - attribute long x; - }; - interface E {}; - """) - parser.finish() - except: - threw = True - - harness.ok(threw, "Should have thrown on implemented interfaces " - "duplicating each other's member names") - - # Same, but duplicated across indirectly implemented interfaces - threw = False - try: - parser.parse(""" - H implements I; - H implements J; - I implements K; - interface K { - attribute long x; - }; - interface L { - attribute long x; - }; - interface I {}; - interface J : L {}; - interface H {}; - """) - parser.finish() - except: - threw = True - - harness.ok(threw, "Should have thrown on indirectly implemented interfaces " - "duplicating each other's member names") - - # Same, but duplicated across an implemented interface and its parent - threw = False - try: - parser.parse(""" - M implements N; - interface O { - attribute long x; - }; - interface N : O { - attribute long x; - }; - interface M {}; - """) - parser.finish() - except: - threw = True - - harness.ok(threw, "Should have thrown on implemented interface and its " - "ancestor duplicating member names") - - # Reset the parser so we can actually find things where we expect - # them in the list - parser = parser.reset() - - # Diamonds should be allowed - threw = False - try: - parser.parse(""" - P implements Q; - P implements R; - Q implements S; - R implements S; - interface Q {}; - interface R {}; - interface S { - attribute long x; - }; - interface P {}; - """) - results = parser.finish() - except: - threw = True - - harness.ok(not threw, "Diamond inheritance is fine") - harness.check(results[6].identifier.name, "S", "We should be looking at 'S'") - harness.check(len(results[6].members), 1, "S should have one member") - harness.check(results[6].members[0].identifier.name, "x", - "S's member should be 'x'") - - parser = parser.reset() - threw = False - try: - parser.parse(""" - interface TestInterface { - }; - callback interface TestCallbackInterface { - }; - TestInterface implements TestCallbackInterface; - """) - results = parser.finish() - except: - threw = True - - harness.ok(threw, - "Should not allow callback interfaces on the right-hand side " - "of 'implements'") - - parser = parser.reset() - threw = False - try: - parser.parse(""" - interface TestInterface { - }; - callback interface TestCallbackInterface { - }; - TestCallbackInterface implements TestInterface; - """) - results = parser.finish() - except: - threw = True - - harness.ok(threw, - "Should not allow callback interfaces on the left-hand side of " - "'implements'") - - parser = parser.reset() - threw = False - try: - parser.parse(""" - interface TestInterface { - }; - dictionary Dict { - }; - Dict implements TestInterface; - """) - results = parser.finish() - except: - threw = True - - harness.ok(threw, - "Should not allow non-interfaces on the left-hand side " - "of 'implements'") - - parser = parser.reset() - threw = False - try: - parser.parse(""" - interface TestInterface { - }; - dictionary Dict { - }; - TestInterface implements Dict; - """) - results = parser.finish() - except: - threw = True - - harness.ok(threw, - "Should not allow non-interfaces on the right-hand side " - "of 'implements'") - diff --git a/components/script/dom/bindings/codegen/parser/tests/test_interface.py b/components/script/dom/bindings/codegen/parser/tests/test_interface.py index 28e6af94597..47db3ae4cc9 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_interface.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_interface.py @@ -84,100 +84,6 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - interface A {}; - interface B {}; - A implements B; - B implements A; - """) - results = parser.finish() - except: - threw = True - - harness.ok(threw, "Should not allow cycles via implements") - - parser = parser.reset() - threw = False - try: - parser.parse(""" - interface A {}; - interface C {}; - interface B {}; - A implements C; - C implements B; - B implements A; - """) - results = parser.finish() - except: - threw = True - - harness.ok(threw, "Should not allow indirect cycles via implements") - - parser = parser.reset() - threw = False - try: - parser.parse(""" - interface A : B {}; - interface B {}; - B implements A; - """) - results = parser.finish() - except: - threw = True - - harness.ok(threw, "Should not allow inheriting from an interface that implements us") - - parser = parser.reset() - threw = False - try: - parser.parse(""" - interface A : B {}; - interface B {}; - interface C {}; - B implements C; - C implements A; - """) - results = parser.finish() - except: - threw = True - - harness.ok(threw, "Should not allow inheriting from an interface that indirectly implements us") - - parser = parser.reset() - threw = False - try: - parser.parse(""" - interface A : B {}; - interface B : C {}; - interface C {}; - C implements A; - """) - results = parser.finish() - except: - threw = True - - harness.ok(threw, "Should not allow indirectly inheriting from an interface that implements us") - - parser = parser.reset() - threw = False - try: - parser.parse(""" - interface A : B {}; - interface B : C {}; - interface C {}; - interface D {}; - C implements D; - D implements A; - """) - results = parser.finish() - except: - threw = True - - harness.ok(threw, "Should not allow indirectly inheriting from an interface that indirectly implements us") - - parser = parser.reset() - threw = False - try: - parser.parse(""" interface A; interface B : A {}; """) @@ -377,7 +283,7 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse(""" - [Global] interface Window {}; + [Global, Exposed=Window] interface Window {}; [Exposed=Window, LegacyWindowAlias=A] interface B {}; [Exposed=Window, LegacyWindowAlias=(C, D)] @@ -419,7 +325,8 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [Global] interface Window {}; + [Global, Exposed=Window] interface Window {}; + [Exposed=Window] interface A {}; [Exposed=Window, LegacyWindowAlias=A] interface B {}; @@ -434,9 +341,10 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [Global] interface Window {}; + [Global, Exposed=Window] interface Window {}; [Exposed=Window, LegacyWindowAlias=A] interface B {}; + [Exposed=Window] interface A {}; """) results = parser.finish() @@ -449,7 +357,7 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - [Global] interface Window {}; + [Global, Exposed=Window] interface Window {}; [Exposed=Window, LegacyWindowAlias=A] interface B {}; [Exposed=Window, LegacyWindowAlias=A] diff --git a/components/script/dom/bindings/codegen/parser/tests/test_interface_maplikesetlikeiterable.py b/components/script/dom/bindings/codegen/parser/tests/test_interface_maplikesetlikeiterable.py index 5de2e02af7e..e070adee7e6 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_interface_maplikesetlikeiterable.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_interface_maplikesetlikeiterable.py @@ -252,16 +252,6 @@ def WebIDLTest(parser, harness): }; """, mapRWMembers, numProductions=2) - shouldPass("Implements with maplike/setlike", - """ - interface Foo1 { - maplike<long, long>; - }; - interface Foo2 { - }; - Foo2 implements Foo1; - """, mapRWMembers, numProductions=3) - shouldPass("JS Implemented maplike interface", """ [JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1"] @@ -350,31 +340,6 @@ def WebIDLTest(parser, harness): }; """) - shouldFail("Consequential interface with conflicting maplike/setlike", - """ - interface Foo1 { - maplike<long, long>; - }; - interface Foo2 { - setlike<long>; - }; - Foo2 implements Foo1; - """) - - shouldFail("Consequential interfaces with conflicting maplike/setlike", - """ - interface Foo1 { - maplike<long, long>; - }; - interface Foo2 { - setlike<long>; - }; - interface Foo3 { - }; - Foo3 implements Foo1; - Foo3 implements Foo2; - """) - # # Member name collision tests # @@ -477,52 +442,28 @@ def WebIDLTest(parser, harness): }; """, mapRWMembers, numProductions=3) - shouldFail("Interface with consequential maplike/setlike interface member collision", - """ - interface Foo1 { - void entries(); - }; - interface Foo2 { - maplike<long, long>; - }; - Foo1 implements Foo2; - """) - - shouldFail("Maplike interface with consequential interface member collision", + shouldFail("Maplike interface with mixin member collision", """ interface Foo1 { maplike<long, long>; }; - interface Foo2 { + interface mixin Foo2 { void entries(); }; - Foo1 implements Foo2; + Foo1 includes Foo2; """) - shouldPass("Consequential Maplike interface with inherited interface member collision", - """ - interface Foo1 { - maplike<long, long>; - }; - interface Foo2 { - void entries(); - }; - interface Foo3 : Foo2 { - }; - Foo3 implements Foo1; - """, mapRWMembers, numProductions=4) - shouldPass("Inherited Maplike interface with consequential interface member collision", """ interface Foo1 { maplike<long, long>; }; - interface Foo2 { + interface mixin Foo2 { void entries(); }; interface Foo3 : Foo1 { }; - Foo3 implements Foo2; + Foo3 includes Foo2; """, mapRWMembers, numProductions=4) shouldFail("Inheritance of name collision with child maplike/setlike", @@ -645,7 +586,7 @@ def WebIDLTest(parser, harness): }; """) - shouldPass("Implemented interface with readonly allowable overrides", + shouldPass("Interface with readonly allowable overrides", """ interface Foo1 { readonly setlike<long>; diff --git a/components/script/dom/bindings/codegen/parser/tests/test_interfacemixin.py b/components/script/dom/bindings/codegen/parser/tests/test_interfacemixin.py index ae3400d2cdb..477a9f37799 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_interfacemixin.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_interfacemixin.py @@ -338,9 +338,47 @@ def WebIDLTest(parser, harness): "Should fail if an interface mixin includes maplike") parser = parser.reset() + threw = False + try: + parser.parse(""" + interface Interface { + attribute short attr; + }; + interface mixin Mixin { + attribute short attr; + }; + Interface includes Mixin; + """) + results = parser.finish() + except: + threw = True + harness.ok(threw, + "Should fail if the included mixin interface has duplicated member") + + parser = parser.reset() + threw = False + try: + parser.parse(""" + interface Interface {}; + interface mixin Mixin1 { + attribute short attr; + }; + interface mixin Mixin2 { + attribute short attr; + }; + Interface includes Mixin1; + Interface includes Mixin2; + """) + results = parser.finish() + except: + threw = True + harness.ok(threw, + "Should fail if the included mixin interfaces have duplicated member") + + parser = parser.reset() parser.parse(""" - [Global] interface Window {}; - [Global] interface Worker {}; + [Global, Exposed=Window] interface Window {}; + [Global, Exposed=Worker] interface Worker {}; [Exposed=Window] interface Base {}; interface mixin Mixin { @@ -356,8 +394,8 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse(""" - [Global] interface Window {}; - [Global] interface Worker {}; + [Global, Exposed=Window] interface Window {}; + [Global, Exposed=Worker] interface Worker {}; [Exposed=Window] interface Base {}; [Exposed=Window] @@ -371,3 +409,29 @@ def WebIDLTest(parser, harness): attr = base.members[0] harness.check(attr.exposureSet, set(["Window"]), "Should follow [Exposed] on interface mixin") + + parser = parser.reset() + parser.parse(""" + [Global, Exposed=Window] interface Window {}; + [Global, Exposed=Worker] interface Worker {}; + [Exposed=Window] + interface Base1 {}; + [Exposed=Worker] + interface Base2 {}; + interface mixin Mixin { + attribute short a; + }; + Base1 includes Mixin; + Base2 includes Mixin; + """) + results = parser.finish() + base = results[2] + attr = base.members[0] + harness.check(attr.exposureSet, set(["Window", "Worker"]), + "Should expose on all globals where including interfaces are " + "exposed") + base = results[3] + attr = base.members[0] + harness.check(attr.exposureSet, set(["Window", "Worker"]), + "Should expose on all globals where including interfaces are " + "exposed") diff --git a/components/script/dom/bindings/codegen/parser/tests/test_securecontext_extended_attribute.py b/components/script/dom/bindings/codegen/parser/tests/test_securecontext_extended_attribute.py index 084f19fa7f5..442dba45d76 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_securecontext_extended_attribute.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_securecontext_extended_attribute.py @@ -288,33 +288,32 @@ def WebIDLTest(parser, harness): threw = True harness.ok(threw, "[SecureContext] must appear on interfaces that inherit from another [SecureContext] interface") - # Test 'implements'. The behavior tested here may have to change depending - # on the resolution of https://github.com/heycam/webidl/issues/118 + # Test 'includes'. parser = parser.reset() parser.parse(""" [SecureContext] - interface TestSecureContextInterfaceThatImplementsNonSecureContextInterface { + interface TestSecureContextInterfaceThatIncludesNonSecureContextMixin { const octet TEST_CONSTANT = 0; }; - interface TestNonSecureContextInterface { + interface mixin TestNonSecureContextMixin { const octet TEST_CONSTANT_2 = 0; readonly attribute byte testAttribute2; void testMethod2(byte foo); }; - TestSecureContextInterfaceThatImplementsNonSecureContextInterface implements TestNonSecureContextInterface; + TestSecureContextInterfaceThatIncludesNonSecureContextMixin includes TestNonSecureContextMixin; """) results = parser.finish() - harness.check(len(results[0].members), 4, "TestSecureContextInterfaceThatImplementsNonSecureContextInterface should have two members") + harness.check(len(results[0].members), 4, "TestSecureContextInterfaceThatImplementsNonSecureContextInterface should have four members") harness.ok(results[0].getExtendedAttribute("SecureContext"), "Interface should have [SecureContext] extended attribute") 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") harness.ok(results[0].members[1].getExtendedAttribute("SecureContext") is None, - "Constants copied from non-[SecureContext] interface should not be [SecureContext]") + "Constants copied from non-[SecureContext] mixin should not be [SecureContext]") harness.ok(results[0].members[2].getExtendedAttribute("SecureContext") is None, - "Attributes copied from non-[SecureContext] interface should not be [SecureContext]") + "Attributes copied from non-[SecureContext] mixin should not be [SecureContext]") harness.ok(results[0].members[3].getExtendedAttribute("SecureContext") is None, - "Methods copied from non-[SecureContext] interface should not be [SecureContext]") + "Methods copied from non-[SecureContext] mixin should not be [SecureContext]") # Test SecureContext and NoInterfaceObject parser = parser.reset() diff --git a/components/script/dom/bindings/codegen/parser/tests/test_unforgeable.py b/components/script/dom/bindings/codegen/parser/tests/test_unforgeable.py index 44a168670ed..770a9d3736f 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_unforgeable.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_unforgeable.py @@ -141,16 +141,16 @@ def WebIDLTest(parser, harness): interface Child : Parent { }; interface Parent {}; - interface Consequential { + interface mixin Mixin { [Unforgeable] readonly attribute long foo; }; - Parent implements Consequential; + Parent includes Mixin; """) results = parser.finish() harness.check(len(results), 4, "Should be able to inherit from an interface with a " - "consequential interface with [Unforgeable] properties.") + "mixin with [Unforgeable] properties.") parser = parser.reset(); threw = False @@ -160,10 +160,10 @@ def WebIDLTest(parser, harness): void foo(); }; interface Parent {}; - interface Consequential { + interface mixin Mixin { [Unforgeable] readonly attribute long foo; }; - Parent implements Consequential; + Parent includes Mixin; """) results = parser.finish() @@ -182,14 +182,14 @@ def WebIDLTest(parser, harness): }; interface Parent : GrandParent {}; interface GrandParent {}; - interface Consequential { + interface mixin Mixin { [Unforgeable] readonly attribute long foo; }; - GrandParent implements Consequential; - interface ChildConsequential { + GrandParent includes Mixin; + interface mixin ChildMixin { void foo(); }; - Child implements ChildConsequential; + Child includes ChildMixin; """) results = parser.finish() @@ -208,14 +208,14 @@ def WebIDLTest(parser, harness): }; interface Parent : GrandParent {}; interface GrandParent {}; - interface Consequential { + interface mixin Mixin { [Unforgeable] void foo(); }; - GrandParent implements Consequential; - interface ChildConsequential { + GrandParent includes Mixin; + interface mixin ChildMixin { void foo(); }; - Child implements ChildConsequential; + Child includes ChildMixin; """) results = parser.finish() |