aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/parser/tests/test_constructor.py
diff options
context:
space:
mode:
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.py207
1 files changed, 147 insertions, 60 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 c722d7bc5c7..20eb152cdab 100644
--- a/components/script/dom/bindings/codegen/parser/tests/test_constructor.py
+++ b/components/script/dom/bindings/codegen/parser/tests/test_constructor.py
@@ -43,45 +43,55 @@ def WebIDLTest(parser, harness):
(QName, name, type, optional, variadic) = expectedArgs[i]
checkArgument(gotArgs[i], QName, name, type, optional, variadic)
+ def checkResults(results):
+ 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)", [])])
+ harness.check(len(results[0].members), 0,
+ "TestConstructorNoArgs should not have members")
+ checkMethod(results[1].ctor(), "::TestConstructorWithArgs::constructor",
+ "constructor",
+ [("TestConstructorWithArgs (Wrapper)",
+ [("::TestConstructorWithArgs::constructor::name", "name", "String", False, False)])])
+ harness.check(len(results[1].members), 0,
+ "TestConstructorWithArgs should not have members")
+ checkMethod(results[2].ctor(), "::TestConstructorOverloads::constructor",
+ "constructor",
+ [("TestConstructorOverloads (Wrapper)",
+ [("::TestConstructorOverloads::constructor::foo", "foo", "Object", False, False)]),
+ ("TestConstructorOverloads (Wrapper)",
+ [("::TestConstructorOverloads::constructor::bar", "bar", "Boolean", False, False)])])
+ harness.check(len(results[2].members), 0,
+ "TestConstructorOverloads should not have members")
+
parser.parse("""
- [Constructor]
interface TestConstructorNoArgs {
+ constructor();
};
- [Constructor(DOMString name)]
interface TestConstructorWithArgs {
+ constructor(DOMString name);
};
- [Constructor(object foo), Constructor(boolean bar)]
interface TestConstructorOverloads {
+ constructor(object foo);
+ constructor(boolean bar);
};
""")
results = parser.finish()
- 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)", [])])
- checkMethod(results[1].ctor(), "::TestConstructorWithArgs::constructor",
- "constructor",
- [("TestConstructorWithArgs (Wrapper)",
- [("::TestConstructorWithArgs::constructor::name", "name", "String", False, False)])])
- checkMethod(results[2].ctor(), "::TestConstructorOverloads::constructor",
- "constructor",
- [("TestConstructorOverloads (Wrapper)",
- [("::TestConstructorOverloads::constructor::foo", "foo", "Object", False, False)]),
- ("TestConstructorOverloads (Wrapper)",
- [("::TestConstructorOverloads::constructor::bar", "bar", "Boolean", False, False)])])
+ checkResults(results)
parser = parser.reset()
parser.parse("""
- [ChromeConstructor()]
- interface TestChromeConstructor {
+ interface TestChromeOnlyConstructor {
+ [ChromeOnly] constructor();
};
""")
results = parser.finish()
@@ -89,8 +99,8 @@ def WebIDLTest(parser, harness):
harness.ok(isinstance(results[0], WebIDL.IDLInterface),
"Should be an IDLInterface")
- checkMethod(results[0].ctor(), "::TestChromeConstructor::constructor",
- "constructor", [("TestChromeConstructor (Wrapper)", [])],
+ checkMethod(results[0].ctor(), "::TestChromeOnlyConstructor::constructor",
+ "constructor", [("TestChromeOnlyConstructor (Wrapper)", [])],
chromeOnly=True)
parser = parser.reset()
@@ -112,16 +122,16 @@ def WebIDLTest(parser, harness):
threw = False
try:
parser.parse("""
- [Constructor(),
- ChromeConstructor(DOMString a)]
- interface TestChromeConstructor {
+ interface TestChromeOnlyConstructor {
+ constructor()
+ [ChromeOnly] constructor(DOMString a);
};
""")
results = parser.finish()
except:
threw = True
- harness.ok(threw, "Can't have both a Constructor and a ChromeConstructor")
+ harness.ok(threw, "Can't have both a constructor and a ChromeOnly constructor")
# Test HTMLConstructor with argument
parser = parser.reset()
@@ -153,120 +163,197 @@ def WebIDLTest(parser, harness):
harness.ok(threw, "HTMLConstructor can't be used on a callback interface")
- # Test HTMLConstructor and Constructor
+ # Test HTMLConstructor and constructor operation
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse("""
+ [HTMLConstructor]
+ interface TestHTMLConstructorAndConstructor {
+ constructor();
+ };
+ """)
+ results = parser.finish()
+ except:
+ threw = True
+
+ harness.ok(threw, "Can't have both a constructor and a HTMLConstructor")
+
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse("""
+ [HTMLConstructor]
+ interface TestHTMLConstructorAndConstructor {
+ [Throws]
+ constructor();
+ };
+ """)
+ results = parser.finish()
+ except:
+ threw = True
+
+ harness.ok(threw,
+ "Can't have both a throwing constructor and a HTMLConstructor")
+
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse("""
+ [HTMLConstructor]
+ interface TestHTMLConstructorAndConstructor {
+ constructor(DOMString a);
+ };
+ """)
+ results = parser.finish()
+ except:
+ threw = True
+
+ harness.ok(threw,
+ "Can't have both a HTMLConstructor and a constructor operation")
+
parser = parser.reset()
threw = False
try:
parser.parse("""
- [Constructor,
- HTMLConstructor]
+ [HTMLConstructor]
interface TestHTMLConstructorAndConstructor {
+ [Throws]
+ constructor(DOMString a);
};
""")
results = parser.finish()
except:
threw = True
- harness.ok(threw, "Can't have both a Constructor and a HTMLConstructor")
+ harness.ok(threw,
+ "Can't have both a HTMLConstructor and a throwing constructor "
+ "operation")
+ # Test HTMLConstructor and [ChromeOnly] constructor operation
parser = parser.reset()
threw = False
try:
parser.parse("""
- [HTMLConstructor,
- Constructor]
+ [HTMLConstructor]
interface TestHTMLConstructorAndConstructor {
+ [ChromeOnly]
+ constructor();
};
""")
results = parser.finish()
except:
threw = True
- harness.ok(threw, "Can't have both a HTMLConstructor and a Constructor")
+ harness.ok(threw,
+ "Can't have both a ChromeOnly constructor and a HTMLConstructor")
parser = parser.reset()
threw = False
try:
parser.parse("""
- [HTMLConstructor,
- Constructor(DOMString a)]
+ [HTMLConstructor]
interface TestHTMLConstructorAndConstructor {
+ [Throws, ChromeOnly]
+ constructor();
};
""")
+ results = parser.finish()
except:
threw = True
- harness.ok(threw, "Can't have both a HTMLConstructor and a Constructor")
+ harness.ok(threw,
+ "Can't have both a throwing chromeonly constructor and a "
+ "HTMLConstructor")
parser = parser.reset()
threw = False
try:
parser.parse("""
- [Constructor(DOMString a),
- HTMLConstructor]
+ [HTMLConstructor]
interface TestHTMLConstructorAndConstructor {
+ [ChromeOnly]
+ constructor(DOMString a);
};
""")
+ results = parser.finish()
except:
threw = True
- harness.ok(threw, "Can't have both a HTMLConstructor and a Constructor")
+ harness.ok(threw,
+ "Can't have both a HTMLConstructor and a chromeonly constructor "
+ "operation")
- # Test HTMLConstructor and ChromeConstructor
parser = parser.reset()
threw = False
try:
parser.parse("""
- [ChromeConstructor,
- HTMLConstructor]
- interface TestHTMLConstructorAndChromeConstructor {
+ [HTMLConstructor]
+ interface TestHTMLConstructorAndConstructor {
+ [Throws, ChromeOnly]
+ constructor(DOMString a);
};
""")
results = parser.finish()
except:
threw = True
- harness.ok(threw, "Can't have both a HTMLConstructor and a ChromeConstructor")
+ harness.ok(threw,
+ "Can't have both a HTMLConstructor and a throwing chromeonly "
+ "constructor operation")
parser = parser.reset()
threw = False
try:
parser.parse("""
- [HTMLConstructor,
- ChromeConstructor]
- interface TestHTMLConstructorAndChromeConstructor {
+ [NoInterfaceObject]
+ interface InterfaceWithoutInterfaceObject {
+ constructor();
};
""")
results = parser.finish()
except:
threw = True
- harness.ok(threw, "Can't have both a HTMLConstructor and a ChromeConstructor")
+ harness.ok(threw,
+ "Can't have a constructor operation on a [NoInterfaceObject] "
+ "interface")
parser = parser.reset()
threw = False
try:
parser.parse("""
- [ChromeConstructor(DOMString a),
- HTMLConstructor]
- interface TestHTMLConstructorAndChromeConstructor {
+ interface InterfaceWithPartial {
+ };
+
+ partial interface InterfaceWithPartial {
+ constructor();
};
""")
results = parser.finish()
except:
threw = True
+ harness.ok(threw,
+ "Can't have a constructor operation on a partial interface")
+
parser = parser.reset()
threw = False
try:
parser.parse("""
- [HTMLConstructor,
- ChromeConstructor(DOMString a)]
- interface TestHTMLConstructorAndChromeConstructor {
+ interface InterfaceWithMixin {
};
+
+ interface mixin Mixin {
+ constructor();
+ };
+
+ InterfaceWithMixin includes Mixin
""")
results = parser.finish()
except:
threw = True
- harness.ok(threw, "Can't have both a HTMLConstructor and a ChromeConstructor")
+ harness.ok(threw,
+ "Can't have a constructor operation on a mixin")
+