Bug 984467 - Replace GetNativeOfWrapper + QI bit with xpc::WindowOrNull(scope). r=bz
☠☠ backed out by d69cced6e242 ☠ ☠
authorAnuj Agarwal <anujagarwal464@gmail.com>
Fri, 18 Apr 2014 09:36:37 -0400
changeset 197791 df8e7a4b86cfdec117295389d63349c46d8e65d2
parent 197790 d8d01c95be038fb3989cc88e8e9bf371c4545f04
child 197792 a90a994dee5fa3bc2f7891e52eaf79e402cdcdad
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)
reviewersbz
bugs984467
milestone31.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 984467 - Replace GetNativeOfWrapper + QI bit with xpc::WindowOrNull(scope). r=bz
dom/base/nsGlobalWindow.cpp
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -7602,33 +7602,21 @@ nsGlobalWindow::CallerInnerWindow()
     NS_ENSURE_TRUE(ok, nullptr);
     if (scopeProto && xpc::IsSandboxPrototypeProxy(scopeProto) &&
         (scopeProto = js::CheckedUnwrap(scopeProto, /* stopAtOuter = */ false)))
     {
       scope = scopeProto;
     }
   }
   JSAutoCompartment ac(cx, 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);
+  nsGlobalWindow* win = xpc::WindowOrNull(scope);
+     
   if (!win)
     return GetCurrentInnerWindowInternal();
-  return static_cast<nsGlobalWindow*>(win.get());
+  return win;
 }
 
 /**
  * Class used to represent events generated by calls to Window.postMessage,
  * which asynchronously creates and dispatches events.
  */
 class PostMessageEvent : public nsRunnable
 {