Bug 1145294. Remove the obj argument from JS::CloneAndExecuteScript. r=luke
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 20 Mar 2015 00:34:08 -0400
changeset 263542 bcc3e98d780f8723bcb7e951100dfb1c5027041d
parent 263541 7971c5d94a1512789ea10b1a927c1b561919dddf
child 263543 6030e30ae43d368edcb74ee57867c964be41bf58
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1145294
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1145294. Remove the obj argument from JS::CloneAndExecuteScript. r=luke
dom/base/nsFrameMessageManager.cpp
dom/xul/XULDocument.cpp
js/src/builtin/TestingFunctions.cpp
js/src/jsapi.cpp
js/src/jsapi.h
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -1552,17 +1552,17 @@ nsMessageManagerScriptExecutor::LoadScri
 
   JS::Rooted<JSObject*> global(rt, mGlobal->GetJSObject());
   if (global) {
     AutoEntryScript aes(xpc::NativeGlobal(global));
     aes.TakeOwnershipOfErrorReporting();
     JSContext* cx = aes.cx();
     if (script) {
       if (aRunInGlobalScope) {
-        JS::CloneAndExecuteScript(cx, global, script);
+        JS::CloneAndExecuteScript(cx, script);
       } else {
         JS::Rooted<JSObject*> scope(cx);
         bool ok = js::ExecuteInGlobalAndReturnScope(cx, global, script, &scope);
         if (ok) {
           // Force the scope to stay alive.
           mAnonymousGlobalScopes.AppendElement(scope);
         }
       }
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -3576,17 +3576,17 @@ XULDocument::ExecuteScript(nsXULPrototyp
 
     JS::ExposeObjectToActiveJS(global);
     xpc_UnmarkGrayScript(scriptObject);
     JSAutoCompartment ac(cx, global);
 
     // 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;
 }
 
 
 nsresult
 XULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype,
                                         Element** aResult,
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -2358,17 +2358,17 @@ ShellCloneAndExecuteScript(JSContext *cx
     }
     if (!global->is<GlobalObject>()) {
         JS_ReportError(cx, "Argument must be a global object");
         return false;
     }
 
     AutoCompartment ac(cx, global);
 
-    if (!JS::CloneAndExecuteScript(cx, global, script))
+    if (!JS::CloneAndExecuteScript(cx, script))
         return false;
 
     args.rval().setUndefined();
     return true;
 }
 
 static bool
 IsSimdAvailable(JSContext *cx, unsigned argc, Value *vp)
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -4136,31 +4136,28 @@ JS_ExecuteScript(JSContext *cx, AutoObje
 
 MOZ_NEVER_INLINE JS_PUBLIC_API(bool)
 JS_ExecuteScript(JSContext *cx, AutoObjectVector &scopeChain, HandleScript scriptArg)
 {
     return ExecuteScript(cx, scopeChain, scriptArg, nullptr);
 }
 
 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<GlobalObject>() ?
-            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;
 
 static bool
 Evaluate(JSContext *cx, HandleObject scope, const ReadOnlyCompileOptions &optionsArg,
          SourceBufferHolder &srcBuf, MutableHandleValue rval)
 {
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -3743,17 +3743,17 @@ JS_ExecuteScript(JSContext *cx, JS::Auto
 
 namespace JS {
 
 /*
  * Like the above, but handles a cross-compartment script. If the script is
  * cross-compartment, it is cloned into the current compartment before executing.
  */
 extern JS_PUBLIC_API(bool)
-CloneAndExecuteScript(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<JSScript*> script);
+CloneAndExecuteScript(JSContext *cx, JS::Handle<JSScript*> script);
 
 } /* namespace JS */
 
 namespace JS {
 
 /*
  * Evaluate the given source buffer in the scope of the current global of cx.
  */