michael@0: import WebIDL michael@0: michael@0: def WebIDLTest(parser, harness): michael@0: parser.parse(""" michael@0: callback interface TestCallbackInterface { michael@0: attribute boolean bool; michael@0: }; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: michael@0: iface = results[0] michael@0: michael@0: harness.ok(iface.isCallback(), "Interface should be a callback") michael@0: michael@0: parser = parser.reset() michael@0: threw = False michael@0: try: michael@0: parser.parse(""" michael@0: interface TestInterface { michael@0: }; michael@0: callback interface TestCallbackInterface : TestInterface { michael@0: attribute boolean bool; michael@0: }; michael@0: """) michael@0: results = parser.finish() michael@0: except: michael@0: threw = True michael@0: michael@0: harness.ok(threw, "Should not allow non-callback parent of callback interface") michael@0: michael@0: parser = parser.reset() michael@0: threw = False michael@0: try: michael@0: parser.parse(""" michael@0: interface TestInterface : TestCallbackInterface { michael@0: }; michael@0: callback interface TestCallbackInterface { michael@0: attribute boolean bool; michael@0: }; michael@0: """) michael@0: results = parser.finish() michael@0: except: michael@0: threw = True michael@0: michael@0: harness.ok(threw, "Should not allow callback parent of non-callback interface") michael@0: michael@0: parser = parser.reset() michael@0: parser.parse(""" michael@0: callback interface TestCallbackInterface1 { michael@0: void foo(); michael@0: }; michael@0: callback interface TestCallbackInterface2 { michael@0: void foo(DOMString arg); michael@0: void foo(TestCallbackInterface1 arg); michael@0: }; michael@0: callback interface TestCallbackInterface3 { michael@0: void foo(DOMString arg); michael@0: void foo(TestCallbackInterface1 arg); michael@0: static void bar(); michael@0: }; michael@0: callback interface TestCallbackInterface4 { michael@0: void foo(DOMString arg); michael@0: void foo(TestCallbackInterface1 arg); michael@0: static void bar(); michael@0: const long baz = 5; michael@0: }; michael@0: callback interface TestCallbackInterface5 { michael@0: static attribute boolean bool; michael@0: void foo(); michael@0: }; michael@0: callback interface TestCallbackInterface6 { michael@0: void foo(DOMString arg); michael@0: void foo(TestCallbackInterface1 arg); michael@0: void bar(); michael@0: }; michael@0: callback interface TestCallbackInterface7 { michael@0: static attribute boolean bool; michael@0: }; michael@0: callback interface TestCallbackInterface8 { michael@0: attribute boolean bool; michael@0: }; michael@0: callback interface TestCallbackInterface9 : TestCallbackInterface1 { michael@0: void foo(); michael@0: }; michael@0: callback interface TestCallbackInterface10 : TestCallbackInterface1 { michael@0: void bar(); michael@0: }; michael@0: """) michael@0: results = parser.finish() michael@0: for (i, iface) in enumerate(results): michael@0: harness.check(iface.isSingleOperationInterface(), i < 4, michael@0: "Interface %s should be a single operation interface" % michael@0: iface.identifier.name)