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.
JS::Rooted<JSObject*> 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<JSScript*> script(cx);
JSAutoCompartment ac(cx, global);
JS::CompileOptions options(cx, JSVERSION_LATEST);
options.setFileAndLine(url.get(), 1);
options.setNoScriptRval(true);
JS::Rooted<JSScript*> 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);
}
}
}