Backed out changeset df8e7a4b86cf (bug 984467) for mochitest-other failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 18 Apr 2014 11:13:31 -0400
changeset 197796 d69cced6e24223c83aabd152b3f2208556da88dd
parent 197795 0ce418853a12b5e7c91ec1b66e24cf97665621cd
child 197797 6632c970ef7c683008a2098d1b94f940358d4422
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs984467
milestone31.0a1
backs outdf8e7a4b86cfdec117295389d63349c46d8e65d2
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
Backed out changeset df8e7a4b86cf (bug 984467) for mochitest-other failures.
dom/base/nsGlobalWindow.cpp
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -7602,21 +7602,33 @@ nsGlobalWindow::CallerInnerWindow()
     NS_ENSURE_TRUE(ok, nullptr);
     if (scopeProto && xpc::IsSandboxPrototypeProxy(scopeProto) &&
         (scopeProto = js::CheckedUnwrap(scopeProto, /* stopAtOuter = */ false)))
     {
       scope = scopeProto;
     }
   }
   JSAutoCompartment ac(cx, scope);
-  nsGlobalWindow* win = xpc::WindowOrNull(scope);
-     
+
+  // We don't use xpc::WindowOrNull here because we want to be able to tell
+  // apart the cases of "scope is not an nsISupports at all" and "scope is an
+  // nsISupports that's not a window". It's not clear whether that's desirable,
+  // see bug 984467.
+  nsISupports* native =
+    nsContentUtils::XPConnect()->GetNativeOfWrapper(cx, scope);
+  if (!native)
+    return nullptr;
+
+  // The calling window must be holding a reference, so we can just return a
+  // raw pointer here and let the QI's addref be balanced by the nsCOMPtr
+  // destructor's release.
+  nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(native);
   if (!win)
     return GetCurrentInnerWindowInternal();
-  return win;
+  return static_cast<nsGlobalWindow*>(win.get());
 }
 
 /**
  * Class used to represent events generated by calls to Window.postMessage,
  * which asynchronously creates and dispatches events.
  */
 class PostMessageEvent : public nsRunnable
 {