Bug 1097987 part 2. Change JS shell's Run to always compile/execute the script in global scope instead of using its this object. r=waldo

This commit is contained in:
Boris Zbarsky 2015-03-14 01:36:16 -04:00
parent 38cddbe9ac
commit 0d622c0e8f

View File

@ -1462,10 +1462,6 @@ Run(JSContext *cx, unsigned argc, jsval *vp)
return false;
}
RootedObject thisobj(cx, JS_THIS_OBJECT(cx, vp));
if (!thisobj)
return false;
RootedString str(cx, JS::ToString(cx, args[0]));
if (!str)
return false;
@ -1493,11 +1489,11 @@ Run(JSContext *cx, unsigned argc, jsval *vp)
.setFileAndLine(filename.ptr(), 1)
.setCompileAndGo(true)
.setNoScriptRval(true);
if (!JS_CompileUCScript(cx, thisobj, ucbuf, buflen, options, &script))
if (!JS_CompileUCScript(cx, cx->global(), ucbuf, buflen, options, &script))
return false;
}
if (!JS_ExecuteScript(cx, thisobj, script))
if (!JS_ExecuteScript(cx, cx->global(), script))
return false;
int64_t endClock = PRMJ_Now();