Bug 1273499 - Move some code around in CallSetup::CallSetup() to avoid code repetition; r=bz
authorMs2ger <Ms2ger@gmail.com>
Fri, 03 Jun 2016 11:11:45 +0200
changeset 341454 94bf6a16d707a3450ad3360a9d02ddf65ab445aa
parent 341453 dc8e4c1174b29a330d8f63e97b20e537d1076cf1
child 341455 6153baa6401d8611015ae3fa0d589204286eadba
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1273499, 1262630
milestone49.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 1273499 - Move some code around in CallSetup::CallSetup() to avoid code repetition; r=bz This has been possible since changeset d5f6867173c9 (bug 1262630).
dom/bindings/CallbackObject.cpp
--- a/dom/bindings/CallbackObject.cpp
+++ b/dom/bindings/CallbackObject.cpp
@@ -95,40 +95,36 @@ CallbackObject::CallSetup::CallSetup(Cal
   nsIGlobalObject* globalObject = nullptr;
 
   JSContext* cx;
   {
     // Bug 955660: we cannot do "proper" rooting here because we need the
     // global to get a context. Everything here is simple getters that cannot
     // GC, so just paper over the necessary dataflow inversion.
     JS::AutoSuppressGCAnalysis nogc;
-    if (mIsMainThread) {
-      // Now get the global for this callback. Note that for the case of
-      // JS-implemented WebIDL we never have a window here.
-      nsGlobalWindow* win =
-        aIsJSImplementedWebIDL ? nullptr : xpc::WindowGlobalOrNull(realCallback);
-      if (win) {
-        MOZ_ASSERT(win->IsInnerWindow());
-        // We don't want to run script in windows that have been navigated away
-        // from.
-        if (!win->AsInner()->HasActiveDocument()) {
-          aRv.ThrowDOMException(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
-            NS_LITERAL_CSTRING("Refusing to execute function from window "
-                               "whose document is no longer active."));
-          return;
-        }
-        globalObject = win;
-      } else {
-        // No DOM Window. Store the global.
-        JSObject* glob = js::GetGlobalForObjectCrossCompartment(realCallback);
-        globalObject = xpc::NativeGlobal(glob);
-        MOZ_ASSERT(globalObject);
+
+    // Now get the global for this callback. Note that for the case of
+    // JS-implemented WebIDL we never have a window here.
+    nsGlobalWindow* win = mIsMainThread && !aIsJSImplementedWebIDL
+                        ? xpc::WindowGlobalOrNull(realCallback)
+                        : nullptr;
+    if (win) {
+      MOZ_ASSERT(win->IsInnerWindow());
+      // We don't want to run script in windows that have been navigated away
+      // from.
+      if (!win->AsInner()->HasActiveDocument()) {
+        aRv.ThrowDOMException(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
+          NS_LITERAL_CSTRING("Refusing to execute function from window "
+                             "whose document is no longer active."));
+        return;
       }
+      globalObject = win;
     } else {
-      JSObject *global = js::GetGlobalForObjectCrossCompartment(realCallback);
+      // No DOM Window. Store the global.
+      JSObject* global = js::GetGlobalForObjectCrossCompartment(realCallback);
       globalObject = xpc::NativeGlobal(global);
       MOZ_ASSERT(globalObject);
     }
 
     // Bail out if there's no useful global. This seems to happen intermittently
     // on gaia-ui tests, probably because nsInProcessTabChildGlobal is returning
     // null in some kind of teardown state.
     if (!globalObject->GetGlobalJSObject()) {