Bug 1017988 part 9. Don't codegen window-only things on worker descriptors. r=khuey
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 04 Aug 2014 22:20:34 -0400
changeset 197784 9e4c9130dee738b89ce19ca5f8e4738da010176e
parent 197783 cea6d1d8e0d160c80e1c021e930d984c23199e3c
child 197785 cf0848334ad24bfa4a889e3a65da12c5441710da
push id27250
push useremorley@mozilla.com
push dateTue, 05 Aug 2014 14:25:40 +0000
treeherdermozilla-central@2aaedcdf69f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1017988
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 1017988 part 9. Don't codegen window-only things on worker descriptors. r=khuey
dom/bindings/Bindings.conf
dom/bindings/Codegen.py
dom/webidl/XMLHttpRequest.webidl
dom/workers/XMLHttpRequest.h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -348,16 +348,18 @@ DOMInterfaces = {
                            'querySelector', 'getAnonymousNodes',
                            'getAnonymousElementByAtribute', 'getBindingParent'
                            ],
     'binaryNames': {
         'documentURI': 'documentURIFromJS',
         'URL': 'documentURIFromJS'
     }
 },
+# Note: we still need the worker descriptor here because
+# XMLHttpRequest.send() uses it.
 {
     'nativeType': 'JSObject',
     'workers': True,
     'skipGen': True
 }],
 
 'DocumentFragment': {
     'resultNotAddRefed': [ 'querySelector' ]
@@ -817,24 +819,20 @@ DOMInterfaces = {
     'resultNotAddRefed': [ 'item', 'namedItem' ]
 },
 
 'MozCanvasPrintState': {
     'headerFile': 'mozilla/dom/HTMLCanvasElement.h',
     'nativeType': 'mozilla::dom::HTMLCanvasPrintState',
 },
 
-'MozChannel': [
-{
+'MozChannel': {
     'nativeType': 'nsIChannel',
     'notflattened': True
 },
-{
-    'workers': True,
-}],
 
 'MozCellBroadcast': {
     'nativeType': 'mozilla::dom::CellBroadcast',
 },
 
 'MozIcc': {
     'nativeType': 'mozilla::dom::Icc',
 },
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -2027,16 +2027,21 @@ def overloadLength(arguments):
     return i
 
 
 def methodLength(method):
     signatures = method.signatures()
     return min(overloadLength(arguments) for retType, arguments in signatures)
 
 
+def isMaybeExposedIn(member, descriptor):
+    # All we can say for sure is that if this is a worker descriptor
+    # and member is only exposed in windows, then it's not exposed.
+    return not descriptor.workers or member.exposureSet != set(["Window"])
+
 class MethodDefiner(PropertyDefiner):
     """
     A class for defining methods on a prototype object.
     """
     def __init__(self, descriptor, name, static, unforgeable=False):
         assert not (static and unforgeable)
         PropertyDefiner.__init__(self, descriptor, name)
 
@@ -2044,17 +2049,18 @@ class MethodDefiner(PropertyDefiner):
         #       We should be able to check for special operations without an
         #       identifier. For now we check if the name starts with __
 
         # Ignore non-static methods for interfaces without a proto object
         if descriptor.interface.hasInterfacePrototypeObject() or static:
             methods = [m for m in descriptor.interface.members if
                        m.isMethod() and m.isStatic() == static and
                        MemberIsUnforgeable(m, descriptor) == unforgeable and
-                       not m.isIdentifierLess()]
+                       not m.isIdentifierLess() and
+                       isMaybeExposedIn(m, descriptor)]
         else:
             methods = []
         self.chrome = []
         self.regular = []
         for m in methods:
             if m.identifier.name == 'queryInterface':
                 if self.descriptor.workers:
                     continue
@@ -2258,17 +2264,18 @@ class AttrDefiner(PropertyDefiner):
     def __init__(self, descriptor, name, static, unforgeable=False):
         assert not (static and unforgeable)
         PropertyDefiner.__init__(self, descriptor, name)
         self.name = name
         # Ignore non-static attributes for interfaces without a proto object
         if descriptor.interface.hasInterfacePrototypeObject() or static:
             attributes = [m for m in descriptor.interface.members if
                           m.isAttr() and m.isStatic() == static and
-                          MemberIsUnforgeable(m, descriptor) == unforgeable]
+                          MemberIsUnforgeable(m, descriptor) == unforgeable and
+                          isMaybeExposedIn(m, descriptor)]
         else:
             attributes = []
         self.chrome = [m for m in attributes if isChromeOnly(m)]
         self.regular = [m for m in attributes if not isChromeOnly(m)]
         self.static = static
         self.unforgeable = unforgeable
 
         if static:
@@ -2341,17 +2348,18 @@ class AttrDefiner(PropertyDefiner):
 
 class ConstDefiner(PropertyDefiner):
     """
     A class for definining constants on the interface object
     """
     def __init__(self, descriptor, name):
         PropertyDefiner.__init__(self, descriptor, name)
         self.name = name
-        constants = [m for m in descriptor.interface.members if m.isConst()]
+        constants = [m for m in descriptor.interface.members if m.isConst() and
+                     isMaybeExposedIn(m, descriptor)]
         self.chrome = [m for m in constants if isChromeOnly(m)]
         self.regular = [m for m in constants if not isChromeOnly(m)]
 
     def generateArray(self, array, name, doIdArrays):
         if len(array) == 0:
             return ""
 
         def specData(const):
@@ -10464,16 +10472,18 @@ class CGDescriptor(CGThing):
             hasPromiseReturningMethod) = False, False, False, False, False, False, False
         crossOriginMethods, crossOriginGetters, crossOriginSetters = set(), set(), set()
         for n in descriptor.interface.namedConstructors:
             cgThings.append(CGClassConstructor(descriptor, n,
                                                NamedConstructorName(n)))
         for m in descriptor.interface.members:
             if m.isMethod() and m.identifier.name == 'queryInterface':
                 continue
+            if not isMaybeExposedIn(m, descriptor):
+                continue
             if m.isMethod() and m == descriptor.operations['Jsonifier']:
                 hasJsonifier = True
                 hasMethod = descriptor.needsSpecialGenericOps()
                 jsonifierMethod = m
             elif (m.isMethod() and
                   (not m.isIdentifierLess() or m == descriptor.operations['Stringifier'])):
                 if m.isStatic():
                     assert descriptor.interface.hasInterfaceObject()
--- a/dom/webidl/XMLHttpRequest.webidl
+++ b/dom/webidl/XMLHttpRequest.webidl
@@ -125,25 +125,25 @@ interface XMLHttpRequest : XMLHttpReques
 
   [SetterThrows]
   attribute XMLHttpRequestResponseType responseType;
   [Throws]
   readonly attribute any response;
   [Throws]
   readonly attribute DOMString? responseText;
 
-  [Throws=MainThread, Exposed=Window]
+  [Throws, Exposed=Window]
   readonly attribute Document? responseXML;
 
   // Mozilla-specific stuff
 
   [ChromeOnly, SetterThrows=Workers]
   attribute boolean mozBackgroundRequest;
 
-  [ChromeOnly]
+  [ChromeOnly, Exposed=Window]
   readonly attribute MozChannel? channel;
 
   [Throws]
   void sendAsBinary(DOMString body);
   [Throws, ChromeOnly]
   any getInterface(IID iid);
 
   readonly attribute boolean mozAnon;
--- a/dom/workers/XMLHttpRequest.h
+++ b/dom/workers/XMLHttpRequest.h
@@ -215,28 +215,16 @@ public:
 
   void
   GetResponse(JSContext* /* unused */, JS::MutableHandle<JS::Value> aResponse,
               ErrorResult& aRv);
 
   void
   GetResponseText(nsAString& aResponseText, ErrorResult& aRv);
 
-  JSObject*
-  GetResponseXML() const
-  {
-    return nullptr;
-  }
-
-  JSObject*
-  GetChannel() const
-  {
-    return nullptr;
-  }
-
   void
   GetInterface(JSContext* cx, JS::Handle<JSObject*> aIID,
                JS::MutableHandle<JS::Value> aRetval, ErrorResult& aRv)
   {
     aRv.Throw(NS_ERROR_FAILURE);
   }
 
   XMLHttpRequestUpload*