diff options
Diffstat (limited to 'components/script/dom/bindings/codegen/parser/tests/test_constructor.py')
-rw-r--r-- | components/script/dom/bindings/codegen/parser/tests/test_constructor.py | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/components/script/dom/bindings/codegen/parser/tests/test_constructor.py b/components/script/dom/bindings/codegen/parser/tests/test_constructor.py index 6ec1be1871b..348204c7dc1 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_constructor.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_constructor.py @@ -11,8 +11,9 @@ def WebIDLTest(parser, harness): harness.check(argument.variadic, variadic, "Argument has the right variadic value") def checkMethod(method, QName, name, signatures, - static=False, getter=False, setter=False, creator=False, - deleter=False, legacycaller=False, stringifier=False): + static=True, getter=False, setter=False, creator=False, + deleter=False, legacycaller=False, stringifier=False, + chromeOnly=False): harness.ok(isinstance(method, WebIDL.IDLMethod), "Should be an IDLMethod") harness.ok(method.isMethod(), "Method is a method") @@ -27,6 +28,7 @@ def WebIDLTest(parser, harness): harness.check(method.isDeleter(), deleter, "Method has the correct deleter value") harness.check(method.isLegacycaller(), legacycaller, "Method has the correct legacycaller value") harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value") + harness.check(method.getExtendedAttribute("ChromeOnly") is not None, chromeOnly, "Method has the correct value for ChromeOnly") harness.check(len(method.signatures()), len(signatures), "Method has the correct number of signatures") sigpairs = zip(method.signatures(), signatures) @@ -55,11 +57,13 @@ def WebIDLTest(parser, harness): }; """) results = parser.finish() - harness.check(len(results), 3, "Should be two productions") + harness.check(len(results), 3, "Should be three productions") harness.ok(isinstance(results[0], WebIDL.IDLInterface), "Should be an IDLInterface") harness.ok(isinstance(results[1], WebIDL.IDLInterface), "Should be an IDLInterface") + harness.ok(isinstance(results[2], WebIDL.IDLInterface), + "Should be an IDLInterface") checkMethod(results[0].ctor(), "::TestConstructorNoArgs::constructor", "constructor", [("TestConstructorNoArgs (Wrapper)", [])]) @@ -73,3 +77,33 @@ def WebIDLTest(parser, harness): [("::TestConstructorOverloads::constructor::foo", "foo", "Object", False, False)]), ("TestConstructorOverloads (Wrapper)", [("::TestConstructorOverloads::constructor::bar", "bar", "Boolean", False, False)])]) + + parser = parser.reset() + parser.parse(""" + [ChromeConstructor()] + interface TestChromeConstructor { + }; + """) + results = parser.finish() + harness.check(len(results), 1, "Should be one production") + harness.ok(isinstance(results[0], WebIDL.IDLInterface), + "Should be an IDLInterface") + + checkMethod(results[0].ctor(), "::TestChromeConstructor::constructor", + "constructor", [("TestChromeConstructor (Wrapper)", [])], + chromeOnly=True) + + parser = parser.reset() + threw = False + try: + parser.parse(""" + [Constructor(), + ChromeConstructor(DOMString a)] + interface TestChromeConstructor { + }; + """) + results = parser.finish() + except: + threw = True + + harness.ok(threw, "Can't have both a Constructor and a ChromeConstructor") |