Bug 1130128, part 2 - CompilationScope() is infallible. r=bholley

This commit is contained in:
Andrew McCreight 2015-02-09 11:42:20 -08:00
Родитель 11e3402967
Коммит cd3a30da5c
1 изменённых файлов: 28 добавлений и 30 удалений

Просмотреть файл

@ -1541,40 +1541,38 @@ nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
// to avoid keeping the current compartment alive. // to avoid keeping the current compartment alive.
JS::Rooted<JSObject*> global(cx, xpc::CompilationScope()); JS::Rooted<JSObject*> global(cx, xpc::CompilationScope());
if (global) { JSAutoCompartment ac(cx, global);
JSAutoCompartment ac(cx, global); JS::CompileOptions options(cx, JSVERSION_LATEST);
JS::CompileOptions options(cx, JSVERSION_LATEST); options.setFileAndLine(url.get(), 1);
options.setFileAndLine(url.get(), 1); options.setNoScriptRval(true);
options.setNoScriptRval(true); JS::Rooted<JSScript*> script(cx);
JS::Rooted<JSScript*> script(cx);
if (aRunInGlobalScope) { if (aRunInGlobalScope) {
if (!JS::Compile(cx, JS::NullPtr(), options, srcBuf, &script)) { if (!JS::Compile(cx, JS::NullPtr(), options, srcBuf, &script)) {
return; return;
}
} else {
// We can't clone compile-and-go scripts.
options.setCompileAndGo(false);
if (!JS::Compile(cx, JS::NullPtr(), options, srcBuf, &script)) {
return;
}
} }
} else {
aScriptp.set(script); // We can't clone compile-and-go scripts.
options.setCompileAndGo(false);
nsAutoCString scheme; if (!JS::Compile(cx, JS::NullPtr(), options, srcBuf, &script)) {
uri->GetScheme(scheme); return;
// 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);
} }
} }
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);
}
} }
} }