Bug 1070842 - Switch to new-style exception reporting in LoadFrameScriptInternal. r=bz

This commit is contained in:
Bobby Holley 2014-09-29 15:34:21 +02:00
Родитель 0e8bf218c0
Коммит 22c9810140
1 изменённых файлов: 10 добавлений и 12 удалений

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

@ -29,6 +29,7 @@
#include "nsIDOMClassInfo.h"
#include "nsIDOMFile.h"
#include "xpcpublic.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/nsIContentParent.h"
#include "mozilla/dom/PermissionMessageUtils.h"
@ -1432,8 +1433,8 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL,
return;
}
AutoSafeJSContext cx;
JS::Rooted<JSScript*> script(cx);
JSRuntime* rt = CycleCollectedJSRuntime::Get()->Runtime();
JS::Rooted<JSScript*> script(rt);
nsFrameScriptObjectExecutorHolder* holder = sCachedScripts->Get(aURL);
if (holder && holder->WillRunInGlobalScope() == aRunInGlobalScope) {
@ -1446,26 +1447,23 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL,
shouldCache, &script);
}
JS::Rooted<JSObject*> global(cx, mGlobal->GetJSObject());
JS::Rooted<JSObject*> global(rt, mGlobal->GetJSObject());
if (global) {
JSAutoCompartment ac(cx, global);
bool ok = true;
AutoEntryScript aes(xpc::NativeGlobal(global));
aes.TakeOwnershipOfErrorReporting();
JSContext* cx = aes.cx();
if (script) {
if (aRunInGlobalScope) {
ok = JS::CloneAndExecuteScript(cx, global, script);
JS::CloneAndExecuteScript(cx, global, script);
} else {
JS::Rooted<JSObject*> scope(cx);
ok = js::ExecuteInGlobalAndReturnScope(cx, global, script, &scope);
if (ok){
bool ok = js::ExecuteInGlobalAndReturnScope(cx, global, script, &scope);
if (ok) {
// Force the scope to stay alive.
mAnonymousGlobalScopes.AppendElement(scope);
}
}
}
if (!ok) {
nsJSUtils::ReportPendingException(cx);
}
}
}