Debian Codegraph @

js/src/jit-test/tests/realms/bug1610189.js

raw
1 var g = newGlobal({sameCompartmentAs: this});
2 var newTarget = g.Function();
3 newTarget.prototype = undefined;
4
5 // Reflect.construct returns an object in the current realm
6 // but its prototype is g's Array.prototype.
7 var arr1 = Reflect.construct(Array, [], newTarget);
8 assertEq(objectGlobal(arr1), this);
9 assertEq(arr1.__proto__, g.Array.prototype);
10
11 // Calling cross-realm slice creates an object in that realm.
12 for (var i = 0; i < 10; i++) {
13 var arr2 = arr1.slice();
14 assertEq(objectGlobal(arr2), g);
15 }