mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 10:45:42 +00:00
Bug 1518753 part 6 - Various fixes for jstests to work with same-compartment realms. r=anba
Differential Revision: https://phabricator.services.mozilla.com/D16171 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
4372b33619
commit
b1dd83671b
@ -250,7 +250,7 @@ assertEq(obj.toSource(),
|
||||
"({set foo() {}})");
|
||||
|
||||
// Methods from other global.
|
||||
// Treated as normal property.
|
||||
// Treated as normal property in the cross-compartment case.
|
||||
|
||||
let g = newGlobal();
|
||||
|
||||
@ -258,8 +258,9 @@ method = g.eval("({ foo() {} }).foo");
|
||||
|
||||
obj = {};
|
||||
Object.defineProperty(obj, "foo", {value: method, enumerable: true});
|
||||
assertEq(obj.toSource(),
|
||||
"({foo:foo() {}})");
|
||||
assertEq((obj.toSource() === "({foo:foo() {}})" ||
|
||||
obj.toSource() === "({foo() {}})"),
|
||||
true);
|
||||
|
||||
// Accessors from other global.
|
||||
// Accessor syntax is composed.
|
||||
|
@ -1,6 +1,6 @@
|
||||
// |reftest| skip-if(!xulRuntime.shell) -- needs Debugger
|
||||
|
||||
var g = newGlobal();
|
||||
var g = newGlobal({newCompartment: true});
|
||||
var dbg = new Debugger(g);
|
||||
var gw = dbg.addDebuggee(g);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// Summary: Ensure typed array validation is called for TypedArray.prototype.slice.
|
||||
|
||||
const otherGlobal = typeof newGlobal === "function" ? newGlobal() : undefined;
|
||||
const otherGlobal = typeof newGlobal === "function" ? newGlobal({newCompartment: true}) : undefined;
|
||||
const typedArrayLengths = [0, 1, 1024];
|
||||
|
||||
function createTestCases(TAConstructor, constructor, constructorCrossRealm) {
|
||||
@ -24,7 +24,8 @@ function createTestCases(TAConstructor, constructor, constructorCrossRealm) {
|
||||
species: constructor,
|
||||
method: otherGlobal[TAConstructor.name].prototype.slice,
|
||||
// Note: slice uses CallTypedArrayMethodIfWrapped, which results
|
||||
// in throwing a TypeError from the wrong Realm.
|
||||
// in throwing a TypeError from the wrong Realm if
|
||||
// cross-compartment.
|
||||
error: TypeError,
|
||||
});
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// Summary: Ensure typed array validation is called for TypedArray.prototype.subarray.
|
||||
|
||||
const otherGlobal = typeof newGlobal === "function" ? newGlobal() : undefined;
|
||||
const otherGlobal = typeof newGlobal === "function" ? newGlobal({newCompartment: true}) : undefined;
|
||||
const typedArrayLengths = [0, 1, 1024];
|
||||
|
||||
function createTestCases(TAConstructor, constructor, constructorCrossRealm) {
|
||||
@ -24,7 +24,8 @@ function createTestCases(TAConstructor, constructor, constructorCrossRealm) {
|
||||
species: constructor,
|
||||
method: otherGlobal[TAConstructor.name].prototype.subarray,
|
||||
// Note: subarray uses CallTypedArrayMethodIfWrapped, which results
|
||||
// in throwing a TypeError from the wrong Realm.
|
||||
// in throwing a TypeError from the wrong Realm if
|
||||
// cross-compartment.
|
||||
error: TypeError,
|
||||
});
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ assertEq(marks[2], 'black', 'global');
|
||||
assertEq(marks[3], 'dead', 'dead object should have been collected');
|
||||
|
||||
var wm = new WeakMap();
|
||||
var global = newGlobal();
|
||||
var global = newGlobal({newCompartment: true});
|
||||
|
||||
var wrapper1 = global.eval("Object.create(null)");
|
||||
wrapper1.name = "wrapper1";
|
||||
|
@ -144,11 +144,12 @@ function runNormalTests(global)
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
// Note: This is a TypeError from |global|, because the proxy's
|
||||
// |setImmutablePrototype| method is what actually throws here.
|
||||
// Note: In the cross-compartment case, this is a TypeError from |global|,
|
||||
// because the proxy's |setImmutablePrototype| method is what actually
|
||||
// throws here. That's why we check for TypeError from either global.
|
||||
// (Usually the method simply sets |*succeeded| to false and the
|
||||
// caller handles or throws as needed after that. But not here.)
|
||||
assertEq(e instanceof global.TypeError, true,
|
||||
assertEq(e instanceof global.TypeError || e instanceof TypeError, true,
|
||||
"expected TypeError, instead threw " + e);
|
||||
}
|
||||
|
||||
@ -167,8 +168,8 @@ function runNormalTests(global)
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
// NOTE: Again from |global|, as above.
|
||||
assertEq(e instanceof global.TypeError, true,
|
||||
// NOTE: Again from |global| or |this|, as above.
|
||||
assertEq(e instanceof global.TypeError || e instanceof TypeError, true,
|
||||
"expected TypeError, instead threw " + e);
|
||||
}
|
||||
}
|
||||
|
@ -560,12 +560,15 @@ function test()
|
||||
alien_view[3] = 77;
|
||||
check(() => view[3] == 77);
|
||||
|
||||
// Now check that the proxy setup is as expected
|
||||
check(() => isProxy(alien_view));
|
||||
check(() => isProxy(alien_buffer));
|
||||
check(() => isProxy(view)); // the real test
|
||||
// Now check that the proxy setup is as expected in the cross-compartment
|
||||
// case.
|
||||
if (isProxy(alien)) {
|
||||
check(() => isProxy(alien_view));
|
||||
check(() => isProxy(alien_buffer));
|
||||
check(() => isProxy(view)); // the real test
|
||||
}
|
||||
|
||||
// cross-compartment property access
|
||||
// cross-realm property access
|
||||
check(() => alien_buffer.byteLength == 7);
|
||||
check(() => alien_view.byteLength == 7);
|
||||
check(() => view.byteLength == 7);
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
var g = newGlobal();
|
||||
var g = newGlobal({newCompartment: true});
|
||||
var dbg = new g.Debugger(this);
|
||||
|
||||
if (typeof evalInFrame === 'function') {
|
||||
|
@ -2,7 +2,7 @@
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
if (typeof Debugger === 'function') {
|
||||
var g = newGlobal();
|
||||
var g = newGlobal({newCompartment: true});
|
||||
var dbg = new Debugger(g);
|
||||
dbg.onDebuggerStatement = function (frame) { frame.eval(''); };
|
||||
var s = '{ let ';
|
||||
|
Loading…
Reference in New Issue
Block a user