Bug 921453. Don't allow conditional-exposure annotations on an interface that has no interface object, since they make no sense there. r=khuey
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 29 Aug 2014 19:50:04 -0400
changeset 224169 af6fa89ec5509baead12a11025ef4f5329dda01c
parent 224168 d29ed7eb2d118cf749c52d20a53311f66e608131
child 224170 f79c41150d2b960a708be3d12bb9fa1b82e2e72e
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs921453
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 921453. Don't allow conditional-exposure annotations on an interface that has no interface object, since they make no sense there. r=khuey
dom/bindings/Configuration.py
dom/bindings/parser/WebIDL.py
--- a/dom/bindings/Configuration.py
+++ b/dom/bindings/Configuration.py
@@ -546,22 +546,17 @@ class Descriptor(DescriptorProvider):
                 in self.interface.members))
 
     def hasThreadChecks(self):
         return ((not self.workers and not self.interface.isExposedInWindow()) or
                 (self.interface.isExposedInAnyWorker() and
                  self.interface.isExposedOnlyInSomeWorkers()))
 
     def isExposedConditionally(self):
-        return (self.interface.getExtendedAttribute("Pref") or
-                self.interface.getExtendedAttribute("ChromeOnly") or
-                self.interface.getExtendedAttribute("Func") or
-                self.interface.getExtendedAttribute("AvailableIn") or
-                self.interface.getExtendedAttribute("CheckPermissions") or
-                self.hasThreadChecks())
+        return self.interface.isExposedConditionally() or self.hasThreadChecks()
 
     def needsXrayResolveHooks(self):
         """
         Generally, any interface with NeedNewResolve needs Xray
         resolveOwnProperty and enumerateOwnProperties hooks.  But for
         the special case of plugin-loading elements, we do NOT want
         those, because we don't want to instantiate plug-ins simply
         due to chrome touching them and that's all those hooks do on
--- a/dom/bindings/parser/WebIDL.py
+++ b/dom/bindings/parser/WebIDL.py
@@ -1013,16 +1013,24 @@ class IDLInterface(IDLObjectWithScope):
 
         if (self.getExtendedAttribute("CheckPermissions") and
             self._exposureGlobalNames != set([self.parentScope.primaryGlobalName])):
             raise WebIDLError("[CheckPermissions] used on an interface that is "
                               "not %s-only" %
                               self.parentScope.primaryGlobalName,
                               [self.location])
 
+        # Conditional exposure makes no sense for interfaces with no
+        # interface object, unless they're navigator properties.
+        if (self.isExposedConditionally() and
+            not self.hasInterfaceObject() and
+            not self.getNavigatorProperty()):
+            raise WebIDLError("Interface with no interface object is "
+                              "exposed conditionally",
+                              [self.location])
 
     def isInterface(self):
         return True
 
     def isExternal(self):
         return False
 
     def setIsConsequentialInterfaceOf(self, other):
@@ -1351,16 +1359,23 @@ class IDLInterface(IDLObjectWithScope):
         deps.union(self.implementedInterfaces)
         if self.parent:
             deps.add(self.parent)
         return deps
 
     def hasMembersInSlots(self):
         return self._ownMembersInSlots != 0
 
+    def isExposedConditionally(self):
+        return (self.getExtendedAttribute("Pref") or
+                self.getExtendedAttribute("ChromeOnly") or
+                self.getExtendedAttribute("Func") or
+                self.getExtendedAttribute("AvailableIn") or
+                self.getExtendedAttribute("CheckPermissions"))
+
 class IDLDictionary(IDLObjectWithScope):
     def __init__(self, location, parentScope, name, parent, members):
         assert isinstance(parentScope, IDLScope)
         assert isinstance(name, IDLUnresolvedIdentifier)
         assert not parent or isinstance(parent, IDLIdentifierPlaceholder)
 
         self.parent = parent
         self._finished = False