mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Backed out changeset 3dd4a5d6bef6 (bug 1814880) for causing SM bustages CLOSED TREE
This commit is contained in:
parent
ed2a64e98a
commit
13450d0c30
@ -1,5 +1,3 @@
|
||||
load(libdir + "asserts.js");
|
||||
|
||||
// Test with envChainObject in current global.
|
||||
{
|
||||
let global = newGlobal();
|
||||
@ -14,12 +12,3 @@ load(libdir + "asserts.js");
|
||||
assertEq(envChainObject.a, "test2");
|
||||
assertEq(evaluate("a", { global, envChainObject }), "test2");
|
||||
}
|
||||
|
||||
// Unqualified variable objects are not allowed.
|
||||
assertThrowsInstanceOf(() => {
|
||||
evaluate("10", { envChainObject: evalcx("") });
|
||||
}, Error);
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
evaluate("10", { envChainObject: evalReturningScope("1") });
|
||||
}, Error);
|
||||
|
@ -2336,18 +2336,12 @@ static bool Evaluate(JSContext* cx, unsigned argc, Value* vp) {
|
||||
cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
|
||||
"\"envChainObject\" passed to evaluate()", "not an object");
|
||||
return false;
|
||||
}
|
||||
|
||||
JSObject* obj = &v.toObject();
|
||||
if (obj->isUnqualifiedVarObj()) {
|
||||
} else if (v.toObject().is<GlobalObject>()) {
|
||||
JS_ReportErrorASCII(
|
||||
cx,
|
||||
"\"envChainObject\" passed to evaluate() should not be an "
|
||||
"unqualified variables object");
|
||||
"\"envChainObject\" passed to evaluate() should not be a global");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!envChain.append(obj)) {
|
||||
} else if (!envChain.append(&v.toObject())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,14 @@ evaluate("(function() { assertEq(someVar, 2);})()", evalOpt);
|
||||
evaluate("(function() { assertEq(this !== alsoSomeObject, true);})()", evalOpt);
|
||||
evaluate("(function() { assertEq(this.someVar, 1);})()", evalOpt);
|
||||
|
||||
// `this` is ShellWindowProxy instead of GlobalObject, and it's allowed.
|
||||
evaluate("assertEq(someVar, 1);", { envChainObject: this });
|
||||
var globalEvalOpt = {
|
||||
envChainObject: this
|
||||
};
|
||||
try {
|
||||
evaluate("assertEq(someVar, 1);", globalEvalOpt);
|
||||
throw new Error("Globals aren't allowed as a envChainObject argument to evaluate");
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
|
||||
reportCompare(true, true);
|
||||
|
@ -3324,7 +3324,8 @@ bool js::CreateObjectsForEnvironmentChain(JSContext* cx,
|
||||
#ifdef DEBUG
|
||||
for (size_t i = 0; i < chain.length(); ++i) {
|
||||
cx->check(chain[i]);
|
||||
MOZ_ASSERT(!chain[i]->isUnqualifiedVarObj());
|
||||
MOZ_ASSERT(!chain[i]->is<GlobalObject>() &&
|
||||
!chain[i]->is<NonSyntacticVariablesObject>());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user