aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/parser/tests/test_dictionary.py
diff options
context:
space:
mode:
authorKagami Sascha Rosylight <saschanaz@outlook.com>2019-07-11 13:16:10 +0900
committerKagami Sascha Rosylight <saschanaz@outlook.com>2019-07-12 12:14:06 +0900
commit56f31c85ef9cc79140f375641302310c6680ded4 (patch)
treefc0616a5f5d1df4434e9974e5bc62db2389ffcef /components/script/dom/bindings/codegen/parser/tests/test_dictionary.py
parent5fdc7c0d2c787ef562809072e3dd7c3258dc8a83 (diff)
downloadservo-56f31c85ef9cc79140f375641302310c6680ded4.tar.gz
servo-56f31c85ef9cc79140f375641302310c6680ded4.zip
Sync WebIDL.py with gecko
Diffstat (limited to 'components/script/dom/bindings/codegen/parser/tests/test_dictionary.py')
-rw-r--r--components/script/dom/bindings/codegen/parser/tests/test_dictionary.py82
1 files changed, 80 insertions, 2 deletions
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 361b83ea52b..770f76b22f0 100644
--- a/components/script/dom/bindings/codegen/parser/tests/test_dictionary.py
+++ b/components/script/dom/bindings/codegen/parser/tests/test_dictionary.py
@@ -174,6 +174,22 @@ def WebIDLTest(parser, harness):
dictionary A {
};
interface X {
+ void doFoo(optional A arg);
+ };
+ """)
+ results = parser.finish()
+ except:
+ threw = True
+
+ harness.ok(threw, "Trailing dictionary arg must have a default value")
+
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse("""
+ dictionary A {
+ };
+ interface X {
void doFoo((A or DOMString) arg);
};
""")
@@ -191,6 +207,23 @@ def WebIDLTest(parser, harness):
dictionary A {
};
interface X {
+ void doFoo(optional (A or DOMString) arg);
+ };
+ """)
+ results = parser.finish()
+ except:
+ threw = True
+
+ harness.ok(threw,
+ "Trailing union arg containing a dictionary must have a default value")
+
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse("""
+ dictionary A {
+ };
+ interface X {
void doFoo(A arg1, optional long arg2);
};
""")
@@ -207,6 +240,22 @@ def WebIDLTest(parser, harness):
dictionary A {
};
interface X {
+ void doFoo(optional A arg1, optional long arg2);
+ };
+ """)
+ results = parser.finish()
+ except:
+ threw = True
+
+ harness.ok(threw, "Dictionary arg followed by optional arg must have default value")
+
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse("""
+ dictionary A {
+ };
+ interface X {
void doFoo(A arg1, optional long arg2, long arg3);
};
""")
@@ -236,6 +285,24 @@ def WebIDLTest(parser, harness):
"be optional")
parser = parser.reset()
+ threw = False
+ try:
+ parser.parse("""
+ dictionary A {
+ };
+ interface X {
+ void doFoo(optional (A or DOMString) arg1, optional long arg2);
+ };
+ """)
+ results = parser.finish()
+ except:
+ threw = True
+
+ harness.ok(threw,
+ "Union arg containing dictionary followed by optional arg must "
+ "have a default value")
+
+ parser = parser.reset()
parser.parse("""
dictionary A {
};
@@ -326,7 +393,7 @@ def WebIDLTest(parser, harness):
dictionary A {
};
interface X {
- void doFoo(optional A arg);
+ void doFoo(optional A arg = {});
};
""")
results = parser.finish()
@@ -337,13 +404,24 @@ def WebIDLTest(parser, harness):
dictionary A {
};
interface X {
- void doFoo(optional (A or DOMString) arg);
+ void doFoo(optional (A or DOMString) arg = {});
};
""")
results = parser.finish()
harness.ok(True, "Union arg containing a dictionary should actually parse")
parser = parser.reset()
+ parser.parse("""
+ dictionary A {
+ };
+ interface X {
+ void doFoo(optional (A or DOMString) arg = "abc");
+ };
+ """)
+ results = parser.finish()
+ harness.ok(True, "Union arg containing a dictionary with string default should actually parse")
+
+ parser = parser.reset()
threw = False
try:
parser.parse("""