Bug 1063271 - Undo bug 796938 part 10. r=smaug, a=lmandel
authorBobby Holley <bobbyholley@gmail.com>
Fri, 05 Sep 2014 08:54:13 -0700
changeset 217545 4f11b0d2a9e824805de810779ea80de769c39c53
parent 217544 bd7532ac742caabd63900e3a729e29f85cb32ca0
child 217546 c7cd9cce6113c0fbd8249a7150b09fb4ad6f3975
push id6850
push userryanvm@gmail.com
push dateTue, 16 Sep 2014 02:29:24 +0000
treeherdermozilla-aurora@4f11b0d2a9e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, lmandel
bugs1063271, 796938
milestone34.0a2
Bug 1063271 - Undo bug 796938 part 10. r=smaug, a=lmandel
dom/base/nsJSEnvironment.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -13,16 +13,17 @@
 #include "nsIScriptSecurityManager.h"
 #include "nsDOMCID.h"
 #include "nsIServiceManager.h"
 #include "nsIXPConnect.h"
 #include "nsIJSRuntimeService.h"
 #include "nsCOMPtr.h"
 #include "nsISupportsPrimitives.h"
 #include "nsReadableUtils.h"
+#include "nsDOMJSUtils.h"
 #include "nsJSUtils.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsPresContext.h"
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
@@ -559,17 +560,23 @@ NS_ScriptErrorReporter(JSContext *cx,
 
   JS::Rooted<JS::Value> exception(cx);
   ::JS_GetPendingException(cx, &exception);
 
   // Note: we must do this before running any more code on cx.
   ::JS_ClearPendingException(cx);
 
   MOZ_ASSERT(cx == nsContentUtils::GetCurrentJSContext());
-  nsCOMPtr<nsIGlobalObject> globalObject = GetEntryGlobal();
+  nsCOMPtr<nsIGlobalObject> globalObject;
+  if (nsIScriptContext* scx = GetScriptContextFromJSContext(cx)) {
+    nsCOMPtr<nsPIDOMWindow> outer = do_QueryInterface(scx->GetGlobalObject());
+    if (outer) {
+      globalObject = static_cast<nsGlobalWindow*>(outer->GetCurrentInnerWindow());
+    }
+  }
   if (globalObject) {
 
     nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(globalObject);
     MOZ_ASSERT_IF(win, win->IsInnerWindow());
     nsCOMPtr<nsIScriptObjectPrincipal> scriptPrincipal =
       do_QueryInterface(globalObject);
     NS_ASSERTION(scriptPrincipal, "Global objects must implement "
                  "nsIScriptObjectPrincipal");