diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp index 56ed4af46586..d79956c93ef3 100644 --- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -1541,40 +1541,38 @@ nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL, // to avoid keeping the current compartment alive. JS::Rooted global(cx, xpc::CompilationScope()); - if (global) { - JSAutoCompartment ac(cx, global); - JS::CompileOptions options(cx, JSVERSION_LATEST); - options.setFileAndLine(url.get(), 1); - options.setNoScriptRval(true); - JS::Rooted script(cx); + JSAutoCompartment ac(cx, global); + JS::CompileOptions options(cx, JSVERSION_LATEST); + options.setFileAndLine(url.get(), 1); + options.setNoScriptRval(true); + JS::Rooted script(cx); - if (aRunInGlobalScope) { - if (!JS::Compile(cx, JS::NullPtr(), options, srcBuf, &script)) { - return; - } - } else { - // We can't clone compile-and-go scripts. - options.setCompileAndGo(false); - if (!JS::Compile(cx, JS::NullPtr(), options, srcBuf, &script)) { - return; - } + if (aRunInGlobalScope) { + if (!JS::Compile(cx, JS::NullPtr(), options, srcBuf, &script)) { + return; } - - aScriptp.set(script); - - nsAutoCString scheme; - uri->GetScheme(scheme); - // We don't cache data: scripts! - if (aShouldCache && !scheme.EqualsLiteral("data")) { - nsFrameScriptObjectExecutorHolder* holder; - - // Root the object also for caching. - if (script) { - holder = new nsFrameScriptObjectExecutorHolder(cx, script, aRunInGlobalScope); - } - sCachedScripts->Put(aURL, holder); + } else { + // We can't clone compile-and-go scripts. + options.setCompileAndGo(false); + if (!JS::Compile(cx, JS::NullPtr(), options, srcBuf, &script)) { + return; } } + + aScriptp.set(script); + + nsAutoCString scheme; + uri->GetScheme(scheme); + // We don't cache data: scripts! + if (aShouldCache && !scheme.EqualsLiteral("data")) { + nsFrameScriptObjectExecutorHolder* holder; + + // Root the object also for caching. + if (script) { + holder = new nsFrameScriptObjectExecutorHolder(cx, script, aRunInGlobalScope); + } + sCachedScripts->Put(aURL, holder); + } } }