diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 7a72c4eabc38..fdf9b9ae1a0d 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -18,6 +18,7 @@ #include "nsCOMPtr.h" #include "nsISupportsPrimitives.h" #include "nsReadableUtils.h" +#include "nsDOMJSUtils.h" #include "nsJSUtils.h" #include "nsIDocShell.h" #include "nsIDocShellTreeItem.h" @@ -564,7 +565,13 @@ NS_ScriptErrorReporter(JSContext *cx, ::JS_ClearPendingException(cx); MOZ_ASSERT(cx == nsContentUtils::GetCurrentJSContext()); - nsCOMPtr globalObject = GetEntryGlobal(); + nsCOMPtr globalObject; + if (nsIScriptContext* scx = GetScriptContextFromJSContext(cx)) { + nsCOMPtr outer = do_QueryInterface(scx->GetGlobalObject()); + if (outer) { + globalObject = static_cast(outer->GetCurrentInnerWindow()); + } + } if (globalObject) { nsCOMPtr win = do_QueryInterface(globalObject);