mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1143793 part 4. Stop supporting load.call(somerandomobj) in xpcshell. r=bholley
I guess I should have done this in bug 1097987.
This commit is contained in:
parent
2f422f4b65
commit
f0a4481730
@ -318,6 +318,11 @@ Load(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
if (!JS_IsGlobalObject(obj)) {
|
||||
JS_ReportError(cx, "Trying to load() into a non-global object");
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedString str(cx);
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
str = ToString(cx, args[i]);
|
||||
@ -337,23 +342,15 @@ Load(JSContext *cx, unsigned argc, jsval *vp)
|
||||
.setFileAndLine(filename.ptr(), 1)
|
||||
.setCompileAndGo(true);
|
||||
JS::Rooted<JSScript*> script(cx);
|
||||
JS::Compile(cx, obj, options, file, &script);
|
||||
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
|
||||
JS::Compile(cx, global, options, file, &script);
|
||||
fclose(file);
|
||||
if (!script)
|
||||
return false;
|
||||
|
||||
if (!compileOnly) {
|
||||
// XXXbz are we intentionally allowing load.call(someNonGlobalObject)?
|
||||
if (JS_IsGlobalObject(obj)) {
|
||||
if (!JS_ExecuteScript(cx, script)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
JS::AutoObjectVector scopeChain(cx);
|
||||
if (!scopeChain.append(obj) ||
|
||||
!JS_ExecuteScript(cx, scopeChain, script)) {
|
||||
return false;
|
||||
}
|
||||
if (!JS_ExecuteScript(cx, script)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user