From d24dd57c58883615d39992e6bdd8f379055a49f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Wed, 30 Apr 2025 14:15:56 +0200 Subject: [PATCH] Replace createNewGlobal with $262.createRealm().global in sm/Array --- ...-array-by-copy-cross-compartment-create.js | 4 +- ...array-by-copy-errors-from-correct-realm.js | 4 +- test/staging/sm/Array/from_realms.js | 55 +++++++++---------- test/staging/sm/Array/isArray.js | 2 +- test/staging/sm/Array/species.js | 3 +- 5 files changed, 32 insertions(+), 36 deletions(-) diff --git a/test/staging/sm/Array/change-array-by-copy-cross-compartment-create.js b/test/staging/sm/Array/change-array-by-copy-cross-compartment-create.js index 21fa225748..aa431e49a8 100644 --- a/test/staging/sm/Array/change-array-by-copy-cross-compartment-create.js +++ b/test/staging/sm/Array/change-array-by-copy-cross-compartment-create.js @@ -29,6 +29,4 @@ function test(otherGlobal) { } } -test(createNewGlobal()); -test(createNewGlobal({newCompartment: true})); - +test($262.createRealm().global); diff --git a/test/staging/sm/Array/change-array-by-copy-errors-from-correct-realm.js b/test/staging/sm/Array/change-array-by-copy-errors-from-correct-realm.js index 824fdcad34..dbf677c70a 100644 --- a/test/staging/sm/Array/change-array-by-copy-errors-from-correct-realm.js +++ b/test/staging/sm/Array/change-array-by-copy-errors-from-correct-realm.js @@ -83,6 +83,4 @@ function test(otherGlobal) { } } -test(createNewGlobal()); -test(createNewGlobal({newCompartment: true})); - +test($262.createRealm().global); diff --git a/test/staging/sm/Array/from_realms.js b/test/staging/sm/Array/from_realms.js index a97a506459..f2c848c72a 100644 --- a/test/staging/sm/Array/from_realms.js +++ b/test/staging/sm/Array/from_realms.js @@ -11,35 +11,34 @@ description: | pending esid: pending ---*/ -if (typeof createNewGlobal === 'function') { - // G.Array.from, where G is any global, produces an array whose prototype - // is G.Array.prototype. - var g = createNewGlobal(); - var ga = g.Array.from([1, 2, 3]); - assert.sameValue(ga instanceof g.Array, true); - // Even if G.Array is not passed in as the 'this' value to the call. - var from = g.Array.from - var ga2 = from([1, 2, 3]); - assert.sameValue(ga2 instanceof g.Array, true); +// G.Array.from, where G is any global, produces an array whose prototype +// is G.Array.prototype. +var g = $262.createRealm().global; +var ga = g.Array.from([1, 2, 3]); +assert.sameValue(ga instanceof g.Array, true); - // Array.from can be applied to a constructor from another realm. - var p = Array.from.call(g.Array, [1, 2, 3]); - assert.sameValue(p instanceof g.Array, true); - var q = g.Array.from.call(Array, [3, 4, 5]); - assert.sameValue(q instanceof Array, true); +// Even if G.Array is not passed in as the 'this' value to the call. +var from = g.Array.from +var ga2 = from([1, 2, 3]); +assert.sameValue(ga2 instanceof g.Array, true); - // The default 'this' value received by a non-strict mapping function is - // that function's global, not Array.from's global or the caller's global. - var h = createNewGlobal(), result = undefined; - h.mainGlobal = this; - h.eval("function f() { mainGlobal.result = this; }"); - g.Array.from.call(Array, [5, 6, 7], h.f); - // (Give each global in the test a name, for better error messages. But use - // globalName, because window.name is complicated.) - this.globalName = "main"; - g.globalName = "g"; - h.globalName = "h"; - assert.sameValue(result.globalName, "h"); -} +// Array.from can be applied to a constructor from another realm. +var p = Array.from.call(g.Array, [1, 2, 3]); +assert.sameValue(p instanceof g.Array, true); +var q = g.Array.from.call(Array, [3, 4, 5]); +assert.sameValue(q instanceof Array, true); +// The default 'this' value received by a non-strict mapping function is +// that function's global, not Array.from's global or the caller's global. +var h = $262.createRealm().global; +var result = undefined; +h.mainGlobal = this; +h.eval("function f() { mainGlobal.result = this; }"); +g.Array.from.call(Array, [5, 6, 7], h.f); +// (Give each global in the test a name, for better error messages. But use +// globalName, because window.name is complicated.) +this.globalName = "main"; +g.globalName = "g"; +h.globalName = "h"; +assert.sameValue(result.globalName, "h"); diff --git a/test/staging/sm/Array/isArray.js b/test/staging/sm/Array/isArray.js index 9a4abecd17..53cfb8b3e3 100644 --- a/test/staging/sm/Array/isArray.js +++ b/test/staging/sm/Array/isArray.js @@ -12,7 +12,7 @@ description: | esid: pending ---*/ var global = this; -var otherGlobal = createNewGlobal(); +var otherGlobal = $262.createRealm().global; var thisGlobal = () => global; var alternateGlobals = (function(i) { diff --git a/test/staging/sm/Array/species.js b/test/staging/sm/Array/species.js index c647c01967..2225a10262 100644 --- a/test/staging/sm/Array/species.js +++ b/test/staging/sm/Array/species.js @@ -14,6 +14,8 @@ var summary = 'Use ArraySpeciesCreate in Array.prototype.{concat,filter,map,slic print(BUGNUMBER + ": " + summary); +var g = $262.createRealm().global; + function test(funcName, args, expectedLength, expectedLogs) { // modified @@species function FakeArray(n) { @@ -128,7 +130,6 @@ function test(funcName, args, expectedLength, expectedLogs) { assert.sameValue(b.constructor, Array); // @@species from different global - var g = createNewGlobal(); g.eval("function FakeArray(n) { this.length = n; }"); a = [1, 2, 3, 4, 5]; a.constructor = {