Bug 1084439. Remove ResolveWorkerClasses in favor of [Exposed=System] annotations. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Sun, 19 Oct 2014 22:25:49 -0400
changeset 211154 916278924d4c4da444bc65dbcade2b74d305b7a2
parent 211153 2c490d1c97b0882a22980c25ff2fd303065832cb
child 211155 e82fd502119c3f071cdd619e158c75bdd2edf195
push id27667
push usercbook@mozilla.com
push dateMon, 20 Oct 2014 12:40:56 +0000
treeherdermozilla-central@cc2d8bdbccb8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1084439
milestone36.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 1084439. Remove ResolveWorkerClasses in favor of [Exposed=System] annotations. r=bholley
dom/bindings/Codegen.py
dom/webidl/AbstractWorker.webidl
dom/webidl/ErrorEvent.webidl
dom/webidl/Event.webidl
dom/webidl/EventTarget.webidl
dom/webidl/LegacyQueryInterface.webidl
dom/webidl/MessageEvent.webidl
dom/webidl/MessagePort.webidl
dom/webidl/MessagePortList.webidl
dom/webidl/Worker.webidl
dom/workers/RuntimeService.cpp
dom/workers/Workers.h
js/xpconnect/src/XPCRuntimeService.cpp
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -11951,18 +11951,17 @@ class CGResolveSystemBinding(CGAbstractM
                             jsidInits])
 
         definitions = CGList([], "\n")
         for desc in descriptors:
             bindingNS = toBindingNamespace(desc.name)
             defineCode = "!%s::GetConstructorObject(aCx, aObj)" % bindingNS
             defineCode = CGIfWrapper(CGGeneric("return false;\n"), defineCode)
             defineCode = CGList([defineCode,
-                                 CGGeneric("aObjp.set(aObj);\n"),
-                                 CGGeneric("return true;\n")])
+                                 CGGeneric("aObjp.set(aObj);\n")])
 
             condition = "JSID_IS_VOID(aId) || aId == %s" % descNameToId(desc.name)
             if desc.isExposedConditionally():
                 condition = "(%s) && %s::ConstructorEnabled(aCx, aObj)" % (condition, bindingNS)
 
             definitions.append(CGIfWrapper(defineCode, condition))
 
         return CGList([CGGeneric("MOZ_ASSERT(NS_IsMainThread());\n"),
--- a/dom/webidl/AbstractWorker.webidl
+++ b/dom/webidl/AbstractWorker.webidl
@@ -1,10 +1,10 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-[NoInterfaceObject, Exposed=(Window,Worker)]
+[NoInterfaceObject, Exposed=(Window,Worker,System)]
 interface AbstractWorker {
     attribute EventHandler onerror;
 };
--- a/dom/webidl/ErrorEvent.webidl
+++ b/dom/webidl/ErrorEvent.webidl
@@ -1,14 +1,15 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-[Constructor(DOMString type, optional ErrorEventInit eventInitDict)]
+[Constructor(DOMString type, optional ErrorEventInit eventInitDict),
+ Exposed=(Window,System)]
 interface ErrorEvent : Event
 {
   readonly attribute DOMString message;
   readonly attribute DOMString filename;
   readonly attribute unsigned long lineno;
   readonly attribute unsigned long colno;
   readonly attribute any error;
 };
--- a/dom/webidl/Event.webidl
+++ b/dom/webidl/Event.webidl
@@ -6,17 +6,17 @@
  * The origin of this IDL file is
  * http://www.w3.org/TR/2012/WD-dom-20120105/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 [Constructor(DOMString type, optional EventInit eventInitDict),
- Exposed=(Window,Worker)]
+ Exposed=(Window,Worker,System)]
 interface Event {
   [Pure]
   readonly attribute DOMString type;
   [Pure]
   readonly attribute EventTarget? target;
   [Pure]
   readonly attribute EventTarget? currentTarget;
 
--- a/dom/webidl/EventTarget.webidl
+++ b/dom/webidl/EventTarget.webidl
@@ -5,17 +5,17 @@
  *
  * The origin of this IDL file is
  * http://www.w3.org/TR/2012/WD-dom-20120105/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
-[Exposed=(Window,Worker)]
+[Exposed=(Window,Worker,System)]
 interface EventTarget {
   /* Passing null for wantsUntrusted means "default behavior", which
      differs in content and chrome.  In content that default boolean
      value is true, while in chrome the default boolean value is
      false. */
   [Throws]
   void addEventListener(DOMString type,
                         EventListener? listener,
--- a/dom/webidl/LegacyQueryInterface.webidl
+++ b/dom/webidl/LegacyQueryInterface.webidl
@@ -5,17 +5,17 @@
  */
 
 interface nsISupports;
 interface IID;
 
 [NoInterfaceObject,
  // Need Exposed here, because this is a mixin onto things like Event
  // that are exposed in workers.
- Exposed=(Window,Worker)]
+ Exposed=(Window,Worker,System)]
 interface LegacyQueryInterface {
   // Legacy QueryInterface, only exposed to chrome or XBL code on the
   // main thread.
   [Exposed=Window]
   nsISupports queryInterface(IID iid);
 };
 
 Attr implements LegacyQueryInterface;
--- a/dom/webidl/MessageEvent.webidl
+++ b/dom/webidl/MessageEvent.webidl
@@ -5,17 +5,17 @@
  *
  * For more information on this interface, please see
  * http://www.whatwg.org/specs/web-apps/current-work/#messageevent
  */
 
 interface WindowProxy;
 
 [Constructor(DOMString type, optional MessageEventInit eventInitDict),
- Exposed=(Window,Worker)]
+ Exposed=(Window,Worker,System)]
 interface MessageEvent : Event {
   /**
    * Custom data associated with this event.
    */
   [GetterThrows]
   readonly attribute any data;
 
   /**
--- a/dom/webidl/MessagePort.webidl
+++ b/dom/webidl/MessagePort.webidl
@@ -2,17 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * For more information on this interface, please see
  * http://www.whatwg.org/specs/web-apps/current-work/#channel-messaging
  */
 
-[Exposed=(Window,Worker)]
+[Exposed=(Window,Worker,System)]
 interface MessagePort : EventTarget {
   [Throws]
   void postMessage(any message, optional sequence<Transferable> transferable);
 
   void start();
   void close();
 
   // event handlers
--- a/dom/webidl/MessagePortList.webidl
+++ b/dom/webidl/MessagePortList.webidl
@@ -1,11 +1,11 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-[NoInterfaceObject, ArrayClass, Exposed=(Window,Worker)]
+[NoInterfaceObject, ArrayClass, Exposed=(Window,Worker,System)]
 interface MessagePortList {
   readonly attribute unsigned long length;
   getter MessagePort? item(unsigned long index);
 };
--- a/dom/webidl/Worker.webidl
+++ b/dom/webidl/Worker.webidl
@@ -9,25 +9,25 @@
  * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and Opera
  * Software ASA.
  * You are granted a license to use, reproduce and create derivative works of
  * this document.
  */
 
 [Constructor(DOMString scriptURL),
  Func="mozilla::dom::workers::WorkerPrivate::WorkerAvailable",
- Exposed=(Window,Worker)]
+ Exposed=(Window,Worker,System)]
 interface Worker : EventTarget {
   void terminate();
 
   [Throws]
   void postMessage(any message, optional sequence<any> transfer);
 
   attribute EventHandler onmessage;
 };
 
 Worker implements AbstractWorker;
 
 [Constructor(DOMString scriptURL),
  Func="mozilla::dom::workers::ChromeWorkerPrivate::WorkerAvailable",
- Exposed=(Window,Worker)]
+ Exposed=(Window,Worker,System)]
 interface ChromeWorker : Worker {
 };
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -183,33 +183,16 @@ enum {
   ID_ChromeWorker,
   ID_Event,
   ID_MessageEvent,
   ID_ErrorEvent,
 
   ID_COUNT
 };
 
-// These are jsids for the main runtime. Only touched on the main thread.
-jsid gStringIDs[ID_COUNT] = { JSID_VOID };
-
-const char* gStringChars[] = {
-  "Worker",
-  "ChromeWorker",
-  "Event",
-  "MessageEvent",
-  "ErrorEvent"
-
-  // XXX Don't care about ProgressEvent since it should never leak to the main
-  // thread.
-};
-
-static_assert(MOZ_ARRAY_LENGTH(gStringChars) == ID_COUNT,
-              "gStringChars should have the right length.");
-
 class LiteralRebindingCString : public nsDependentCString
 {
 public:
   template<int N>
   void RebindLiteral(const char (&aStr)[N])
   {
     Rebind(aStr, N-1);
   }
@@ -1217,65 +1200,16 @@ private:
 
 #ifdef ENABLE_TESTS
 NS_IMPL_ISUPPORTS(RuntimeService::WorkerThread::TestPBackgroundCreateCallback,
                   nsIIPCBackgroundChildCreateCallback);
 #endif
 
 BEGIN_WORKERS_NAMESPACE
 
-// Entry point for main thread non-window globals.
-bool
-ResolveWorkerClasses(JSContext* aCx, JS::Handle<JSObject*> aObj, JS::Handle<jsid> aId,
-                     JS::MutableHandle<JSObject*> aObjp)
-{
-  AssertIsOnMainThread();
-  MOZ_ASSERT(nsContentUtils::IsCallerChrome());
-
-  // Make sure our strings are interned.
-  if (JSID_IS_VOID(gStringIDs[0])) {
-    for (uint32_t i = 0; i < ID_COUNT; i++) {
-      JSString* str = JS_InternString(aCx, gStringChars[i]);
-      if (!str) {
-        while (i) {
-          gStringIDs[--i] = JSID_VOID;
-        }
-        return false;
-      }
-      gStringIDs[i] = INTERNED_STRING_TO_JSID(aCx, str);
-    }
-  }
-
-  // Invoking this function with JSID_VOID means "always resolve".
-  bool shouldResolve = JSID_IS_VOID(aId);
-  if (!shouldResolve) {
-    for (uint32_t i = 0; i < ID_COUNT; i++) {
-      if (gStringIDs[i] == aId) {
-        shouldResolve = true;
-        break;
-      }
-    }
-  }
-
-  if (!shouldResolve) {
-    aObjp.set(nullptr);
-    return true;
-  }
-
-  if (!WorkerBinding::GetConstructorObject(aCx, aObj) ||
-      !ChromeWorkerBinding::GetConstructorObject(aCx, aObj) ||
-      !ErrorEventBinding::GetConstructorObject(aCx, aObj) ||
-      !MessageEventBinding::GetConstructorObject(aCx, aObj)) {
-    return false;
-  }
-
-  aObjp.set(aObj);
-  return true;
-}
-
 void
 CancelWorkersForWindow(nsPIDOMWindow* aWindow)
 {
   AssertIsOnMainThread();
   RuntimeService* runtime = RuntimeService::GetService();
   if (runtime) {
     runtime->CancelWorkersForWindow(aWindow);
   }
--- a/dom/workers/Workers.h
+++ b/dom/workers/Workers.h
@@ -166,22 +166,16 @@ enum WorkerPreference
 {
   WORKERPREF_DUMP = 0, // browser.dom.window.dump.enabled
   WORKERPREF_DOM_FETCH,// dom.fetch.enabled
   WORKERPREF_COUNT
 };
 
 // All of these are implemented in RuntimeService.cpp
 
-// Resolves all of the worker classes onto |aObjp| if one of them matches |aId|
-// or if |aId| is JSID_VOID.
-bool
-ResolveWorkerClasses(JSContext* aCx, JS::Handle<JSObject*> aObj, JS::Handle<jsid> aId,
-                     JS::MutableHandle<JSObject*> aObjp);
-
 void
 CancelWorkersForWindow(nsPIDOMWindow* aWindow);
 
 void
 SuspendWorkersForWindow(nsPIDOMWindow* aWindow);
 
 void
 ResumeWorkersForWindow(nsPIDOMWindow* aWindow);
--- a/js/xpconnect/src/XPCRuntimeService.cpp
+++ b/js/xpconnect/src/XPCRuntimeService.cpp
@@ -5,20 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsContentUtils.h"
 #include "BackstagePass.h"
 #include "nsIProgrammingLanguage.h"
 #include "nsDOMClassInfo.h"
 #include "nsIPrincipal.h"
 
-#include "mozilla/dom/workers/Workers.h"
 #include "mozilla/dom/ResolveSystemBinding.h"
 
-using mozilla::dom::workers::ResolveWorkerClasses;
 using mozilla::dom::ResolveSystemBinding;
 
 NS_INTERFACE_MAP_BEGIN(BackstagePass)
   NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
   NS_INTERFACE_MAP_ENTRY(nsIXPCScriptable)
   NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
   NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
@@ -63,24 +61,16 @@ BackstagePass::NewResolve(nsIXPConnectWr
 
     if (resolved) {
         *objpArg = obj;
         return NS_OK;
     }
 
     JS::RootedObject objp(cx, *objpArg);
 
-    *_retval = ResolveWorkerClasses(cx, obj, id, &objp);
-    NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
-
-    if (objp) {
-        *objpArg = objp;
-        return NS_OK;
-    }
-
     *_retval = ResolveSystemBinding(cx, obj, id, &objp);
     NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
 
     if (objp) {
         *objpArg = objp;
         return NS_OK;
     }
 
@@ -92,19 +82,16 @@ BackstagePass::Enumerate(nsIXPConnectWra
                          JSObject *objArg, bool *_retval)
 {
     JS::RootedObject obj(cx, objArg);
 
     *_retval = JS_EnumerateStandardClasses(cx, obj);
     NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
 
     JS::RootedObject ignored(cx);
-    *_retval = ResolveWorkerClasses(cx, obj, JSID_VOIDHANDLE, &ignored);
-    NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
-
     *_retval = ResolveSystemBinding(cx, obj, JSID_VOIDHANDLE, &ignored);
     NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
 
     return NS_OK;
 }
 
 /***************************************************************************/
 /* void getInterfaces (out uint32_t count, [array, size_is (count), retval]