From 9fb24e26589d38eb860f8b30006c666bbad0aa30 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 20 Mar 2015 00:34:08 -0400 Subject: [PATCH] Bug 1145294. Remove the obj argument from JS::CloneAndExecuteScript. r=luke --- dom/base/nsFrameMessageManager.cpp | 2 +- dom/xul/XULDocument.cpp | 2 +- js/src/builtin/TestingFunctions.cpp | 2 +- js/src/jsapi.cpp | 9 +++------ js/src/jsapi.h | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp index 18e3dfa16ddf..c5cc5d37d060 100644 --- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -1557,7 +1557,7 @@ nsMessageManagerScriptExecutor::LoadScriptInternal(const nsAString& aURL, JSContext* cx = aes.cx(); if (script) { if (aRunInGlobalScope) { - JS::CloneAndExecuteScript(cx, global, script); + JS::CloneAndExecuteScript(cx, script); } else { JS::Rooted scope(cx); bool ok = js::ExecuteInGlobalAndReturnScope(cx, global, script, &scope); diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp index 6acf0a114005..29fb260e8975 100644 --- a/dom/xul/XULDocument.cpp +++ b/dom/xul/XULDocument.cpp @@ -3581,7 +3581,7 @@ XULDocument::ExecuteScript(nsXULPrototypeScript *aScript) // The script is in the compilation scope. Clone it into the target scope // and execute it. On failure, ~AutoScriptEntry will handle exceptions, so // there is no need to manually check the return value. - JS::CloneAndExecuteScript(cx, global, scriptObject); + JS::CloneAndExecuteScript(cx, scriptObject); return NS_OK; } diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 7f6475f41b3f..a9de2d854120 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -2363,7 +2363,7 @@ ShellCloneAndExecuteScript(JSContext *cx, unsigned argc, Value *vp) AutoCompartment ac(cx, global); - if (!JS::CloneAndExecuteScript(cx, global, script)) + if (!JS::CloneAndExecuteScript(cx, script)) return false; args.rval().setUndefined(); diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index d207399ad3c8..e1809307419f 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -4141,21 +4141,18 @@ JS_ExecuteScript(JSContext *cx, AutoObjectVector &scopeChain, HandleScript scrip } JS_PUBLIC_API(bool) -JS::CloneAndExecuteScript(JSContext *cx, HandleObject obj, HandleScript scriptArg) +JS::CloneAndExecuteScript(JSContext *cx, HandleScript scriptArg) { CHECK_REQUEST(cx); - assertSameCompartment(cx, obj); RootedScript script(cx, scriptArg); if (script->compartment() != cx->compartment()) { - PollutedGlobalScopeOption globalScopeOption = obj->is() ? - HasCleanGlobalScope : HasPollutedGlobalScope; - script = CloneScript(cx, NullPtr(), NullPtr(), script, globalScopeOption); + script = CloneScript(cx, NullPtr(), NullPtr(), script); if (!script) return false; js::Debugger::onNewScript(cx, script); } - return ExecuteScript(cx, obj, script, nullptr); + return ExecuteScript(cx, cx->global(), script, nullptr); } static const unsigned LARGE_SCRIPT_LENGTH = 500*1024; diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 8baa3d7d709a..9d6660b4d94d 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -3748,7 +3748,7 @@ namespace JS { * cross-compartment, it is cloned into the current compartment before executing. */ extern JS_PUBLIC_API(bool) -CloneAndExecuteScript(JSContext *cx, JS::Handle obj, JS::Handle script); +CloneAndExecuteScript(JSContext *cx, JS::Handle script); } /* namespace JS */