michael@0: def WebIDLTest(parser, harness): michael@0: parser.parse(""" michael@0: interface Child : Parent { michael@0: }; michael@0: interface Parent { michael@0: [Unforgeable] readonly attribute long foo; michael@0: }; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: harness.check(len(results), 2, michael@0: "Should be able to inherit from an interface with " michael@0: "[Unforgeable] properties.") michael@0: michael@0: parser = parser.reset(); michael@0: parser.parse(""" michael@0: interface Child : Parent { michael@0: const short foo = 10; michael@0: }; michael@0: interface Parent { michael@0: [Unforgeable] readonly attribute long foo; michael@0: }; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: harness.check(len(results), 2, michael@0: "Should be able to inherit from an interface with " michael@0: "[Unforgeable] properties even if we have a constant with " michael@0: "the same name.") michael@0: michael@0: parser = parser.reset(); michael@0: parser.parse(""" michael@0: interface Child : Parent { michael@0: static attribute short foo; michael@0: }; michael@0: interface Parent { michael@0: [Unforgeable] readonly attribute long foo; michael@0: }; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: harness.check(len(results), 2, michael@0: "Should be able to inherit from an interface with " michael@0: "[Unforgeable] properties even if we have a static attribute " michael@0: "with the same name.") michael@0: michael@0: parser = parser.reset(); michael@0: parser.parse(""" michael@0: interface Child : Parent { michael@0: static void foo(); michael@0: }; michael@0: interface Parent { michael@0: [Unforgeable] readonly attribute long foo; michael@0: }; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: harness.check(len(results), 2, michael@0: "Should be able to inherit from an interface with " michael@0: "[Unforgeable] properties even if we have a static operation " michael@0: "with the same name.") michael@0: michael@0: parser = parser.reset(); michael@0: threw = False michael@0: try: michael@0: parser.parse(""" michael@0: interface Child : Parent { michael@0: void foo(); michael@0: }; michael@0: interface Parent { michael@0: [Unforgeable] readonly attribute long foo; michael@0: }; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: except: michael@0: threw = True michael@0: harness.ok(threw, michael@0: "Should have thrown when shadowing unforgeable attribute on " michael@0: "parent with operation.") michael@0: michael@0: parser = parser.reset(); michael@0: threw = False michael@0: try: michael@0: parser.parse(""" michael@0: interface Child : Parent { michael@0: attribute short foo; michael@0: }; michael@0: interface Parent { michael@0: [Unforgeable] readonly attribute long foo; michael@0: }; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: except Exception,x: michael@0: threw = True michael@0: harness.ok(threw, michael@0: "Should have thrown when shadowing unforgeable attribute on " michael@0: "parent with attribute.") michael@0: michael@0: parser = parser.reset(); michael@0: parser.parse(""" michael@0: interface Child : Parent { michael@0: }; michael@0: interface Parent {}; michael@0: interface Consequential { michael@0: [Unforgeable] readonly attribute long foo; michael@0: }; michael@0: Parent implements Consequential; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: harness.check(len(results), 4, michael@0: "Should be able to inherit from an interface with a " michael@0: "consequential interface with [Unforgeable] properties.") michael@0: michael@0: parser = parser.reset(); michael@0: threw = False michael@0: try: michael@0: parser.parse(""" michael@0: interface Child : Parent { michael@0: void foo(); michael@0: }; michael@0: interface Parent {}; michael@0: interface Consequential { michael@0: [Unforgeable] readonly attribute long foo; michael@0: }; michael@0: Parent implements Consequential; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: except: michael@0: threw = True michael@0: michael@0: harness.ok(threw, michael@0: "Should have thrown when shadowing unforgeable attribute " michael@0: "of parent's consequential interface.") michael@0: michael@0: parser = parser.reset(); michael@0: threw = False michael@0: try: michael@0: parser.parse(""" michael@0: interface Child : Parent { michael@0: }; michael@0: interface Parent : GrandParent {}; michael@0: interface GrandParent {}; michael@0: interface Consequential { michael@0: [Unforgeable] readonly attribute long foo; michael@0: }; michael@0: GrandParent implements Consequential; michael@0: interface ChildConsequential { michael@0: void foo(); michael@0: }; michael@0: Child implements ChildConsequential; michael@0: """) michael@0: michael@0: results = parser.finish() michael@0: except: michael@0: threw = True michael@0: michael@0: harness.ok(threw, michael@0: "Should have thrown when our consequential interface shadows unforgeable attribute " michael@0: "of ancestor's consequential interface.") michael@0: michael@0: parser = parser.reset(); michael@0: threw = False michael@0: try: michael@0: parser.parse(""" michael@0: interface iface { michael@0: [Unforgeable] attribute long foo; 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 for writable [Unforgeable] attribute.") michael@0: michael@0: parser = parser.reset(); michael@0: threw = False michael@0: try: michael@0: parser.parse(""" michael@0: interface iface { michael@0: [Unforgeable] static readonly attribute long foo; 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 for static [Unforgeable] attribute.")