From cd3a30da5c58b8e0bac636230be435840568abaa Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Mon, 9 Feb 2015 11:42:20 -0800 Subject: [PATCH] Bug 1130128, part 2 - CompilationScope() is infallible. r=bholley --- dom/base/nsFrameMessageManager.cpp | 58 +++++++++++++++--------------- 1 file changed, 28 insertions(+), 30 deletions(-) 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); + } } }