Bug 785472 - The Web IDL parser should not allow inheriting from an interface that is only forward declared; r=khuey
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 24 Aug 2012 15:23:21 -0400
changeset 105383 68a243c559b23d08fa8a824d93ebd8531454c143
parent 105382 1bc0e4eac6e53c239afd2bc8416f543024d92b77
child 105384 f56f3d3f2c12b67624a84c2bbfdb38f7bff29fd7
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 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")