From ed41a09c4d812055378eeca46a1fa73af47c876e Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 26 Mar 2014 10:59:03 -0300 Subject: [PATCH] Bug 979481 - Don't depend on the default global for the SafeJSContext in nsJSUtils::ReportPendingException. r=bz --- dom/base/nsJSUtils.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp index ea0fb3958b4..c4f757a546b 100644 --- a/dom/base/nsJSUtils.cpp +++ b/dom/base/nsJSUtils.cpp @@ -120,6 +120,12 @@ nsJSUtils::ReportPendingException(JSContext *aContext) JS::Rooted scope(aContext); scope = scx ? scx->GetWindowProxy() : js::DefaultObjectForContextOrNull(aContext); + if (!scope) { + // The SafeJSContext has no default object associated with it. + MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(aContext == nsContentUtils::GetSafeJSContext()); + scope = xpc::GetSafeJSContextGlobal(); + } JSAutoCompartment ac(aContext, scope); JS_ReportPendingException(aContext); }