michael@0: import WebIDL michael@0: michael@0: def WebIDLTest(parser, harness): michael@0: parser.parse(""" michael@0: [TreatNonCallableAsNull] callback Function = any(any... arguments); michael@0: michael@0: interface TestTreatNonCallableAsNull1 { michael@0: attribute Function? onfoo; michael@0: attribute Function onbar; michael@0: }; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: michael@0: iface = results[1] michael@0: attr = iface.members[0] michael@0: harness.check(attr.type.treatNonCallableAsNull(), True, "Got the expected value") michael@0: attr = iface.members[1] michael@0: harness.check(attr.type.treatNonCallableAsNull(), False, "Got the expected value") michael@0: michael@0: parser = parser.reset() michael@0: michael@0: threw = False michael@0: try: michael@0: parser.parse(""" michael@0: callback Function = any(any... arguments); michael@0: michael@0: interface TestTreatNonCallableAsNull2 { michael@0: [TreatNonCallableAsNull] attribute Function onfoo; michael@0: }; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: except: michael@0: threw = True michael@0: michael@0: harness.ok(threw, "Should have thrown.") michael@0: michael@0: parser = parser.reset() michael@0: michael@0: threw = False michael@0: try: michael@0: parser.parse(""" michael@0: callback Function = any(any... arguments); michael@0: michael@0: [TreatNonCallableAsNull] michael@0: interface TestTreatNonCallableAsNull3 { michael@0: attribute Function onfoo; michael@0: }; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: except: michael@0: threw = True michael@0: michael@0: harness.ok(threw, "Should have thrown.") michael@0: michael@0: parser = parser.reset() michael@0: michael@0: threw = False michael@0: try: michael@0: parser.parse(""" michael@0: [TreatNonCallableAsNull, TreatNonObjectAsNull] michael@0: callback Function = any(any... arguments); michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: except: michael@0: threw = True michael@0: michael@0: harness.ok(threw, "Should have thrown.")