dom/bindings/parser/tests/test_global_extended_attr.py

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 def WebIDLTest(parser, harness):
michael@0 2 parser.parse("""
michael@0 3 [Global]
michael@0 4 interface Foo : Bar {
michael@0 5 getter any(DOMString name);
michael@0 6 };
michael@0 7 interface Bar {};
michael@0 8 """)
michael@0 9
michael@0 10 results = parser.finish()
michael@0 11
michael@0 12 harness.ok(results[0].isOnGlobalProtoChain(),
michael@0 13 "[Global] interface should be on global's proto chain")
michael@0 14 harness.ok(results[1].isOnGlobalProtoChain(),
michael@0 15 "[Global] interface should be on global's proto chain")
michael@0 16
michael@0 17 parser = parser.reset()
michael@0 18 threw = False
michael@0 19 try:
michael@0 20 parser.parse("""
michael@0 21 [Global]
michael@0 22 interface Foo {
michael@0 23 getter any(DOMString name);
michael@0 24 setter void(DOMString name, any arg);
michael@0 25 };
michael@0 26 """)
michael@0 27 results = parser.finish()
michael@0 28 except:
michael@0 29 threw = True
michael@0 30
michael@0 31 harness.ok(threw,
michael@0 32 "Should have thrown for [Global] used on an interface with a "
michael@0 33 "named setter")
michael@0 34
michael@0 35 parser = parser.reset()
michael@0 36 threw = False
michael@0 37 try:
michael@0 38 parser.parse("""
michael@0 39 [Global]
michael@0 40 interface Foo {
michael@0 41 getter any(DOMString name);
michael@0 42 creator void(DOMString name, any arg);
michael@0 43 };
michael@0 44 """)
michael@0 45 results = parser.finish()
michael@0 46 except:
michael@0 47 threw = True
michael@0 48
michael@0 49 harness.ok(threw,
michael@0 50 "Should have thrown for [Global] used on an interface with a "
michael@0 51 "named creator")
michael@0 52
michael@0 53 parser = parser.reset()
michael@0 54 threw = False
michael@0 55 try:
michael@0 56 parser.parse("""
michael@0 57 [Global]
michael@0 58 interface Foo {
michael@0 59 getter any(DOMString name);
michael@0 60 deleter void(DOMString name);
michael@0 61 };
michael@0 62 """)
michael@0 63 results = parser.finish()
michael@0 64 except:
michael@0 65 threw = True
michael@0 66
michael@0 67 harness.ok(threw,
michael@0 68 "Should have thrown for [Global] used on an interface with a "
michael@0 69 "named deleter")
michael@0 70
michael@0 71 parser = parser.reset()
michael@0 72 threw = False
michael@0 73 try:
michael@0 74 parser.parse("""
michael@0 75 [Global, OverrideBuiltins]
michael@0 76 interface Foo {
michael@0 77 };
michael@0 78 """)
michael@0 79 results = parser.finish()
michael@0 80 except:
michael@0 81 threw = True
michael@0 82
michael@0 83 harness.ok(threw,
michael@0 84 "Should have thrown for [Global] used on an interface with a "
michael@0 85 "[OverrideBuiltins]")
michael@0 86
michael@0 87 parser = parser.reset()
michael@0 88 threw = False
michael@0 89 try:
michael@0 90 parser.parse("""
michael@0 91 [Global]
michael@0 92 interface Foo : Bar {
michael@0 93 };
michael@0 94 [OverrideBuiltins]
michael@0 95 interface Bar {
michael@0 96 };
michael@0 97 """)
michael@0 98 results = parser.finish()
michael@0 99 except:
michael@0 100 threw = True
michael@0 101
michael@0 102 harness.ok(threw,
michael@0 103 "Should have thrown for [Global] used on an interface with an "
michael@0 104 "[OverrideBuiltins] ancestor")
michael@0 105
michael@0 106 parser = parser.reset()
michael@0 107 threw = False
michael@0 108 try:
michael@0 109 parser.parse("""
michael@0 110 [Global]
michael@0 111 interface Foo {
michael@0 112 };
michael@0 113 interface Bar : Foo {
michael@0 114 };
michael@0 115 """)
michael@0 116 results = parser.finish()
michael@0 117 except:
michael@0 118 threw = True
michael@0 119
michael@0 120 harness.ok(threw,
michael@0 121 "Should have thrown for [Global] used on an interface with a "
michael@0 122 "descendant")

mercurial