mirror of
https://github.com/tc39/test262.git
synced 2025-09-24 10:38:30 +02:00
Replace createNewGlobal with $262.createRealm().global
This commit is contained in:
parent
eae3f3a386
commit
d77f35a4ec
@ -9,7 +9,7 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
var g = createNewGlobal();
|
||||
var g = $262.createRealm().global;
|
||||
|
||||
var arr = [1, 2, 3];
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(constructor.prototype.at.length, 1);
|
||||
|
||||
@ -32,10 +35,8 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(new constructor([0, 1]).at(NaN), 0); // ToInteger(NaN) = 0
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var at = createNewGlobal()[constructor.name].prototype.at;
|
||||
var at = otherGlobal[constructor.name].prototype.at;
|
||||
assert.sameValue(at.call(new constructor([1, 2, 3]), 2), 3);
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -10,7 +10,7 @@ description: |
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
let g = createNewGlobal();
|
||||
let g = $262.createRealm().global;
|
||||
|
||||
// Both TypedArray and ArrayBuffer from different global.
|
||||
for (let ctor of typedArrayConstructors) {
|
||||
|
@ -13,7 +13,7 @@ esid: pending
|
||||
|
||||
// Ensure the various error conditions are tested in the correct order.
|
||||
|
||||
const otherGlobal = createNewGlobal();
|
||||
const otherGlobal = $262.createRealm().global;
|
||||
|
||||
function* createBuffers(lengths = [0, 8]) {
|
||||
for (let length of lengths) {
|
||||
|
@ -15,7 +15,7 @@ esid: pending
|
||||
// ensure they are both created in the correct global.
|
||||
|
||||
const thisGlobal = this;
|
||||
const otherGlobal = createNewGlobal();
|
||||
const otherGlobal = $262.createRealm().global;
|
||||
|
||||
const typedArrays = [otherGlobal.eval("new Int32Array(0)")];
|
||||
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(constructor.prototype.entries.length, 0);
|
||||
assert.sameValue(constructor.prototype.entries.name, "entries");
|
||||
@ -26,14 +29,11 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.deepEqual(iterator.next(), {value: undefined, done: true});
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var otherGlobal = createNewGlobal();
|
||||
var entries = otherGlobal[constructor.name].prototype.entries;
|
||||
assert.deepEqual([...entries.call(new constructor(2))],
|
||||
[new otherGlobal.Array(0, 0), new otherGlobal.Array(1, 0)]);
|
||||
arr = new (createNewGlobal()[constructor.name])(2);
|
||||
arr = new (otherGlobal[constructor.name])(2);
|
||||
assert.sameValue([...constructor.prototype.entries.call(arr)].toString(), "0,0,1,0");
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
// Tests for TypedArray#every.
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(constructor.prototype.every.length, 1);
|
||||
@ -102,12 +105,10 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
});
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var every = createNewGlobal()[constructor.name].prototype.every;
|
||||
var every = otherGlobal[constructor.name].prototype.every;
|
||||
var sum = 0;
|
||||
assert.sameValue(every.call(new constructor([1, 2, 3]), v => sum += v), true);
|
||||
assert.sameValue(sum, 6);
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
@ -225,15 +226,13 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
});
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var some = createNewGlobal()[constructor.name].prototype.some;
|
||||
var some = otherGlobal[constructor.name].prototype.some;
|
||||
var sum = 0;
|
||||
assert.sameValue(some.call(new constructor([1, 2, 3]), v => {
|
||||
sum += v;
|
||||
return false;
|
||||
}), false);
|
||||
assert.sameValue(sum, 6);
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.deepEqual(constructor.prototype.fill.length, 1);
|
||||
|
||||
@ -46,10 +49,8 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.deepEqual(new constructor([1,1,1]).fill(2, 0, {valueOf: ()=>1}), new constructor([2,1,1]));
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var fill = createNewGlobal()[constructor.name].prototype.fill;
|
||||
var fill = otherGlobal[constructor.name].prototype.fill;
|
||||
assert.deepEqual(fill.call(new constructor([3, 2, 1]), 2), new constructor([2, 2, 2]));
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
// Tests for TypedArray#forEach
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(constructor.prototype.forEach.length, 1);
|
||||
@ -81,14 +84,12 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
});
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var forEach = createNewGlobal()[constructor.name].prototype.forEach;
|
||||
var forEach = otherGlobal[constructor.name].prototype.forEach;
|
||||
var sum = 0;
|
||||
forEach.call(new constructor([1, 2, 3]), v => {
|
||||
sum += v;
|
||||
});
|
||||
assert.sameValue(sum, 6);
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -9,13 +9,13 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
if (typeof createNewGlobal !== 'function')
|
||||
break;
|
||||
|
||||
var g = $262.createRealm().global;
|
||||
var h = $262.createRealm().global;
|
||||
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
// G[constructor.name].from, where G is any global, produces an array whose prototype
|
||||
// is G[constructor.name].prototype.
|
||||
var g = createNewGlobal();
|
||||
var ga = g[constructor.name].from([1, 2, 3]);
|
||||
assert.sameValue(ga instanceof g[constructor.name], true);
|
||||
|
||||
@ -27,7 +27,7 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
|
||||
// The default 'this' value received by a non-strict mapping function is
|
||||
// that function's global, not %TypedArray%.from's global or the caller's global.
|
||||
var h = createNewGlobal(), result = undefined;
|
||||
var result = undefined;
|
||||
h.mainGlobal = this;
|
||||
h.eval("function f() { mainGlobal.result = this; }");
|
||||
g[constructor.name].from.call(constructor, [5, 6, 7], h.f);
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(constructor.prototype.includes.length, 1);
|
||||
|
||||
@ -25,10 +28,8 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(new constructor([1, 2, 3]).includes(2, 100), false);
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var includes = createNewGlobal()[constructor.name].prototype.includes;
|
||||
var includes = otherGlobal[constructor.name].prototype.includes;
|
||||
assert.sameValue(includes.call(new constructor([1, 2, 3]), 2), true);
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -15,13 +15,13 @@ function checkResult(actual, expected)
|
||||
assert.sameValue(actual.done, expected.done);
|
||||
}
|
||||
|
||||
if (typeof $262.detachArrayBuffer === "function" && typeof createNewGlobal === "function")
|
||||
if (typeof $262.detachArrayBuffer === "function")
|
||||
{
|
||||
var iteratorFunction = Uint8Array.prototype[Symbol.iterator];
|
||||
|
||||
|
||||
var thisGlobal = this;
|
||||
var otherGlobal = createNewGlobal();
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
var thisNext = new Uint8Array()[Symbol.iterator]().next
|
||||
|
||||
|
@ -41,7 +41,7 @@ Object.defineProperty(i8Array, "length", {value: 15});
|
||||
(new Uint8Array(4)).set(i8Array, 3);
|
||||
|
||||
// Ensure that it works across globals
|
||||
let g2 = createNewGlobal();
|
||||
let g2 = $262.createRealm().global;
|
||||
|
||||
i8Array = new Int8Array(8);
|
||||
Object.defineProperty(i8Array, "length", {value: 0});
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(constructor.prototype.join.length, 1);
|
||||
|
||||
@ -29,10 +32,8 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.throws(TypeError, () => new constructor().join(Symbol()));
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var join = createNewGlobal()[constructor.name].prototype.join;
|
||||
var join = otherGlobal[constructor.name].prototype.join;
|
||||
assert.sameValue(join.call(new constructor([1, 2, 3]), "\t"), "1\t2\t3");
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(constructor.prototype.keys.length, 0);
|
||||
assert.sameValue(constructor.prototype.keys.name, "keys");
|
||||
@ -26,12 +29,10 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.deepEqual(iterator.next(), {value: undefined, done: true});
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var keys = createNewGlobal()[constructor.name].prototype.keys;
|
||||
var keys = otherGlobal[constructor.name].prototype.keys;
|
||||
assert.deepEqual([...keys.call(new constructor(2))], [0, 1]);
|
||||
arr = new (createNewGlobal()[constructor.name])(2);
|
||||
arr = new (otherGlobal[constructor.name])(2);
|
||||
assert.sameValue([...constructor.prototype.keys.call(arr)].toString(), "0,1");
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
// Tests for TypedArray#map.
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(constructor.prototype.map.length, 1);
|
||||
@ -110,12 +113,10 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
});
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var map = createNewGlobal()[constructor.name].prototype.map;
|
||||
var map = otherGlobal[constructor.name].prototype.map;
|
||||
var sum = 0;
|
||||
assert.compareArray(map.call(new constructor([1, 2, 3]), v => sum += v), new constructor([1,3,6]));
|
||||
assert.sameValue(sum, 6);
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
@ -234,13 +235,11 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
});
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var filter = createNewGlobal()[constructor.name].prototype.filter;
|
||||
var filter = otherGlobal[constructor.name].prototype.filter;
|
||||
var sum = 0;
|
||||
assert.compareArray(filter.call(new constructor([1, 2, 3]), v => {sum += v; return true}),
|
||||
new constructor([1,2,3]));
|
||||
assert.sameValue(sum, 6);
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(constructor.of.length, 0);
|
||||
|
||||
@ -40,12 +43,10 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(hits, 1);
|
||||
|
||||
// Behavior across compartments.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var newC = createNewGlobal()[constructor.name];
|
||||
var newC = otherGlobal[constructor.name];
|
||||
assert.sameValue(newC.of() instanceof newC, true);
|
||||
assert.sameValue(newC.of() instanceof constructor, false);
|
||||
assert.sameValue(newC.of.call(constructor) instanceof constructor, true);
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a constructor.
|
||||
var invalidConstructors = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
// Tests for TypedArray#reduce.
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(constructor.prototype.reduce.length, 1);
|
||||
@ -80,10 +83,8 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
});
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var reduce = createNewGlobal()[constructor.name].prototype.reduce;
|
||||
var reduce = otherGlobal[constructor.name].prototype.reduce;
|
||||
assert.sameValue(reduce.call(arr, (previous, current) => Math.min(previous, current)), 1);
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
@ -173,10 +174,8 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
});
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var reduceRight = createNewGlobal()[constructor.name].prototype.reduceRight;
|
||||
var reduceRight = otherGlobal[constructor.name].prototype.reduceRight;
|
||||
assert.sameValue(reduceRight.call(arr, (previous, current) => Math.min(previous, current)), 1);
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.deepEqual(constructor.prototype.reverse.length, 0);
|
||||
|
||||
@ -23,10 +26,8 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.deepEqual(new constructor([.1, .2, .3]).reverse(), new constructor([.3, .2, .1]));
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var reverse = createNewGlobal()[constructor.name].prototype.reverse;
|
||||
var reverse = otherGlobal[constructor.name].prototype.reverse;
|
||||
assert.deepEqual(reverse.call(new constructor([3, 2, 1])), new constructor([1, 2, 3]));
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -12,18 +12,17 @@ esid: pending
|
||||
// Test %TypedArray%.prototype.set(typedArray, offset) when called with wrapped
|
||||
// typed array.
|
||||
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var otherGlobal = createNewGlobal();
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
function taintLengthProperty(obj) {
|
||||
function taintLengthProperty(obj) {
|
||||
Object.defineProperty(obj, "length", {
|
||||
get() {
|
||||
assert.sameValue(true, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (var TA of anyTypedArrayConstructors) {
|
||||
for (var TA of anyTypedArrayConstructors) {
|
||||
var target = new TA(4);
|
||||
var source = new otherGlobal[TA.name]([10, 20]);
|
||||
|
||||
@ -33,10 +32,10 @@ if (typeof createNewGlobal === "function") {
|
||||
assert.compareArray(target, [0, 0, 0, 0]);
|
||||
target.set(source, 1);
|
||||
assert.compareArray(target, [0, 10, 20, 0]);
|
||||
}
|
||||
}
|
||||
|
||||
// Detachment checks are also applied correctly for wrapped typed arrays.
|
||||
if (typeof $262.detachArrayBuffer === "function") {
|
||||
// Detachment checks are also applied correctly for wrapped typed arrays.
|
||||
if (typeof $262.detachArrayBuffer === "function") {
|
||||
// Create typed array from different global (explicit constructor call).
|
||||
for (var TA of typedArrayConstructors) {
|
||||
var target = new TA(4);
|
||||
@ -85,6 +84,4 @@ if (typeof createNewGlobal === "function") {
|
||||
};
|
||||
assert.throws(TypeError, () => target.set(source, offset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ const float64Constructors = anyTypedArrayConstructors.filter(isFloatConstructor)
|
||||
.filter(c => c.BYTES_PER_ELEMENT === 8);
|
||||
|
||||
// Also test with cross-compartment typed arrays.
|
||||
const otherGlobal = createNewGlobal();
|
||||
const otherGlobal = $262.createRealm().global;
|
||||
float32Constructors.push(otherGlobal.Float32Array);
|
||||
float64Constructors.push(otherGlobal.Float64Array);
|
||||
|
||||
|
@ -9,7 +9,7 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
const otherGlobal = createNewGlobal();
|
||||
const otherGlobal = $262.createRealm().global;
|
||||
|
||||
// Create with new ArrayBuffer and offset.
|
||||
for (var constructor of typedArrayConstructors) {
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(constructor.prototype.slice.length, 2);
|
||||
|
||||
@ -28,11 +31,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.compareArray(new constructor([1, 2]).slice(1, 5), new constructor([2]));
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var slice = createNewGlobal()[constructor.name].prototype.slice;
|
||||
var slice = otherGlobal[constructor.name].prototype.slice;
|
||||
assert.compareArray(slice.call(new constructor([3, 2, 1]), 1),
|
||||
new constructor([2, 1]));
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
@ -13,8 +13,8 @@ esid: pending
|
||||
const floatConstructors = anyTypedArrayConstructors.filter(isFloatConstructor);
|
||||
|
||||
// Also test with cross-compartment wrapped typed arrays.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
const otherGlobal = createNewGlobal();
|
||||
{
|
||||
const otherGlobal = $262.createRealm().global;
|
||||
floatConstructors.push(otherGlobal.Float16Array);
|
||||
floatConstructors.push(otherGlobal.Float32Array);
|
||||
floatConstructors.push(otherGlobal.Float64Array);
|
||||
|
@ -15,10 +15,8 @@ esid: pending
|
||||
var sortFunctions = [Int32Array.prototype.sort];
|
||||
|
||||
// Also test with cross-compartment wrapped typed arrays.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var otherGlobal = createNewGlobal();
|
||||
sortFunctions.push(createNewGlobal().Int32Array.prototype.sort);
|
||||
}
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
sortFunctions.push(otherGlobal.Int32Array.prototype.sort);
|
||||
|
||||
// The bug manifests itself only with Float arrays,
|
||||
// but checking everything here just for sanity.
|
||||
|
@ -33,20 +33,20 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
assert.sameValue(detached, true);
|
||||
}
|
||||
|
||||
let otherGlobal = $262.createRealm().global;
|
||||
|
||||
// Ensure detachment check doesn't choke on wrapped typed array.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
{
|
||||
let ta = new Int32Array(3);
|
||||
let otherGlobal = createNewGlobal();
|
||||
otherGlobal.Int32Array.prototype.sort.call(ta, function(a, b) {
|
||||
return a - b;
|
||||
});
|
||||
}
|
||||
|
||||
// Ensure detaching buffer in comparator doesn't throw an error when the typed array is wrapped.
|
||||
if (typeof createNewGlobal === "function" && typeof $262.detachArrayBuffer === "function") {
|
||||
if (typeof $262.detachArrayBuffer === "function") {
|
||||
let detached = false;
|
||||
let ta = new Int32Array(3);
|
||||
let otherGlobal = createNewGlobal();
|
||||
otherGlobal.Int32Array.prototype.sort.call(ta, function(a,b) {
|
||||
if (!detached) {
|
||||
detached = true;
|
||||
|
@ -10,7 +10,7 @@ description: |
|
||||
esid: pending
|
||||
---*/
|
||||
// TypedArray.prototype.sort should work across globals
|
||||
let g2 = createNewGlobal();
|
||||
let g2 = $262.createRealm().global;
|
||||
assert.compareArray(
|
||||
Int32Array.prototype.sort.call(new g2.Int32Array([3, 2, 1])),
|
||||
new Int32Array([1, 2, 3])
|
||||
|
@ -73,7 +73,7 @@ for (let constructor of anyTypedArrayConstructors) {
|
||||
Number.prototype.toLocaleString = originalNumberToLocaleString;
|
||||
|
||||
// Calls Number.prototype.toLocaleString from the current Realm.
|
||||
const otherGlobal = createNewGlobal();
|
||||
const otherGlobal = $262.createRealm().global;
|
||||
for (let constructor of anyTypedArrayConstructors) {
|
||||
Number.prototype.toLocaleString = function() {
|
||||
"use strict";
|
||||
|
@ -12,7 +12,7 @@ esid: pending
|
||||
const TypedArrayPrototype = Object.getPrototypeOf(Int8Array.prototype);
|
||||
const {get: toStringTag} = Object.getOwnPropertyDescriptor(TypedArrayPrototype, Symbol.toStringTag);
|
||||
|
||||
const otherGlobal = createNewGlobal();
|
||||
const otherGlobal = $262.createRealm().global;
|
||||
|
||||
for (let constructor of anyTypedArrayConstructors) {
|
||||
let ta = new otherGlobal[constructor.name](0);
|
||||
|
@ -9,6 +9,9 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var otherGlobal = $262.createRealm().global;
|
||||
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(constructor.prototype.values.length, 0);
|
||||
assert.sameValue(constructor.prototype.values.name, "values");
|
||||
@ -27,12 +30,10 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.deepEqual(iterator.next(), {value: undefined, done: true});
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
var values = createNewGlobal()[constructor.name].prototype.values;
|
||||
var values = otherGlobal[constructor.name].prototype.values;
|
||||
assert.deepEqual([...values.call(new constructor([42, 36]))], [42, 36]);
|
||||
arr = new (createNewGlobal()[constructor.name])([42, 36]);
|
||||
arr = new (otherGlobal[constructor.name])([42, 36]);
|
||||
assert.sameValue([...constructor.prototype.values.call(arr)].toString(), "42,36");
|
||||
}
|
||||
|
||||
// Throws if `this` isn't a TypedArray.
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
|
Loading…
x
Reference in New Issue
Block a user