Merge pull request #3176 from tc39/rwaldron/rename-realm-shadowrealm

Renaming Realm -> ShadowRealm
This commit is contained in:
Leo Balter 2021-09-02 11:09:15 -07:00 committed by GitHub
commit e3902f5107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 330 additions and 330 deletions

View File

@ -249,9 +249,9 @@ resizable-arraybuffer
# https://github.com/tc39/proposal-temporal
Temporal
# Callable Boundary Realms
# ShadowRealm, née Callable Boundary Realms
# https://github.com/tc39/proposal-realms
callable-boundary-realms
ShadowRealm
# Array.prototype.findLast & Array.prototype.findLastIndex
# https://github.com/tc39/proposal-array-find-from-last

View File

@ -1,18 +0,0 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm-constructor
description: >
Realm is a constructor and has [[Construct]] internal method.
includes: [isConstructor.js]
features: [callable-boundary-realms, Reflect.construct]
---*/
assert.sameValue(
typeof Realm,
'function',
'This test must fail if Realm is not a function'
);
assert(isConstructor(Realm));
assert.sameValue(Object.getPrototypeOf(Realm), Function.prototype);
new Realm();

View File

@ -1,30 +0,0 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm-constructor
description: >
new Realm() returns a realm instance
info: |
Realm ( )
...
2. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Realm.prototype%",
« [[Realm]], [[ExecutionContext]] »).
...
13. Return O.
features: [callable-boundary-realms]
---*/
assert.sameValue(
typeof Realm,
'function',
'This test must fail if Realm is not a function'
);
var realm = new Realm();
assert(realm instanceof Realm);
assert.sameValue(
Object.getPrototypeOf(realm),
Realm.prototype,
'[[Prototype]] is set to %Realm.prototype%'
);

View File

@ -1,21 +0,0 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
description: >
Realm.prototype.evaluate validates realm object.
features: [callable-boundary-realms]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
);
const r = new Realm();
const bogus = {};
assert.throws(TypeError, function() {
r.evaluate.call(bogus, '');
}, 'throws a TypeError if this is not a Realm object');

View File

@ -1,31 +0,0 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.importvalue
description: >
Realm.prototype.importValue is not a constructor.
includes: [isConstructor.js]
features: [callable-boundary-realms, Reflect.construct]
---*/
assert.sameValue(
typeof Realm.prototype.importValue,
'function',
'This test must fail if Realm.prototype.importValue is not a function'
);
assert.sameValue(
isConstructor(Realm.prototype.importValue),
false,
'isConstructor(Realm.prototype.importValue) must return false'
);
assert.throws(TypeError, () => {
new Realm.prototype.importValue("", "name");
}, '`new Realm.prototype.importValue("")` throws TypeError');
const r = new Realm();
assert.throws(TypeError, () => {
new r.imporValue("./import-value_FIXTURE.js", "x");
}, '`new r.imporValue("...")` throws TypeError');

View File

@ -1,21 +0,0 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.importvalue
description: >
Realm.prototype.importValue validates realm object.
features: [callable-boundary-realms]
---*/
assert.sameValue(
typeof Realm.prototype.importValue,
'function',
'This test must fail if Realm.prototype.importValue is not a function'
);
const r = new Realm();
const bogus = {};
assert.throws(TypeError, function() {
r.importValue.call(bogus, "specifier", "name");
}, 'throws a TypeError if this is not a Realm object');

View File

@ -0,0 +1,18 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-shadowrealm-constructor
description: >
ShadowRealm is a constructor and has [[Construct]] internal method.
includes: [isConstructor.js]
features: [ShadowRealm, Reflect.construct]
---*/
assert.sameValue(
typeof ShadowRealm,
'function',
'This test must fail if ShadowRealm is not a function'
);
assert(isConstructor(ShadowRealm));
assert.sameValue(Object.getPrototypeOf(ShadowRealm), Function.prototype);
new ShadowRealm();

View File

@ -1,14 +1,14 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm-constructor
esid: sec-shadowrealm-constructor
description: >
The Realm constructor is the initial value of the "Realm" property of the global object.
The ShadowRealm constructor is the initial value of the "ShadowRealm" property of the global object.
includes: [propertyHelper.js]
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
verifyProperty(this, "Realm", {
verifyProperty(this, "ShadowRealm", {
enumerable: false,
writable: true,
configurable: true,

View File

@ -1,15 +1,15 @@
// Copyright (C) 2021 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm-constructor
esid: sec-shadowrealm-constructor
description: >
The Realm constructor is extensible
The ShadowRealm constructor is extensible
info: |
17 ECMAScript Standard Built-in Objects
Unless specified otherwise, the [[Extensible]] internal slot of a built-in
object initially has the value true.
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
assert.sameValue(Object.isExtensible(Realm), true);
assert.sameValue(Object.isExtensible(ShadowRealm), true);

View File

@ -2,15 +2,15 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm
esid: sec-shadowrealm
description: >
The new instance is extensible
info: |
Realm ( )
ShadowRealm ( )
...
2. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Realm.prototype%",
« [[Realm]], [[ExecutionContext]] »).
2. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%ShadowRealm.prototype%",
« [[ShadowRealm]], [[ExecutionContext]] »).
...
13. Return O.
@ -18,14 +18,14 @@ info: |
internal slots [[Prototype]] and [[Extensible]]. The latter will have its
value set to true.
includes: [propertyHelper.js]
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
const realm = new Realm();
const realm = new ShadowRealm();
assert(Object.isExtensible(realm));
Object.defineProperty(realm, 'foo', {});
Object.defineProperty(realm, 'foo', { configurable: true });
assert(realm.hasOwnProperty('foo'), 'confirms extensibility adding a new property');
Object.defineProperty(realm, 'foo', {

View File

@ -0,0 +1,30 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-shadowrealm-constructor
description: >
new ShadowRealm() returns a shadow realm instance
info: |
ShadowRealm ( )
...
2. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%ShadowRealm.prototype%",
« [[ShadowRealm]], [[ExecutionContext]] »).
...
13. Return O.
features: [ShadowRealm]
---*/
assert.sameValue(
typeof ShadowRealm,
'function',
'This test must fail if ShadowRealm is not a function'
);
var realm = new ShadowRealm();
assert(realm instanceof ShadowRealm);
assert.sameValue(
Object.getPrototypeOf(realm),
ShadowRealm.prototype,
'[[Prototype]] is set to %ShadowRealm.prototype%'
);

View File

@ -1,11 +1,11 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm-constructor
esid: sec-shadowrealm-constructor
description: >
The value of Realm.length is 0
The value of ShadowRealm.length is 0
info: |
Realm ( )
ShadowRealm ( )
Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified, this value
@ -17,10 +17,10 @@ info: |
the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
verifyProperty(Realm, "length", {
verifyProperty(ShadowRealm, "length", {
value: 0,
enumerable: false,
writable: false,

View File

@ -3,22 +3,22 @@
/*---
esid: sec-ecmascript-standard-built-in-objects
description: >
The value of Realm.name is 'Realm'
The value of ShadowRealm.name is 'ShadowRealm'
info: |
Every built-in function object, including constructors, has a "name" property
whose value is a String. Unless otherwise specified, this value is the name
that is given to the function in this specification.
Every built-in function object, including constructors, has a "name" property
whose value is a String. Unless otherwise specified, this value is the name
that is given to the function in this specification.
Unless otherwise specified, the "name" property of a built-in function
object has the attributes
Unless otherwise specified, the "name" property of a built-in function
object has the attributes
{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
verifyProperty(Realm, "name", {
value: "Realm",
verifyProperty(ShadowRealm, "name", {
value: "ShadowRealm",
enumerable: false,
writable: false,
configurable: true,

View File

@ -1,15 +1,15 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-properties-of-the-realm-constructor
esid: sec-properties-of-the-shadowrealm-constructor
description: >
The [[Prototype]] of Realm is Function.Prototype.
The [[Prototype]] of ShadowRealm is Function.Prototype.
info: |
Unless otherwise specified every built-in function and every built-in constructor
has the Function prototype object, which is the initial value of the expression
Function.prototype, as the value of its [[Prototype]] internal slot.
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
assert.sameValue(Object.getPrototypeOf(Realm), Function.prototype);
assert.sameValue(Object.getPrototypeOf(ShadowRealm), Function.prototype);

View File

@ -1,21 +1,21 @@
// Copyright (C) 2021 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype-@@tostringtag
esid: sec-shadowrealm.prototype-@@tostringtag
description: >
`Symbol.toStringTag` property descriptor
info: |
The initial value of the @@toStringTag property is the String value
"Realm".
"ShadowRealm".
This property has the attributes { [[Writable]]: false, [[Enumerable]]:
false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [callable-boundary-realms, Symbol.toStringTag]
features: [ShadowRealm, Symbol.toStringTag]
---*/
verifyProperty(Realm.prototype, Symbol.toStringTag, {
value: 'Realm',
verifyProperty(ShadowRealm.prototype, Symbol.toStringTag, {
value: 'ShadowRealm',
enumerable: false,
writable: false,
configurable: true

View File

@ -1,14 +1,14 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate is an ECMAScript Standard built-in object function.
ShadowRealm.prototype.evaluate is an ECMAScript Standard built-in object function.
includes: [propertyHelper.js]
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
verifyProperty(Realm.prototype, "evaluate", {
verifyProperty(ShadowRealm.prototype, "evaluate", {
enumerable: false,
writable: true,
configurable: true,

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate wraps errors from other realm into TypeErrors
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate wraps errors from other realm into TypeErrors
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
assert.throws(TypeError, () => r.evaluate('...'), 'SyntaxError => TypeError');
assert.throws(TypeError, () => r.evaluate('throw 42'), 'throw primitive => TypeError');

View File

@ -1,11 +1,11 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
The value of Realm.prototype.evaluate.length is 1
The value of ShadowRealm.prototype.evaluate.length is 1
info: |
Realm.prototype.evaluate ( sourceText )
ShadowRealm.prototype.evaluate ( sourceText )
Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified, this value
@ -17,10 +17,10 @@ info: |
the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
verifyProperty(Realm.prototype.evaluate, "length", {
verifyProperty(ShadowRealm.prototype.evaluate, "length", {
value: 1,
enumerable: false,
writable: false,

View File

@ -1,23 +1,23 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
The value of Realm.prototype.evaluate.name is 'evaluate'
The value of ShadowRealm.prototype.evaluate.name is 'evaluate'
info: |
Every built-in function object, including constructors, has a "name" property
whose value is a String. Unless otherwise specified, this value is the name
that is given to the function in this specification.
Every built-in function object, including constructors, has a "name" property
whose value is a String. Unless otherwise specified, this value is the name
that is given to the function in this specification.
Unless otherwise specified, the "name" property of a built-in function
object has the attributes
Unless otherwise specified, the "name" property of a built-in function
object has the attributes
{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
verifyProperty(Realm.prototype.evaluate, "name", {
verifyProperty(ShadowRealm.prototype.evaluate, "name", {
value: "evaluate",
enumerable: false,
writable: false,

View File

@ -1,30 +1,30 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate is not a constructor.
ShadowRealm.prototype.evaluate is not a constructor.
includes: [isConstructor.js]
features: [callable-boundary-realms, Reflect.construct]
features: [ShadowRealm, Reflect.construct]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
assert.sameValue(
isConstructor(Realm.prototype.evaluate),
isConstructor(ShadowRealm.prototype.evaluate),
false,
'isConstructor(Realm.prototype.evaluate) must return false'
'isConstructor(ShadowRealm.prototype.evaluate) must return false'
);
assert.throws(TypeError, () => {
new Realm.prototype.evaluate("");
}, '`new Realm.prototype.evaluate("")` throws TypeError');
new ShadowRealm.prototype.evaluate("");
}, '`new ShadowRealm.prototype.evaluate("")` throws TypeError');
const r = new Realm();
const r = new ShadowRealm();
r.evaluate('globalThis.x = 0');
assert.throws(TypeError, () => {

View File

@ -1,15 +1,15 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
The [[Prototype]] of Realm.prototype.evaluate is Function.Prototype.
The [[Prototype]] of ShadowRealm.prototype.evaluate is Function.Prototype.
Unless otherwise specified every built-in function and every built-in constructor
has the Function prototype object, which is the initial value of the expression
Function.prototype, as the value of its [[Prototype]] internal slot.
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
assert.sameValue(Object.getPrototypeOf(Realm.prototype.evaluate), Function.prototype);
assert.sameValue(Object.getPrototypeOf(ShadowRealm.prototype.evaluate), Function.prototype);

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate returns primitive values
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate returns primitive values
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
assert.sameValue(r.evaluate('1 + 1'), 2);
assert.sameValue(r.evaluate('null'), null);

View File

@ -1,23 +1,23 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate returns symbol values
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate returns symbol values
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
const s = r.evaluate('Symbol()');
assert.sameValue(typeof s, 'symbol');
assert.sameValue(s.constructor, Symbol, 'primitive does not expose other Realm constructor');
assert.sameValue(s.constructor, Symbol, 'primitive does not expose other ShadowRealm constructor');
assert.sameValue(Object.getPrototypeOf(s), Symbol.prototype);
assert.sameValue(r.evaluate('Symbol.for("x")'), Symbol.for('x'));
assert.sameValue(Symbol.prototype.toString.call(s), 'Symbol()');

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate throws a TypeError if evaluate resolves to non-primitive values
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate throws a TypeError if evaluate resolves to non-primitive values
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
assert.throws(TypeError, () => r.evaluate('globalThis'), 'globalThis');
assert.throws(TypeError, () => r.evaluate('[]'), 'array literal');

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate throws when argument is not a string.
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate throws when argument is not a string.
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
assert.throws(TypeError, () => r.evaluate(['1+1']));
assert.throws(TypeError, () => r.evaluate({ [Symbol.toPrimitive]() { return '1+1'; }}));

View File

@ -0,0 +1,21 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-shadowrealm.prototype.evaluate
description: >
ShadowRealm.prototype.evaluate validates realm object.
features: [ShadowRealm]
---*/
assert.sameValue(
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new ShadowRealm();
const bogus = {};
assert.throws(TypeError, function() {
r.evaluate.call(bogus, '');
}, 'throws a TypeError if this is not a ShadowRealm object');

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate wrapped function arguments are wrapped into the inner realm, extended.
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate wrapped function arguments are wrapped into the inner realm, extended.
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
const blueFn = (x, y) => x + y;
const redWrappedFn = r.evaluate(`

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate wrapped function arguments are wrapped into the inner realm
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate wrapped function arguments are wrapped into the inner realm
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
const blueFn = (x, y) => x + y;
const redWrappedFn = r.evaluate(`

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate wrapped function from return values share no identity.
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate wrapped function from return values share no identity.
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
r.evaluate(`
function fn() { return 42; }

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate wrapped function observing their scopes
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate wrapped function observing their scopes
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
let myValue;
function blueFn(x) {
@ -21,7 +21,7 @@ function blueFn(x) {
return myValue;
}
// cb is a new function in the red Realm that chains the call to the blueFn
// cb is a new function in the red ShadowRealm that chains the call to the blueFn
const redFunction = r.evaluate(`
var myValue = 'red';
0, function(cb) {

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate accepts callable objects
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate accepts callable objects
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
assert.sameValue(typeof r.evaluate('function fn() {} fn'), 'function', 'value from a fn declaration');
assert.sameValue(typeof r.evaluate('(function() {})'), 'function', 'function expression');

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate wrapped functions can resolve callable returns.
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate wrapped functions can resolve callable returns.
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
const wrapped = r.evaluate('x => y => x * y');
const nestedWrapped = wrapped(2);

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate wrapped functions produce new wrapping on each evaluation.
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate wrapped functions produce new wrapping on each evaluation.
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
r.evaluate(`
function fn() {

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate wrapped functions share no properties, extended
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate wrapped functions share no properties, extended
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
r.evaluate(`
function fn() { return 42; }

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.evaluate
esid: sec-shadowrealm.prototype.evaluate
description: >
Realm.prototype.evaluate wrapped functions share no properties
features: [callable-boundary-realms]
ShadowRealm.prototype.evaluate wrapped functions share no properties
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.evaluate,
typeof ShadowRealm.prototype.evaluate,
'function',
'This test must fail if Realm.prototype.evaluate is not a function'
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
const wrapped = r.evaluate(`
function fn() {

View File

@ -1,14 +1,14 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.importvalue
esid: sec-shadowrealm.prototype.importvalue
description: >
Realm.prototype.importValue is an ECMAScript Standard built-in object function.
ShadowRealm.prototype.importValue is an ECMAScript Standard built-in object function.
includes: [propertyHelper.js]
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
verifyProperty(Realm.prototype, "importValue", {
verifyProperty(ShadowRealm.prototype, "importValue", {
enumerable: false,
writable: true,
configurable: true,

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.importvalue
esid: sec-shadowrealm.prototype.importvalue
description: >
Realm.prototype.importValue coerces exportName to string.
features: [callable-boundary-realms]
ShadowRealm.prototype.importValue coerces exportName to string.
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.importValue,
typeof ShadowRealm.prototype.importValue,
'function',
'This test must fail if Realm.prototype.importValue is not a function'
'This test must fail if ShadowRealm.prototype.importValue is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
let count = 0;
const exportName = {

View File

@ -1,20 +1,20 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.importvalue
esid: sec-shadowrealm.prototype.importvalue
description: >
Realm.prototype.importValue can import a value.
ShadowRealm.prototype.importValue can import a value.
flags: [async, module]
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.importValue,
typeof ShadowRealm.prototype.importValue,
'function',
'This test must fail if Realm.prototype.importValue is not a function'
'This test must fail if ShadowRealm.prototype.importValue is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
r.importValue('./import-value_FIXTURE.js', 'x').then(x => {

View File

@ -1,9 +1,9 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.importvalue
esid: sec-shadowrealm.prototype.importvalue
description: >
The value of Realm.prototype.importValue.length is 2
The value of ShadowRealm.prototype.importValue.length is 2
info: |
Every built-in function object, including constructors, has a "length" property
whose value is a non-negative integral Number. Unless otherwise specified, this value
@ -15,10 +15,10 @@ info: |
the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
verifyProperty(Realm.prototype.importValue, "length", {
verifyProperty(ShadowRealm.prototype.importValue, "length", {
value: 2,
enumerable: false,
writable: false,

View File

@ -1,25 +1,25 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.importValue
esid: sec-shadowrealm.prototype.importValue
description: >
The value of Realm.prototype.importValue.name is 'importValue'
The value of ShadowRealm.prototype.importValue.name is 'importValue'
info: |
Realm.prototype.importValue
ShadowRealm.prototype.importValue
Every built-in function object, including constructors, has a "name" property
whose value is a String. Unless otherwise specified, this value is the name
that is given to the function in this specification.
Every built-in function object, including constructors, has a "name" property
whose value is a String. Unless otherwise specified, this value is the name
that is given to the function in this specification.
Unless otherwise specified, the "name" property of a built-in function
object has the attributes
Unless otherwise specified, the "name" property of a built-in function
object has the attributes
{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
verifyProperty(Realm.prototype.importValue, "name", {
verifyProperty(ShadowRealm.prototype.importValue, "name", {
value: "importValue",
enumerable: false,
writable: false,

View File

@ -0,0 +1,31 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-shadowrealm.prototype.importvalue
description: >
ShadowRealm.prototype.importValue is not a constructor.
includes: [isConstructor.js]
features: [ShadowRealm, Reflect.construct]
---*/
assert.sameValue(
typeof ShadowRealm.prototype.importValue,
'function',
'This test must fail if ShadowRealm.prototype.importValue is not a function'
);
assert.sameValue(
isConstructor(ShadowRealm.prototype.importValue),
false,
'isConstructor(ShadowRealm.prototype.importValue) must return false'
);
assert.throws(TypeError, () => {
new ShadowRealm.prototype.importValue("", "name");
}, '`new ShadowRealm.prototype.importValue("")` throws TypeError');
const r = new ShadowRealm();
assert.throws(TypeError, () => {
new r.imporValue("./import-value_FIXTURE.js", "x");
}, '`new r.imporValue("...")` throws TypeError');

View File

@ -1,15 +1,15 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.importvalue
esid: sec-shadowrealm.prototype.importvalue
description: >
The [[Prototype]] of Realm.prototype.importValue is AsyncFunction.Prototype.
The [[Prototype]] of ShadowRealm.prototype.importValue is AsyncFunction.Prototype.
info: |
Unless otherwise specified every built-in function and every built-in constructor
has the Function prototype object, which is the initial value of the expression
Function.prototype, as the value of its [[Prototype]] internal slot.
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
assert.sameValue(Object.getPrototypeOf(Realm.prototype.importValue), Function.prototype);
assert.sameValue(Object.getPrototypeOf(ShadowRealm.prototype.importValue), Function.prototype);

View File

@ -1,19 +1,19 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-realm.prototype.importvalue
esid: sec-shadowrealm.prototype.importvalue
description: >
Realm.prototype.importValue coerces specifier to string.
features: [callable-boundary-realms]
ShadowRealm.prototype.importValue coerces specifier to string.
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.importValue,
typeof ShadowRealm.prototype.importValue,
'function',
'This test must fail if Realm.prototype.importValue is not a function'
'This test must fail if ShadowRealm.prototype.importValue is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
let count = 0;
const specifier = {

View File

@ -3,15 +3,15 @@
/*---
esid: sec-realmimportvalue
description: >
Realm.prototype.importValue rejects when export name does not exist
ShadowRealm.prototype.importValue rejects when export name does not exist
info: |
RealmImportValue ( specifierString, exportNameString, callerRealm, evalRealm, evalContext )
Assert: Type(specifierString) is String.
Assert: Type(exportNameString) is String.
Assert: callerRealm is a Realm Record.
Assert: evalRealm is a Realm Record.
Assert: evalContext is an execution context associated to a Realm instance's [[ExecutionContext]].
Assert: callerRealm is a ShadowRealm Record.
Assert: evalRealm is a ShadowRealm Record.
Assert: evalContext is an execution context associated to a ShadowRealm instance's [[ExecutionContext]].
Let innerCapability be ! NewPromiseCapability(%Promise%).
Let runningContext be the running execution context.
If runningContext is not already suspended, suspend runningContext.
@ -35,16 +35,16 @@ info: |
...
flags: [async, module]
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
assert.sameValue(
typeof Realm.prototype.importValue,
typeof ShadowRealm.prototype.importValue,
'function',
'This test must fail if Realm.prototype.importValue is not a function'
'This test must fail if ShadowRealm.prototype.importValue is not a function'
);
const r = new Realm();
const r = new ShadowRealm();
r.importValue('./import-value_FIXTURE.js', 'y')
.then(

View File

@ -0,0 +1,21 @@
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-shadowrealm.prototype.importvalue
description: >
ShadowRealm.prototype.importValue validates realm object.
features: [ShadowRealm]
---*/
assert.sameValue(
typeof ShadowRealm.prototype.importValue,
'function',
'This test must fail if ShadowRealm.prototype.importValue is not a function'
);
const r = new ShadowRealm();
const bogus = {};
assert.throws(TypeError, function() {
r.importValue.call(bogus, "specifier", "name");
}, 'throws a TypeError if this is not a ShadowRealm object');

View File

@ -3,13 +3,13 @@
/*---
esid: sec-properties-of-the-realm-prototype-object
description: >
The [[Prototype]] of Realm.prototype is Object.Prototype.
The [[Prototype]] of ShadowRealm.prototype is Object.Prototype.
info: |
Unless otherwise specified every built-in prototype object has the Object prototype
object, which is the initial value of the expression Object.prototype, as the value
of its [[Prototype]] internal slot, except the Object prototype object itself.
features: [callable-boundary-realms]
features: [ShadowRealm]
---*/
assert.sameValue(Object.getPrototypeOf(Realm.prototype), Object.prototype);
assert.sameValue(Object.getPrototypeOf(ShadowRealm.prototype), Object.prototype);