Bug 785472 - The Web IDL parser should not allow inheriting from an interface that is only forward declared; r=khuey
☠☠ backed out by 1bc0e4eac6e5 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 24 Aug 2012 15:23:21 -0400
changeset 105370 1142882b6c0b58eb019ca0514d32552de9efbb09
parent 105369 1bdc56a180bc2b8c588b4982103c3a7e6b6baa3e
child 105371 62f13ac39e4c9c1fd2a24b0fbc6a83f460c64b1a
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewerskhuey
bugs785472
milestone17.0a1
Bug 785472 - The Web IDL parser should not allow inheriting from an interface that is only forward declared; r=khuey
dom/bindings/parser/WebIDL.py
dom/bindings/parser/tests/test_interface.py
--- a/dom/bindings/parser/WebIDL.py
+++ b/dom/bindings/parser/WebIDL.py
@@ -417,16 +417,22 @@ class IDLInterface(IDLObjectWithScope):
     def finish(self, scope):
         if self._finished:
             return
 
         self._finished = True
 
         assert not self.parent or isinstance(self.parent, IDLIdentifierPlaceholder)
         parent = self.parent.finish(scope) if self.parent else None
+        if parent and not isinstance(parent, IDLExternalInterface):
+            raise WebIDLError("%s inherits from %s which does not have "
+                              "a definition" %
+                              (self.identifier.name,
+                               self.parent.identifier.name),
+                              [self.location])
         assert not parent or isinstance(parent, IDLInterface)
 
         self.parent = parent
 
         assert iter(self.members)
 
         if self.parent:
             self.parent.finish(scope)
--- a/dom/bindings/parser/tests/test_interface.py
+++ b/dom/bindings/parser/tests/test_interface.py
@@ -168,8 +168,21 @@ def WebIDLTest(parser, harness):
             C implements D;
             D implements A;
         """)
         results = parser.finish()
     except:
         threw = True
 
     harness.ok(threw, "Should not allow indirectly inheriting from an interface that indirectly implements us")
+
+    parser = parser.reset()
+    threw = False
+    try:
+        parser.parse("""
+            interface A;
+            interface B : A {};
+        """)
+        results = parser.finish()
+    except:
+        threw = True
+
+    harness.ok(threw, "Should not allow inheriting from an interface that is only forward declared")