test_constructor_global.py (1748B)
1 import WebIDL 2 3 4 def WebIDLTest(parser, harness): 5 threw = False 6 try: 7 parser.parse( 8 """ 9 [Global=TestConstructorGlobal, Exposed=TestConstructorGlobal] 10 interface TestConstructorGlobal { 11 constructor(); 12 }; 13 """ 14 ) 15 16 parser.finish() 17 except WebIDL.WebIDLError: 18 threw = True 19 20 harness.ok(threw, "Should have thrown.") 21 22 parser = parser.reset() 23 threw = False 24 try: 25 parser.parse( 26 """ 27 [Global=TestLegacyFactoryFunctionGlobal, Exposed=TestLegacyFactoryFunctionGlobal, 28 LegacyFactoryFunction=FooBar] 29 interface TestLegacyFactoryFunctionGlobal { 30 }; 31 """ 32 ) 33 parser.finish() 34 except WebIDL.WebIDLError: 35 threw = True 36 37 harness.ok(threw, "Should have thrown.") 38 39 parser = parser.reset() 40 threw = False 41 try: 42 parser.parse( 43 """ 44 [LegacyFactoryFunction=FooBar, Global=TestLegacyFactoryFunctionGlobal, 45 Exposed=TestLegacyFactoryFunctionGlobal] 46 interface TestLegacyFactoryFunctionGlobal { 47 }; 48 """ 49 ) 50 parser.finish() 51 except WebIDL.WebIDLError: 52 threw = True 53 54 harness.ok(threw, "Should have thrown.") 55 56 parser = parser.reset() 57 threw = False 58 try: 59 parser.parse( 60 """ 61 [Global=TestHTMLConstructorGlobal, Exposed=TestHTMLConstructorGlobal] 62 interface TestHTMLConstructorGlobal { 63 [HTMLConstructor] constructor(); 64 }; 65 """ 66 ) 67 68 parser.finish() 69 except WebIDL.WebIDLError: 70 threw = True 71 72 harness.ok(threw, "Should have thrown.")