diff --git a/test/staging/sm/ArrayBuffer/slice-species.js b/test/staging/sm/ArrayBuffer/slice-species.js index 4de0cbf11d..8ca50b60ce 100644 --- a/test/staging/sm/ArrayBuffer/slice-species.js +++ b/test/staging/sm/ArrayBuffer/slice-species.js @@ -123,7 +123,7 @@ for (let [ctor, answer] of tests) { } // @@species from different global - let g = createNewGlobal(); + let g = $262.createRealm().global; g.eval("var MyArrayBuffer = class MyArrayBuffer extends ArrayBuffer {};"); a = arr.buffer; a.constructor = { diff --git a/test/staging/sm/Atomics/cross-compartment.js b/test/staging/sm/Atomics/cross-compartment.js index 21d6fa23cc..ab74078841 100644 --- a/test/staging/sm/Atomics/cross-compartment.js +++ b/test/staging/sm/Atomics/cross-compartment.js @@ -10,7 +10,7 @@ description: | esid: pending ---*/ -const otherGlobal = createNewGlobal(); +const otherGlobal = $262.createRealm().global; const intArrayConstructors = [ otherGlobal.Int32Array, diff --git a/test/staging/sm/Date/constructor-one-Date-argument.js b/test/staging/sm/Date/constructor-one-Date-argument.js index 8828397d81..b37a58e1d6 100644 --- a/test/staging/sm/Date/constructor-one-Date-argument.js +++ b/test/staging/sm/Date/constructor-one-Date-argument.js @@ -30,7 +30,7 @@ Date.prototype.valueOf = () => 42; d = new Date(new Date(8675309)); assert.sameValue(d.getTime(), 8675309); -var D = createNewGlobal().Date; +var D = $262.createRealm().global.Date; D.prototype.toString = D.prototype.valueOf = null; var d = new Date(new D(3141592654)); diff --git a/test/staging/sm/Date/defaultvalue.js b/test/staging/sm/Date/defaultvalue.js index b66205fe71..ce9fec8736 100644 --- a/test/staging/sm/Date/defaultvalue.js +++ b/test/staging/sm/Date/defaultvalue.js @@ -21,7 +21,7 @@ print(BUGNUMBER + ": " + summary); * BEGIN TEST * **************/ -function allTests() +function allTests(Date) { var DS = new Date(2010, 1, 1).toString(); @@ -182,13 +182,8 @@ function allTests() testInOperatorName(); } -allTests(); - -if (typeof createNewGlobal === "function") -{ - Date = createNewGlobal().Date; - allTests(); -} +allTests(Date); +allTests($262.createRealm().global.Date); /******************************************************************************/ diff --git a/test/staging/sm/Error/AggregateError.js b/test/staging/sm/Error/AggregateError.js index 8e86516e2b..8db3c803c3 100644 --- a/test/staging/sm/Error/AggregateError.js +++ b/test/staging/sm/Error/AggregateError.js @@ -74,7 +74,7 @@ assert.throws(TypeError, () => AggregateError()); assert.sameValue(writable, true); assert.sameValue(value.length, 0); - const g = createNewGlobal(); + const g = $262.createRealm().global; let obj = {}; let errors = new g.AggregateError([obj]).errors; diff --git a/test/staging/sm/Function/arguments-iterator.js b/test/staging/sm/Function/arguments-iterator.js index b4af4b63e8..bbd2dbd236 100644 --- a/test/staging/sm/Function/arguments-iterator.js +++ b/test/staging/sm/Function/arguments-iterator.js @@ -86,7 +86,7 @@ for (let f of mapped) { f(10, 20, 30); } -var g1 = createNewGlobal(); +var g1 = $262.createRealm().global; assert.sameValue(g1.eval(` function f(a, b, c) { return arguments[Symbol.iterator].name; @@ -166,7 +166,7 @@ for (let f of unmapped) { f([10], 20, 30); } -var g2 = createNewGlobal(); +var g2 = $262.createRealm().global; assert.sameValue(g2.eval(` function f([a], b, c) { return arguments[Symbol.iterator].name; diff --git a/test/staging/sm/JSON/parse-with-source.js b/test/staging/sm/JSON/parse-with-source.js index a26d76a62d..b3bcc95a55 100644 --- a/test/staging/sm/JSON/parse-with-source.js +++ b/test/staging/sm/JSON/parse-with-source.js @@ -121,7 +121,7 @@ esid: pending })(); (function checkErrorsComeFromCorrectRealm() { - const otherGlobal = createNewGlobal({newCompartment: true}); + const otherGlobal = $262.createRealm().global; assert.sameValue(TypeError !== otherGlobal.TypeError, true); assertErrorComesFromCorrectRealm = (fun, thisRealmType) => { diff --git a/test/staging/sm/Promise/bug-1289040.js b/test/staging/sm/Promise/bug-1289040.js index 9e4b9fc6dc..5bdc488259 100644 --- a/test/staging/sm/Promise/bug-1289040.js +++ b/test/staging/sm/Promise/bug-1289040.js @@ -9,7 +9,7 @@ description: | pending esid: pending ---*/ -var global = createNewGlobal(); +var global = $262.createRealm().global; Promise.prototype.then = global.Promise.prototype.then; p1 = new Promise(function f(r) { r(1); diff --git a/test/staging/sm/Proxy/proxy-with-revoked-arguments.js b/test/staging/sm/Proxy/proxy-with-revoked-arguments.js index 5ad3d5927e..ad06921959 100644 --- a/test/staging/sm/Proxy/proxy-with-revoked-arguments.js +++ b/test/staging/sm/Proxy/proxy-with-revoked-arguments.js @@ -49,7 +49,7 @@ new Proxy(p, {}); new Proxy({}, p); -var g = createNewGlobal(); +var g = $262.createRealm().global; p = g.eval(`var r = Proxy.revocable({}, {}); r.proxy;`); new Proxy(p, {}); diff --git a/test/staging/sm/Reflect/apply.js b/test/staging/sm/Reflect/apply.js index f34482046d..f139ca3cf0 100644 --- a/test/staging/sm/Reflect/apply.js +++ b/test/staging/sm/Reflect/apply.js @@ -70,7 +70,7 @@ assert.sameValue(Reflect.apply(new Proxy(f, {}), 13); // Cross-compartment wrappers: -var gw = createNewGlobal(); +var gw = $262.createRealm().global; assert.sameValue(Reflect.apply(gw.parseInt, undefined, ["45"]), diff --git a/test/staging/sm/Reflect/construct.js b/test/staging/sm/Reflect/construct.js index a5013f1391..b614cbc339 100644 --- a/test/staging/sm/Reflect/construct.js +++ b/test/staging/sm/Reflect/construct.js @@ -56,7 +56,7 @@ g = Derived.bind(null, "q"); assert.deepEqual(Reflect.construct(g, [8, 9]), new g(8, 9)); // Cross-compartment wrappers: -var g = createNewGlobal(); +var g = $262.createRealm().global; var local = {here: this}; g.eval("function F(arg) { this.arg = arg }"); assert.deepEqual(Reflect.construct(g.F, [local]), new g.F(local)); diff --git a/test/staging/sm/Reflect/ownKeys.js b/test/staging/sm/Reflect/ownKeys.js index 4b584d1909..82cac3b9ab 100644 --- a/test/staging/sm/Reflect/ownKeys.js +++ b/test/staging/sm/Reflect/ownKeys.js @@ -40,7 +40,7 @@ var cases = [ keys: ["0", "8", "773", // indexes in numeric order "str", "-1", "second str", // strings in insertion order sym, sym2]}, // symbols in insertion order - {object: createNewGlobal().Math, // cross-compartment wrapper + {object: $262.createRealm().global.Math, // cross-compartment wrapper keys: Reflect.ownKeys(Math)} ]; for (var {object, keys} of cases) diff --git a/test/staging/sm/Reflect/set.js b/test/staging/sm/Reflect/set.js index 2921286538..f760c84c21 100644 --- a/test/staging/sm/Reflect/set.js +++ b/test/staging/sm/Reflect/set.js @@ -124,7 +124,7 @@ assert.sameValue(log, "sp"); // When calling a cross-compartment wrapper, receiver is rewrapped for the // target compartment. -var g = createNewGlobal(); +var g = $262.createRealm().global; if (!("assert" in g) && "assert" in globalThis) g.assert = assert; // necessary when exporting to test262 if (!("assert.sameValue" in g)) diff --git a/test/staging/sm/RegExp/constructor-constructor.js b/test/staging/sm/RegExp/constructor-constructor.js index 461b554b5c..00f6cade46 100644 --- a/test/staging/sm/RegExp/constructor-constructor.js +++ b/test/staging/sm/RegExp/constructor-constructor.js @@ -14,7 +14,7 @@ var summary = "RegExp constructor should check pattern.constructor."; print(BUGNUMBER + ": " + summary); -var g = createNewGlobal(); +var g = $262.createRealm().global; var re = /foo/; assert.sameValue(RegExp(re), re); diff --git a/test/staging/sm/RegExp/constructor-regexp.js b/test/staging/sm/RegExp/constructor-regexp.js index c4a740e948..cc4bfe437c 100644 --- a/test/staging/sm/RegExp/constructor-regexp.js +++ b/test/staging/sm/RegExp/constructor-regexp.js @@ -39,7 +39,7 @@ assert.sameValue(sourceCalled, false); assert.sameValue(flagsCalled, false); // cross-compartment -var g = createNewGlobal(); +var g = $262.createRealm().global; var b = g.eval(` var b = /foo2/; var flagsCalled = false; diff --git a/test/staging/sm/RegExp/cross-compartment-getter.js b/test/staging/sm/RegExp/cross-compartment-getter.js index 0bd2176aa4..88bca7f8ce 100644 --- a/test/staging/sm/RegExp/cross-compartment-getter.js +++ b/test/staging/sm/RegExp/cross-compartment-getter.js @@ -9,7 +9,7 @@ description: | pending esid: pending ---*/ -const otherGlobal = createNewGlobal({newCompartment: true}); +const otherGlobal = $262.createRealm().global; let regExp = otherGlobal.eval("/a(b|c)/iy"); diff --git a/test/staging/sm/RegExp/prototype-different-global.js b/test/staging/sm/RegExp/prototype-different-global.js index e597e51d35..197e506b17 100644 --- a/test/staging/sm/RegExp/prototype-different-global.js +++ b/test/staging/sm/RegExp/prototype-different-global.js @@ -32,6 +32,5 @@ function test(otherGlobal) { assert.sameValue(RegExp.prototype.toString.call(otherRegExp.prototype), "/(?:)/"); } -test(createNewGlobal()); -test(createNewGlobal({newCompartment: true})); +test($262.createRealm().global); diff --git a/test/staging/sm/String/iterator_edge_cases.js b/test/staging/sm/String/iterator_edge_cases.js index c79d6a460a..9f1c01154f 100644 --- a/test/staging/sm/String/iterator_edge_cases.js +++ b/test/staging/sm/String/iterator_edge_cases.js @@ -25,10 +25,7 @@ TestStringIteratorPrototypeConfusion(); // cross-compartment iterator. function TestStringIteratorWrappers() { var iter = ""[Symbol.iterator](); - assert.deepEqual(iter.next.call(createNewGlobal().eval('"x"[Symbol.iterator]()')), + assert.deepEqual(iter.next.call($262.createRealm().global.eval('"x"[Symbol.iterator]()')), { value: "x", done: false }) } -if (typeof createNewGlobal === "function") { - TestStringIteratorWrappers(); -} - +TestStringIteratorWrappers(); diff --git a/test/staging/sm/String/matchAll.js b/test/staging/sm/String/matchAll.js index 8263ebd3f7..78f7998766 100644 --- a/test/staging/sm/String/matchAll.js +++ b/test/staging/sm/String/matchAll.js @@ -81,7 +81,7 @@ assertEqMatchResults("ababcca".matchAll("a"), matchResults("ababcca", /a/g)); // Cross-compartment tests. { - let otherGlobal = createNewGlobal(); + let otherGlobal = $262.createRealm().global; let iterator = otherGlobal.eval(`"ababcca".matchAll(/a/g)`); let expected = matchResults("ababcca", /a/g); diff --git a/test/staging/sm/String/replaceAll.js b/test/staging/sm/String/replaceAll.js index 52ba9650ae..e8d6d7fe68 100644 --- a/test/staging/sm/String/replaceAll.js +++ b/test/staging/sm/String/replaceAll.js @@ -13,7 +13,7 @@ function neverCalled() { assert.sameValue(true, false, "unexpected call"); } -const g = createNewGlobal(); +const g = $262.createRealm().global; assert.sameValue(typeof String.prototype.replaceAll, "function"); assert.sameValue(String.prototype.replaceAll.length, 2); diff --git a/test/staging/sm/class/extendBuiltinConstructors.js b/test/staging/sm/class/extendBuiltinConstructors.js index 893019e629..306c76d32c 100644 --- a/test/staging/sm/class/extendBuiltinConstructors.js +++ b/test/staging/sm/class/extendBuiltinConstructors.js @@ -104,7 +104,7 @@ testBuiltin(WeakSet); testBuiltin(ArrayBuffer); testBuiltinTypedArrays(); testBuiltin(DataView, new ArrayBuffer()); -testBuiltin(DataView, new (createNewGlobal().ArrayBuffer)()); +testBuiltin(DataView, new ($262.createRealm().global.ArrayBuffer)()); testBuiltin(String); testBuiltin(Array); testBuiltin(Array, 15); diff --git a/test/staging/sm/class/newTargetCCW.js b/test/staging/sm/class/newTargetCCW.js index 41d6679d34..5724620c41 100644 --- a/test/staging/sm/class/newTargetCCW.js +++ b/test/staging/sm/class/newTargetCCW.js @@ -10,7 +10,7 @@ description: | esid: pending ---*/ // Make sure we wrap the new target on CCW construct calls. -var g = createNewGlobal(); +var g = $262.createRealm().global; let f = g.eval('(function (expected) { this.accept = new.target === expected; })'); diff --git a/test/staging/sm/class/superPropProxies.js b/test/staging/sm/class/superPropProxies.js index dba771559b..f70ce13ad4 100644 --- a/test/staging/sm/class/superPropProxies.js +++ b/test/staging/sm/class/superPropProxies.js @@ -80,7 +80,7 @@ child.testStaticLookups(); assert.sameValue(new Proxy(({ method() { return super.hasOwnProperty("method"); } }), {}).method(), true); // What about a CCW? -var g = createNewGlobal(); +var g = $262.createRealm().global; var wrappedSuper = g.eval("({ method() { return super.hasOwnProperty('method'); } })"); assert.sameValue(wrappedSuper.method(), true); diff --git a/test/staging/sm/extensions/cross-global-eval-is-indirect.js b/test/staging/sm/extensions/cross-global-eval-is-indirect.js index faa3c84b2a..86db2aa9b1 100644 --- a/test/staging/sm/extensions/cross-global-eval-is-indirect.js +++ b/test/staging/sm/extensions/cross-global-eval-is-indirect.js @@ -33,33 +33,19 @@ function f() return [this, eval("this")]; } -var otherGlobalSameCompartment = createNewGlobal("same-compartment"); +var otherGlobal = $262.createRealm().global; -eval = otherGlobalSameCompartment.eval; +eval = otherGlobal.eval; res = new f(); assert.sameValue(res[0] !== res[1], true); assert.sameValue(res[0] !== this, true); assert.sameValue(res[0] instanceof f, true); -assert.sameValue(res[1], otherGlobalSameCompartment); +assert.sameValue(res[1], otherGlobal); res = f(); assert.sameValue(res[0] !== res[1], true); assert.sameValue(res[0], this); -assert.sameValue(res[1], otherGlobalSameCompartment); - -var otherGlobalDifferentCompartment = createNewGlobal(); - -eval = otherGlobalDifferentCompartment.eval; -res = new f(); -assert.sameValue(res[0] !== res[1], true); -assert.sameValue(res[0] !== this, true); -assert.sameValue(res[0] instanceof f, true); -assert.sameValue(res[1], otherGlobalDifferentCompartment); - -res = f(); -assert.sameValue(res[0] !== res[1], true); -assert.sameValue(res[0], this); -assert.sameValue(res[1], otherGlobalDifferentCompartment); +assert.sameValue(res[1], otherGlobal); /******************************************************************************/ diff --git a/test/staging/sm/extensions/dataview.js b/test/staging/sm/extensions/dataview.js index b291836ea3..b78f6c79d1 100644 --- a/test/staging/sm/extensions/dataview.js +++ b/test/staging/sm/extensions/dataview.js @@ -1564,7 +1564,7 @@ function test(sharedMem) { checkThrow(() => DataView.prototype.buffer, TypeError); // Protos and proxies, oh my! - var alien = createNewGlobal(); + var alien = $262.createRealm().global; var alien_data = alien.eval('data = ' + JSON.stringify(data1)); var alien_buffer = alien.eval(`buffer = new ${sharedMem ? 'Shared' : ''}ArrayBuffer(data.length)`); alien.eval('new Uint8Array(buffer).set(data)'); diff --git a/test/staging/sm/extensions/new-cross-compartment.js b/test/staging/sm/extensions/new-cross-compartment.js index c5590a6a24..33d68e892c 100644 --- a/test/staging/sm/extensions/new-cross-compartment.js +++ b/test/staging/sm/extensions/new-cross-compartment.js @@ -22,7 +22,7 @@ print(BUGNUMBER + ": " + summary); * BEGIN TEST * **************/ -var g = createNewGlobal(); +var g = $262.createRealm().global; var otherStr = new g.String("foo"); assert.sameValue(otherStr instanceof g.String, true); diff --git a/test/staging/sm/object/setPrototypeOf-cross-realm-cycle.js b/test/staging/sm/object/setPrototypeOf-cross-realm-cycle.js index e0224f283e..422056337b 100644 --- a/test/staging/sm/object/setPrototypeOf-cross-realm-cycle.js +++ b/test/staging/sm/object/setPrototypeOf-cross-realm-cycle.js @@ -12,7 +12,7 @@ esid: pending // The cycle check in 9.1.2 [[SetPrototypeOf]] prevents cross-realm cycles // involving only ordinary objects. -var gw = createNewGlobal(); +var gw = $262.createRealm().global; var obj = {}; var w = gw.Object.create(obj); diff --git a/test/staging/sm/regress/regress-636364.js b/test/staging/sm/regress/regress-636364.js index 2dd7e59a53..3a893be0ad 100644 --- a/test/staging/sm/regress/regress-636364.js +++ b/test/staging/sm/regress/regress-636364.js @@ -11,25 +11,14 @@ description: | pending esid: pending ---*/ -if (typeof createNewGlobal == 'function') { - var gsame = createNewGlobal('same-compartment'); - gsame.eval("function f() { return this; }"); - f = gsame.f; - assert.sameValue(f(), gsame); +var gnew = $262.createRealm().global; - gsame.eval("function g() { 'use strict'; return this; }"); - g = gsame.g; - assert.sameValue(g(), undefined); +gnew.eval("function f() { return this; }"); +f = gnew.f; +assert.sameValue(f(), gnew); - var gnew = createNewGlobal(); - - gnew.eval("function f() { return this; }"); - f = gnew.f; - assert.sameValue(f(), gnew); - - gnew.eval("function g() { 'use strict'; return this; }"); - g = gnew.g; - assert.sameValue(g(), undefined); -} +gnew.eval("function g() { 'use strict'; return this; }"); +g = gnew.g; +assert.sameValue(g(), undefined); diff --git a/test/staging/sm/syntax/yield-as-identifier.js b/test/staging/sm/syntax/yield-as-identifier.js index 6d8b0568e5..ca9a59f1e9 100644 --- a/test/staging/sm/syntax/yield-as-identifier.js +++ b/test/staging/sm/syntax/yield-as-identifier.js @@ -21,13 +21,13 @@ print(BUGNUMBER + ": " + summary); * BEGIN TEST * **************/ +var g = $262.createRealm().global; + function t(code) { var strictSemi = " 'use strict'; " + code; var strictASI = " 'use strict' \n " + code; - var g = createNewGlobal(); - g.Function(code); assert.throws(g.SyntaxError, () => g.Function(strictSemi));