aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/parser/tests/test_unforgeable.py
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-05-09 05:04:57 -0700
committerbors-servo <lbergstrom+bors@mozilla.com>2016-05-09 05:04:57 -0700
commitb054cb82a6b50b07209c9a8670076d1d9ed61605 (patch)
treea37a6d2a58efa219e7820b67de5ed3af44ab2191 /components/script/dom/bindings/codegen/parser/tests/test_unforgeable.py
parent9a8c81773a7dc51301e52ce3f02f8ea55984365a (diff)
parentd3528ffce4092e0b28b9494f96555368bf8945b9 (diff)
downloadservo-b054cb82a6b50b07209c9a8670076d1d9ed61605.tar.gz
servo-b054cb82a6b50b07209c9a8670076d1d9ed61605.zip
Auto merge of #9890 - AgostonSzepessy:update-webidl-tests, r=nox
update.sh downloads all *.py tests from mozilla central components/script/dom/bindings/codegen/parser/update.sh downloads all *.py tests from https://dxr.mozilla.org/mozilla-central/source/dom/bindings/parser/tests <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9890) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bindings/codegen/parser/tests/test_unforgeable.py')
-rw-r--r--components/script/dom/bindings/codegen/parser/tests/test_unforgeable.py253
1 files changed, 253 insertions, 0 deletions
diff --git a/components/script/dom/bindings/codegen/parser/tests/test_unforgeable.py b/components/script/dom/bindings/codegen/parser/tests/test_unforgeable.py
new file mode 100644
index 00000000000..3787e8c6af1
--- /dev/null
+++ b/components/script/dom/bindings/codegen/parser/tests/test_unforgeable.py
@@ -0,0 +1,253 @@
+def WebIDLTest(parser, harness):
+ parser.parse("""
+ interface Child : Parent {
+ };
+ interface Parent {
+ [Unforgeable] readonly attribute long foo;
+ };
+ """)
+
+ results = parser.finish()
+ harness.check(len(results), 2,
+ "Should be able to inherit from an interface with "
+ "[Unforgeable] properties.")
+
+ parser = parser.reset();
+ parser.parse("""
+ interface Child : Parent {
+ const short foo = 10;
+ };
+ interface Parent {
+ [Unforgeable] readonly attribute long foo;
+ };
+ """)
+
+ results = parser.finish()
+ harness.check(len(results), 2,
+ "Should be able to inherit from an interface with "
+ "[Unforgeable] properties even if we have a constant with "
+ "the same name.")
+
+ parser = parser.reset();
+ parser.parse("""
+ interface Child : Parent {
+ static attribute short foo;
+ };
+ interface Parent {
+ [Unforgeable] readonly attribute long foo;
+ };
+ """)
+
+ results = parser.finish()
+ harness.check(len(results), 2,
+ "Should be able to inherit from an interface with "
+ "[Unforgeable] properties even if we have a static attribute "
+ "with the same name.")
+
+ parser = parser.reset();
+ parser.parse("""
+ interface Child : Parent {
+ static void foo();
+ };
+ interface Parent {
+ [Unforgeable] readonly attribute long foo;
+ };
+ """)
+
+ results = parser.finish()
+ harness.check(len(results), 2,
+ "Should be able to inherit from an interface with "
+ "[Unforgeable] properties even if we have a static operation "
+ "with the same name.")
+
+ parser = parser.reset();
+ threw = False
+ try:
+ parser.parse("""
+ interface Child : Parent {
+ void foo();
+ };
+ interface Parent {
+ [Unforgeable] readonly attribute long foo;
+ };
+ """)
+
+ results = parser.finish()
+ except:
+ threw = True
+ harness.ok(threw,
+ "Should have thrown when shadowing unforgeable attribute on "
+ "parent with operation.")
+
+ parser = parser.reset();
+ threw = False
+ try:
+ parser.parse("""
+ interface Child : Parent {
+ void foo();
+ };
+ interface Parent {
+ [Unforgeable] void foo();
+ };
+ """)
+
+ results = parser.finish()
+ except:
+ threw = True
+ harness.ok(threw,
+ "Should have thrown when shadowing unforgeable operation on "
+ "parent with operation.")
+
+ parser = parser.reset();
+ threw = False
+ try:
+ parser.parse("""
+ interface Child : Parent {
+ attribute short foo;
+ };
+ interface Parent {
+ [Unforgeable] readonly attribute long foo;
+ };
+ """)
+
+ results = parser.finish()
+ except Exception,x:
+ threw = True
+ harness.ok(threw,
+ "Should have thrown when shadowing unforgeable attribute on "
+ "parent with attribute.")
+
+ parser = parser.reset();
+ threw = False
+ try:
+ parser.parse("""
+ interface Child : Parent {
+ attribute short foo;
+ };
+ interface Parent {
+ [Unforgeable] void foo();
+ };
+ """)
+
+ results = parser.finish()
+ except Exception,x:
+ threw = True
+ harness.ok(threw,
+ "Should have thrown when shadowing unforgeable operation on "
+ "parent with attribute.")
+
+ parser = parser.reset();
+ parser.parse("""
+ interface Child : Parent {
+ };
+ interface Parent {};
+ interface Consequential {
+ [Unforgeable] readonly attribute long foo;
+ };
+ Parent implements Consequential;
+ """)
+
+ results = parser.finish()
+ harness.check(len(results), 4,
+ "Should be able to inherit from an interface with a "
+ "consequential interface with [Unforgeable] properties.")
+
+ parser = parser.reset();
+ threw = False
+ try:
+ parser.parse("""
+ interface Child : Parent {
+ void foo();
+ };
+ interface Parent {};
+ interface Consequential {
+ [Unforgeable] readonly attribute long foo;
+ };
+ Parent implements Consequential;
+ """)
+
+ results = parser.finish()
+ except:
+ threw = True
+
+ harness.ok(threw,
+ "Should have thrown when shadowing unforgeable attribute "
+ "of parent's consequential interface.")
+
+ parser = parser.reset();
+ threw = False
+ try:
+ parser.parse("""
+ interface Child : Parent {
+ };
+ interface Parent : GrandParent {};
+ interface GrandParent {};
+ interface Consequential {
+ [Unforgeable] readonly attribute long foo;
+ };
+ GrandParent implements Consequential;
+ interface ChildConsequential {
+ void foo();
+ };
+ Child implements ChildConsequential;
+ """)
+
+ results = parser.finish()
+ except:
+ threw = True
+
+ harness.ok(threw,
+ "Should have thrown when our consequential interface shadows unforgeable attribute "
+ "of ancestor's consequential interface.")
+
+ parser = parser.reset();
+ threw = False
+ try:
+ parser.parse("""
+ interface Child : Parent {
+ };
+ interface Parent : GrandParent {};
+ interface GrandParent {};
+ interface Consequential {
+ [Unforgeable] void foo();
+ };
+ GrandParent implements Consequential;
+ interface ChildConsequential {
+ void foo();
+ };
+ Child implements ChildConsequential;
+ """)
+
+ results = parser.finish()
+ except:
+ threw = True
+
+ harness.ok(threw,
+ "Should have thrown when our consequential interface shadows unforgeable operation "
+ "of ancestor's consequential interface.")
+
+ parser = parser.reset();
+ parser.parse("""
+ interface iface {
+ [Unforgeable] attribute long foo;
+ };
+ """)
+
+ results = parser.finish()
+ harness.check(len(results), 1,
+ "Should allow writable [Unforgeable] attribute.")
+
+ parser = parser.reset();
+ threw = False
+ try:
+ parser.parse("""
+ interface iface {
+ [Unforgeable] static readonly attribute long foo;
+ };
+ """)
+
+ results = parser.finish()
+ except:
+ threw = True
+
+ harness.ok(threw, "Should have thrown for static [Unforgeable] attribute.")