diff --git a/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-no-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-no-strict.js index 5179496733..3daa25f30e 100644 --- a/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-no-strict.js +++ b/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-no-strict.js @@ -80,19 +80,25 @@ info: | ---*/ async function fn() { - const ns = await import('./delete-exported-init_FIXTURE.js'); + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(delete ns.default, false, 'delete: default'); + assert.sameValue( + Reflect.deleteProperty(ns, 'default'), false, 'Reflect.deleteProperty: default' + ); + assert.sameValue(ns.default, 42, 'binding unmodified: default'); assert.sameValue(delete ns.local1, false, 'delete: local1'); assert.sameValue( Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' ); - assert.sameValue(ns.local1, 333, 'binding unmodified: local1'); + assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); assert.sameValue(delete ns.renamed, false, 'delete: renamed'); assert.sameValue( Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' ); - assert.sameValue(ns.renamed, 444, 'binding unmodified: renamed'); + assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); assert.sameValue(delete ns.indirect, false, 'delete: indirect'); assert.sameValue( @@ -100,7 +106,7 @@ async function fn() { false, 'Reflect.deleteProperty: indirect' ); - assert.sameValue(ns.indirect, 333, 'binding unmodified: indirect'); + assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect'); } fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-strict.js index 6b81d20282..9a93989c80 100644 --- a/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-strict.js +++ b/test/language/module-code/dynamic-import/ns/await-ns-delete-exported-init-strict.js @@ -80,7 +80,15 @@ info: | ---*/ async function fn() { - const ns = await import('./delete-exported-init_FIXTURE.js'); + const ns = await import('./module-code_FIXTURE.js'); + + assert.throws(TypeError, function() { + delete ns.default; + }, 'delete: default'); + assert.sameValue( + Reflect.deleteProperty(ns, 'default'), false, 'Reflect.deleteProperty: default' + ); + assert.sameValue(ns.default, 42, 'binding unmodified: default'); assert.throws(TypeError, function() { delete ns.local1; @@ -88,7 +96,7 @@ async function fn() { assert.sameValue( Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' ); - assert.sameValue(ns.local1, 333, 'binding unmodified: local1'); + assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); assert.throws(TypeError, function() { delete ns.renamed; @@ -96,7 +104,7 @@ async function fn() { assert.sameValue( Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' ); - assert.sameValue(ns.renamed, 444, 'binding unmodified: renamed'); + assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); assert.throws(TypeError, function() { delete ns.indirect; @@ -106,7 +114,7 @@ async function fn() { false, 'Reflect.deleteProperty: indirect' ); - assert.sameValue(ns.indirect, 333, 'binding unmodified: indirect'); + assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect'); } fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-found-init.js b/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-found-init.js new file mode 100644 index 0000000000..0577d03135 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-found-init.js @@ -0,0 +1,124 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-own-property-str-found-init.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[GetOwnProperty]] internal method with a string argument describing an initialized binding (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. + 4. Let value be ? O.[[Get]](P, O). + 5. Return PropertyDescriptor{[[Value]]: value, [[Writable]]: true, + [[Enumerable]]: true, [[Configurable]]: false }. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + var desc; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'local1'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'local1'); + assert.sameValue(desc.value, 'Test262'); + assert.sameValue(desc.enumerable, true, 'local1 enumerable'); + assert.sameValue(desc.writable, true, 'local1 writable'); + assert.sameValue(desc.configurable, false, 'local1 configurable'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'renamed'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); + assert.sameValue(desc.value, 'TC39'); + assert.sameValue(desc.enumerable, true, 'renamed enumerable'); + assert.sameValue(desc.writable, true, 'renamed writable'); + assert.sameValue(desc.configurable, false, 'renamed configurable'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'indirect'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'indirect'); + assert.sameValue(desc.value, 'Test262'); + assert.sameValue(desc.enumerable, true, 'indirect enumerable'); + assert.sameValue(desc.writable, true, 'indirect writable'); + assert.sameValue(desc.configurable, false, 'indirect configurable'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'default'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'default'); + assert.sameValue(desc.value, 42); + assert.sameValue(desc.enumerable, true, 'default enumerable'); + assert.sameValue(desc.writable, true, 'default writable'); + assert.sameValue(desc.configurable, false, 'default configurable'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-not-found.js b/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-not-found.js new file mode 100644 index 0000000000..abf689fcfe --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-str-not-found.js @@ -0,0 +1,117 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-own-property-str-not-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[GetOwnProperty]] internal method with a string argument describing a binding that cannot be found (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + var desc; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'local2'), + false, + 'hasOwnProperty: local2' + ); + desc = Object.getOwnPropertyDescriptor(ns, 'local2'); + assert.sameValue(desc, undefined, 'property descriptor for "local2"'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'toStringTag'), + false, + 'hasOwnProperty: toStringTag' + ); + desc = Object.getOwnPropertyDescriptor(ns, 'toStringTag'); + assert.sameValue(desc, undefined, 'property descriptor for "toStringTag"'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'iterator'), + false, + 'hasOwnProperty: iterator' + ); + desc = Object.getOwnPropertyDescriptor(ns, 'iterator'); + assert.sameValue(desc, undefined, 'property descriptor for "iterator"'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, '__proto__'), + false, + 'hasOwnProperty: __proto__' + ); + desc = Object.getOwnPropertyDescriptor(ns, '__proto__'); + assert.sameValue(desc, undefined, 'property descriptor for "__proto__"'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-sym.js b/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-sym.js new file mode 100644 index 0000000000..318788e28b --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-own-property-sym.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-own-property-sym.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[GetOwnProperty]] internal method with a Symbol argument (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ +var notFound = Symbol('test262'); + + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + var desc; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, Symbol.toStringTag), true + ); + desc = Object.getOwnPropertyDescriptor(ns, Symbol.toStringTag); + assert.sameValue(desc.value, ns[Symbol.toStringTag]); + assert.sameValue(desc.enumerable, false, 'Symbol.toStringTag enumerable'); + assert.sameValue(desc.writable, false, 'Symbol.toStringTag writable'); + assert.sameValue(desc.configurable, false, 'Symbol.toStringTag configurable'); + + assert.sameValue(Object.prototype.hasOwnProperty.call(ns, notFound), false); + desc = Object.getOwnPropertyDescriptor(ns, notFound); + assert.sameValue(desc, undefined); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-str-found.js b/test/language/module-code/dynamic-import/ns/await-ns-get-str-found.js new file mode 100644 index 0000000000..0a971a6944 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-str-found.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-str-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[Get]] internal method with a string argument for exported initialized bindings. (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(ns.local1, 'Test262'); + assert.sameValue(ns.renamed, 'TC39'); + assert.sameValue(ns.indirect, 'Test262'); + assert.sameValue(ns.default, 42); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-str-not-found.js b/test/language/module-code/dynamic-import/ns/await-ns-get-str-not-found.js new file mode 100644 index 0000000000..4c15994aee --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-str-not-found.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-str-not-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[Get]] internal method with a string argument for non-exported bindings (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 3. Let exports be the value of O's [[Exports]] internal slot. + 4. If P is not an element of exports, return undefined. + +---*/ +var local2; // not used + + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(ns.local2, undefined, 'key: local2'); + assert.sameValue(ns.toStringTag, undefined, 'key: toStringTag'); + assert.sameValue(ns.iterator, undefined, 'key: iterator'); + assert.sameValue(ns.__proto__, undefined, 'key: __proto__'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-sym-found.js b/test/language/module-code/dynamic-import/ns/await-ns-get-sym-found.js new file mode 100644 index 0000000000..da8c6c2797 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-sym-found.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-sym-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[Get]] internal method with a symbol argument that can be found (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryGet(O, P, Receiver). + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(typeof ns[Symbol.toStringTag], 'string'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-get-sym-not-found.js b/test/language/module-code/dynamic-import/ns/await-ns-get-sym-not-found.js new file mode 100644 index 0000000000..3366101da4 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-get-sym-not-found.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-sym-not-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[Get]] internal method with a symbol argument that cannot be found (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryGet(O, P, Receiver). + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(ns[Symbol('test262')], undefined, 'Symbol: test262'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-has-property-str-found-init.js b/test/language/module-code/dynamic-import/ns/await-ns-has-property-str-found-init.js new file mode 100644 index 0000000000..7e12f8b083 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-has-property-str-found-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-str-found-init.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a string argument for exported initialized bindings. (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert('local1' in ns, 'in: local1'); + assert(Reflect.has(ns, 'local1'), 'Reflect.has: local1'); + + assert('renamed' in ns, 'in: renamed'); + assert(Reflect.has(ns, 'renamed'), 'Reflect.has: renamed'); + + assert('indirect' in ns, 'in: indirect'); + assert(Reflect.has(ns, 'indirect'), 'Reflect.has: indirect'); + + assert('default' in ns, 'in: default'); + assert(Reflect.has(ns, 'default'), 'Reflect.has: default'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-has-property-str-not-found.js b/test/language/module-code/dynamic-import/ns/await-ns-has-property-str-not-found.js new file mode 100644 index 0000000000..7d241a47a0 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-has-property-str-not-found.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-str-not-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a string argument for non-exported bindings (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. + 4. Return false. + +---*/ +var local2; // not used + + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue('local2' in ns, false, 'in: local2'); + assert.sameValue(Reflect.has(ns, 'local2'), false, 'Reflect.has: local2'); + + assert.sameValue('toStringTag' in ns, false, 'in: toStringTag'); + assert.sameValue( + Reflect.has(ns, 'toStringTag'), false, 'Reflect.has: toStringTag' + ); + + assert.sameValue('iterator' in ns, false, 'in: iterator'); + assert.sameValue(Reflect.has(ns, 'iterator'), false, 'Reflect.has: iterator'); + + assert.sameValue('__proto__' in ns, false, 'in: __proto__'); + assert.sameValue( + Reflect.has(ns, '__proto__'), false, 'Reflect.has: __proto__' + ); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-found.js b/test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-found.js new file mode 100644 index 0000000000..1e68c121ca --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-found.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-sym-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a symbol argument that can be found (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryHasProperty(O, P). + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert(Symbol.toStringTag in ns, 'in: Symbol.toStringTag'); + assert(Reflect.has(ns, Symbol.toStringTag), 'Reflect.has: Symbol.toStringTag'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-not-found.js b/test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-not-found.js new file mode 100644 index 0000000000..fddf13b985 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-has-property-sym-not-found.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-sym-not-found.case +// - src/dynamic-import/namespace/await.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a symbol argument that cannot be found (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryHasProperty(O, P). + +---*/ +var sym = Symbol('test262'); + + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(sym in ns, false, 'in'); + assert.sameValue(Reflect.has(ns, sym), false, 'Reflect.has'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-own-property-keys-sort.js b/test/language/module-code/dynamic-import/ns/await-ns-own-property-keys-sort.js new file mode 100644 index 0000000000..b4487e09d1 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-own-property-keys-sort.js @@ -0,0 +1,130 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-own-property-keys-sort.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[OwnPropertyKeys]] internal method reflects the sorted order (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Let exports be a copy of the value of O's [[Exports]] internal slot. + 2. Let symbolKeys be ! OrdinaryOwnPropertyKeys(O). + 3. Append all the entries of symbolKeys to the end of exports. + 4. Return exports. + +---*/ + +async function fn() { + const ns = await import('./own-keys-sort_FIXTURE.js'); + + var stringKeys = Object.getOwnPropertyNames(ns); + + assert.sameValue(stringKeys.length, 16); + assert.sameValue(stringKeys[0], '$', 'stringKeys[0] === "$"'); + assert.sameValue(stringKeys[1], '$$', 'stringKeys[1] === "$$"'); + assert.sameValue(stringKeys[2], 'A', 'stringKeys[2] === "A"'); + assert.sameValue(stringKeys[3], 'Z', 'stringKeys[3] === "Z"'); + assert.sameValue(stringKeys[4], '_', 'stringKeys[4] === "_"'); + assert.sameValue(stringKeys[5], '__', 'stringKeys[5] === "__"'); + assert.sameValue(stringKeys[6], 'a', 'stringKeys[6] === "a"'); + assert.sameValue(stringKeys[7], 'aa', 'stringKeys[7] === "aa"'); + assert.sameValue(stringKeys[8], 'az', 'stringKeys[8] === "az"'); + assert.sameValue(stringKeys[9], 'default', 'stringKeys[9] === "default"'); + assert.sameValue(stringKeys[10], 'z', 'stringKeys[10] === "z"'); + assert.sameValue(stringKeys[11], 'za', 'stringKeys[11] === "za"'); + assert.sameValue(stringKeys[12], 'zz', 'stringKeys[12] === "zz"'); + assert.sameValue(stringKeys[13], '\u03bb', 'stringKeys[13] === "\u03bb"'); + assert.sameValue(stringKeys[14], '\u03bc', 'stringKeys[14] === "\u03bc"'); + assert.sameValue(stringKeys[15], '\u03c0', 'stringKeys[15] === "\u03c0"'); + + var allKeys = Reflect.ownKeys(ns); + assert( + allKeys.length >= 17, + 'at least as many keys as defined by the module and the specification' + ); + assert.sameValue(allKeys[0], '$', 'allKeys[0] === "$"'); + assert.sameValue(allKeys[1], '$$', 'allKeys[1] === "$$"'); + assert.sameValue(allKeys[2], 'A', 'allKeys[2] === "A"'); + assert.sameValue(allKeys[3], 'Z', 'allKeys[3] === "Z"'); + assert.sameValue(allKeys[4], '_', 'allKeys[4] === "_"'); + assert.sameValue(allKeys[5], '__', 'allKeys[5] === "__"'); + assert.sameValue(allKeys[6], 'a', 'allKeys[6] === "a"'); + assert.sameValue(allKeys[7], 'aa', 'allKeys[7] === "aa"'); + assert.sameValue(allKeys[8], 'az', 'allKeys[8] === "az"'); + assert.sameValue(allKeys[9], 'default', 'allKeys[9] === "default"'); + assert.sameValue(allKeys[10], 'z', 'allKeys[10] === "z"'); + assert.sameValue(allKeys[11], 'za', 'allKeys[11] === "za"'); + assert.sameValue(allKeys[12], 'zz', 'allKeys[12] === "zz"'); + assert.sameValue(allKeys[13], '\u03bb', 'allKeys[13] === "\u03bb"'); + assert.sameValue(allKeys[14], '\u03bc', 'allKeys[14] === "\u03bc"'); + assert.sameValue(allKeys[15], '\u03c0', 'allKeys[15] === "\u03c0"'); + assert( + allKeys.indexOf(Symbol.toStringTag) > 15, + 'keys array includes Symbol.toStringTag' + ); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-object.js b/test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-object.js new file mode 100644 index 0000000000..7fc2708a5d --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-object.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-prevent-extensions-object.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[PreventExtensions]] internal method returns `true` (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +async function fn() { + const ns = await import('./empty_FIXTURE.js'); + + // This invocation should not throw an exception + Object.preventExtensions(ns); + + assert.sameValue(Reflect.preventExtensions(ns), true); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-reflect.js b/test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-reflect.js new file mode 100644 index 0000000000..28edbf8fca --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-prevent-extensions-reflect.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-prevent-extensions-reflect.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[PreventExtensions]] internal method returns `true` (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +async function fn() { + const ns = await import('./empty_FIXTURE.js'); + + assert.sameValue(Reflect.preventExtensions(ns), true); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-prop-descs.js b/test/language/module-code/dynamic-import/ns/await-ns-prop-descs.js index 3d0d29471a..99362a9282 100644 --- a/test/language/module-code/dynamic-import/ns/await-ns-prop-descs.js +++ b/test/language/module-code/dynamic-import/ns/await-ns-prop-descs.js @@ -80,24 +80,31 @@ async function fn() { // object does not. var desc = Object.getOwnPropertyDescriptor(ns, 'default'); -assert.sameValue(desc.value, 42, 'default value is 42'); -assert.sameValue(desc.enumerable, true, 'default reports as enumerable'); -assert.sameValue(desc.writable, true, 'default reports as writable'); -assert.sameValue(desc.configurable, false, 'default reports as non-configurable'); +assert.sameValue(desc.value, 42, 'default: value is 42'); +assert.sameValue(desc.enumerable, true, 'default: is enumerable'); +assert.sameValue(desc.writable, true, 'default: is writable'); +assert.sameValue(desc.configurable, false, 'default: is non-configurable'); -desc = Object.getOwnPropertyDescriptor(ns, 'x'); +desc = Object.getOwnPropertyDescriptor(ns, 'local1'); -assert.sameValue(desc.value, 'Test262', 'x value is "Test262"'); -assert.sameValue(desc.enumerable, true, 'x reports as enumerable'); -assert.sameValue(desc.writable, true, 'x reports as writable'); -assert.sameValue(desc.configurable, false, 'x reports as non-configurable'); +assert.sameValue(desc.value, 'Test262', 'local1: value is "Test262"'); +assert.sameValue(desc.enumerable, true, 'local1: is enumerable'); +assert.sameValue(desc.writable, true, 'local1: is writable'); +assert.sameValue(desc.configurable, false, 'local1: is non-configurable'); -desc = Object.getOwnPropertyDescriptor(ns, 'z'); +desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); -assert.sameValue(desc.value, 42, 'z value is 42'); -assert.sameValue(desc.enumerable, true, 'z reports as enumerable'); -assert.sameValue(desc.writable, true, 'z reports as writable'); -assert.sameValue(desc.configurable, false, 'z reports as non-configurable'); +assert.sameValue(desc.value, 'TC39', 'renamed: value is TC39"'); +assert.sameValue(desc.enumerable, true, 'renamed: is enumerable'); +assert.sameValue(desc.writable, true, 'renamed: is writable'); +assert.sameValue(desc.configurable, false, 'renamed: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns, 'indirect'); + +assert.sameValue(desc.value, 'Test262', 'indirect: value is Test262"'); +assert.sameValue(desc.enumerable, true, 'indirect: is enumerable'); +assert.sameValue(desc.writable, true, 'indirect: is writable'); +assert.sameValue(desc.configurable, false, 'indirect: is non-configurable'); } fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-prototype.js b/test/language/module-code/dynamic-import/ns/await-ns-prototype.js index 4bbd93bbad..c21c6b84fb 100644 --- a/test/language/module-code/dynamic-import/ns/await-ns-prototype.js +++ b/test/language/module-code/dynamic-import/ns/await-ns-prototype.js @@ -74,6 +74,7 @@ info: | async function fn() { const ns = await import('./module-code_FIXTURE.js'); + assert.sameValue(ns instanceof Object, false); assert.sameValue(Object.getPrototypeOf(ns), null, 'prototype is null'); } diff --git a/test/language/module-code/dynamic-import/ns/await-ns-set-no-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-set-no-strict.js new file mode 100644 index 0000000000..858c0275ba --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-set-no-strict.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-no-strict.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[Set]] internal method consistently returns `false`, No Strict Mode (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, noStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ +var sym = Symbol('test262'); + + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Reflect.set(ns, 'local1'), false, 'Reflect.set: local1'); + assert.sameValue(ns.local1 = null, null, 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'local2'), false, 'Reflect.set: local2'); + assert.sameValue(ns.local2 = null, null, 'AssignmentExpression: local2'); + + assert.sameValue(Reflect.set(ns, 'renamed'), false, 'Reflect.set: renamed'); + assert.sameValue(ns.renamed = null, null, 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect'), false, 'Reflect.set: indirect'); + assert.sameValue(ns.indirect = null, null, 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default'), false, 'Reflect.set: default'); + assert.sameValue(ns.default = null, null, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, null), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.sameValue(ns[Symbol.toStringTag] = null, null, 'AssignmentExpression: Symbol.toStringTag'); + + assert.sameValue(Reflect.set(ns, sym), false, 'Reflect.set: sym'); + assert.sameValue(ns[sym] = null, null, 'AssignmentExpression: sym'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of-null.js b/test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of-null.js new file mode 100644 index 0000000000..02a75f470a --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of-null.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-prototype-of-null.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[SetPrototypeOf]] internal method returns `true` if passed `null` (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +async function fn() { + const ns = await import('./empty_FIXTURE.js'); + + assert.sameValue(typeof Object.setPrototypeOf, 'function'); + assert.sameValue(ns, Object.setPrototypeOf(ns, null)); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of.js b/test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of.js new file mode 100644 index 0000000000..819f8429cd --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-set-prototype-of.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-prototype-of.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[SetPrototypeOf]] internal method returns `false` (value from await resolving) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + var newProto = {}; + + assert.sameValue(typeof Object.setPrototypeOf, 'function'); + + assert.throws(TypeError, function() { + Object.setPrototypeOf(ns, newProto); + }); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-set-same-values-no-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-set-same-values-no-strict.js new file mode 100644 index 0000000000..e5e636b0c9 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-set-same-values-no-strict.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-same-values-no-strict.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[Set]] internal method consistently returns `false` even setting the same value - No Strict Mode (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, noStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Reflect.set(ns, 'local1', 'Test262'), false, 'Reflect.set: local1'); + assert.sameValue(ns.local1 = 'Test262', 'Test262', 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'renamed', 'TC39'), false, 'Reflect.set: renamed'); + assert.sameValue(ns.renamed = 'TC39', 'TC39', 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect', 'Test262'), false, 'Reflect.set: indirect'); + assert.sameValue(ns.indirect = 'Test262', 'Test262', 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default', 42), false, 'Reflect.set: default'); + assert.sameValue(ns.default = 42, 42, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, ns[Symbol.toStringTag]), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.sameValue(ns[Symbol.toStringTag] = ns[Symbol.toStringTag], 'Module', 'AssignmentExpression: Symbol.toStringTag'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-set-same-values-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-set-same-values-strict.js new file mode 100644 index 0000000000..c08d85d95c --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-set-same-values-strict.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-same-values-strict.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[Set]] internal method consistently returns `false` even setting the same value - Strict Mode (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, onlyStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Reflect.set(ns, 'local1', 'Test262'), false, 'Reflect.set: local1'); + assert.throws(TypeError, function() { + ns.local1 = 'Test262'; + }, 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'renamed', 'TC39'), false, 'Reflect.set: renamed'); + assert.throws(TypeError, function() { + ns.renamed = 'TC39'; + }, 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect', 'Test262'), false, 'Reflect.set: indirect'); + assert.throws(TypeError, function() { + ns.indirect = 'Test262'; + }, 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default', 42), false, 'Reflect.set: default'); + assert.throws(TypeError, function() { + ns.default = 42; + }, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, ns[Symbol.toStringTag]), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.throws(TypeError, function() { + ns[Symbol.toStringTag] = ns[Symbol.toStringTag]; + }, 'AssignmentExpression: Symbol.toStringTag'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/await-ns-set-strict.js b/test/language/module-code/dynamic-import/ns/await-ns-set-strict.js new file mode 100644 index 0000000000..31eda654d5 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/await-ns-set-strict.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-strict.case +// - src/dynamic-import/namespace/await.template +/*--- +description: The [[Set]] internal method consistently returns `false`, Strict Mode (value from await resolving) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, onlyStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ +var sym = Symbol('test262'); + + +async function fn() { + const ns = await import('./module-code_FIXTURE.js'); + + assert.sameValue(Reflect.set(ns, 'local1'), false, 'Reflect.set: local1'); + assert.throws(TypeError, function() { + ns.local1 = null; + }, 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'local2'), false, 'Reflect.set: local2'); + assert.throws(TypeError, function() { + ns.local2 = null; + }, 'AssignmentExpression: local2'); + + assert.sameValue(Reflect.set(ns, 'renamed'), false, 'Reflect.set: renamed'); + assert.throws(TypeError, function() { + ns.renamed = null; + }, 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect'), false, 'Reflect.set: indirect'); + assert.throws(TypeError, function() { + ns.indirect = null; + }, 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default'), false, 'Reflect.set: default'); + assert.throws(TypeError, function() { + ns.default = null; + }, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, null), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.throws(TypeError, function() { + ns[Symbol.toStringTag] = null; + }, 'AssignmentExpression: Symbol.toStringTag'); + + assert.sameValue(Reflect.set(ns, sym), false, 'Reflect.set: sym'); + assert.throws(TypeError, function() { + ns[sym] = null; + }, 'AssignmentExpression: sym'); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-no-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-no-strict.js index 41d13495bf..39847dde75 100644 --- a/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-no-strict.js +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-no-strict.js @@ -79,19 +79,25 @@ info: | ---*/ -import('./delete-exported-init_FIXTURE.js').then(ns => { +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(delete ns.default, false, 'delete: default'); + assert.sameValue( + Reflect.deleteProperty(ns, 'default'), false, 'Reflect.deleteProperty: default' + ); + assert.sameValue(ns.default, 42, 'binding unmodified: default'); assert.sameValue(delete ns.local1, false, 'delete: local1'); assert.sameValue( Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' ); - assert.sameValue(ns.local1, 333, 'binding unmodified: local1'); + assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); assert.sameValue(delete ns.renamed, false, 'delete: renamed'); assert.sameValue( Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' ); - assert.sameValue(ns.renamed, 444, 'binding unmodified: renamed'); + assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); assert.sameValue(delete ns.indirect, false, 'delete: indirect'); assert.sameValue( @@ -99,6 +105,6 @@ import('./delete-exported-init_FIXTURE.js').then(ns => { false, 'Reflect.deleteProperty: indirect' ); - assert.sameValue(ns.indirect, 333, 'binding unmodified: indirect'); + assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect'); }).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-strict.js index c07c9e9c18..c8fad64d43 100644 --- a/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-strict.js +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-delete-exported-init-strict.js @@ -79,7 +79,15 @@ info: | ---*/ -import('./delete-exported-init_FIXTURE.js').then(ns => { +import('./module-code_FIXTURE.js').then(ns => { + + assert.throws(TypeError, function() { + delete ns.default; + }, 'delete: default'); + assert.sameValue( + Reflect.deleteProperty(ns, 'default'), false, 'Reflect.deleteProperty: default' + ); + assert.sameValue(ns.default, 42, 'binding unmodified: default'); assert.throws(TypeError, function() { delete ns.local1; @@ -87,7 +95,7 @@ import('./delete-exported-init_FIXTURE.js').then(ns => { assert.sameValue( Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' ); - assert.sameValue(ns.local1, 333, 'binding unmodified: local1'); + assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); assert.throws(TypeError, function() { delete ns.renamed; @@ -95,7 +103,7 @@ import('./delete-exported-init_FIXTURE.js').then(ns => { assert.sameValue( Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' ); - assert.sameValue(ns.renamed, 444, 'binding unmodified: renamed'); + assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); assert.throws(TypeError, function() { delete ns.indirect; @@ -105,6 +113,6 @@ import('./delete-exported-init_FIXTURE.js').then(ns => { false, 'Reflect.deleteProperty: indirect' ); - assert.sameValue(ns.indirect, 333, 'binding unmodified: indirect'); + assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect'); }).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-found-init.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-found-init.js new file mode 100644 index 0000000000..5652eef119 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-found-init.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-own-property-str-found-init.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[GetOwnProperty]] internal method with a string argument describing an initialized binding (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. + 4. Let value be ? O.[[Get]](P, O). + 5. Return PropertyDescriptor{[[Value]]: value, [[Writable]]: true, + [[Enumerable]]: true, [[Configurable]]: false }. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + var desc; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'local1'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'local1'); + assert.sameValue(desc.value, 'Test262'); + assert.sameValue(desc.enumerable, true, 'local1 enumerable'); + assert.sameValue(desc.writable, true, 'local1 writable'); + assert.sameValue(desc.configurable, false, 'local1 configurable'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'renamed'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); + assert.sameValue(desc.value, 'TC39'); + assert.sameValue(desc.enumerable, true, 'renamed enumerable'); + assert.sameValue(desc.writable, true, 'renamed writable'); + assert.sameValue(desc.configurable, false, 'renamed configurable'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'indirect'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'indirect'); + assert.sameValue(desc.value, 'Test262'); + assert.sameValue(desc.enumerable, true, 'indirect enumerable'); + assert.sameValue(desc.writable, true, 'indirect writable'); + assert.sameValue(desc.configurable, false, 'indirect configurable'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'default'), true + ); + desc = Object.getOwnPropertyDescriptor(ns, 'default'); + assert.sameValue(desc.value, 42); + assert.sameValue(desc.enumerable, true, 'default enumerable'); + assert.sameValue(desc.writable, true, 'default writable'); + assert.sameValue(desc.configurable, false, 'default configurable'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-not-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-not-found.js new file mode 100644 index 0000000000..7e3e40c2d8 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-str-not-found.js @@ -0,0 +1,115 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-own-property-str-not-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[GetOwnProperty]] internal method with a string argument describing a binding that cannot be found (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryGetOwnProperty(O, P). + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is not an element of exports, return undefined. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + var desc; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'local2'), + false, + 'hasOwnProperty: local2' + ); + desc = Object.getOwnPropertyDescriptor(ns, 'local2'); + assert.sameValue(desc, undefined, 'property descriptor for "local2"'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'toStringTag'), + false, + 'hasOwnProperty: toStringTag' + ); + desc = Object.getOwnPropertyDescriptor(ns, 'toStringTag'); + assert.sameValue(desc, undefined, 'property descriptor for "toStringTag"'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, 'iterator'), + false, + 'hasOwnProperty: iterator' + ); + desc = Object.getOwnPropertyDescriptor(ns, 'iterator'); + assert.sameValue(desc, undefined, 'property descriptor for "iterator"'); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, '__proto__'), + false, + 'hasOwnProperty: __proto__' + ); + desc = Object.getOwnPropertyDescriptor(ns, '__proto__'); + assert.sameValue(desc, undefined, 'property descriptor for "__proto__"'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-sym.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-sym.js new file mode 100644 index 0000000000..6824a10f98 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-own-property-sym.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-own-property-sym.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[GetOwnProperty]] internal method with a Symbol argument (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ +var notFound = Symbol('test262'); + + +import('./module-code_FIXTURE.js').then(ns => { + + var desc; + + assert.sameValue( + Object.prototype.hasOwnProperty.call(ns, Symbol.toStringTag), true + ); + desc = Object.getOwnPropertyDescriptor(ns, Symbol.toStringTag); + assert.sameValue(desc.value, ns[Symbol.toStringTag]); + assert.sameValue(desc.enumerable, false, 'Symbol.toStringTag enumerable'); + assert.sameValue(desc.writable, false, 'Symbol.toStringTag writable'); + assert.sameValue(desc.configurable, false, 'Symbol.toStringTag configurable'); + + assert.sameValue(Object.prototype.hasOwnProperty.call(ns, notFound), false); + desc = Object.getOwnPropertyDescriptor(ns, notFound); + assert.sameValue(desc, undefined); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-found.js new file mode 100644 index 0000000000..7322efc541 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-found.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-str-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[Get]] internal method with a string argument for exported initialized bindings. (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 12. Let targetEnvRec be targetEnv's EnvironmentRecord. + 13. Return ? targetEnvRec.GetBindingValue(binding.[[BindingName]], true). + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(ns.local1, 'Test262'); + assert.sameValue(ns.renamed, 'TC39'); + assert.sameValue(ns.indirect, 'Test262'); + assert.sameValue(ns.default, 42); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-not-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-not-found.js new file mode 100644 index 0000000000..bae537b0d5 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-str-not-found.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-str-not-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[Get]] internal method with a string argument for non-exported bindings (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 3. Let exports be the value of O's [[Exports]] internal slot. + 4. If P is not an element of exports, return undefined. + +---*/ +var local2; // not used + + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(ns.local2, undefined, 'key: local2'); + assert.sameValue(ns.toStringTag, undefined, 'key: toStringTag'); + assert.sameValue(ns.iterator, undefined, 'key: iterator'); + assert.sameValue(ns.__proto__, undefined, 'key: __proto__'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-found.js new file mode 100644 index 0000000000..f2f4e20cfb --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-found.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-sym-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[Get]] internal method with a symbol argument that can be found (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryGet(O, P, Receiver). + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(typeof ns[Symbol.toStringTag], 'string'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-not-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-not-found.js new file mode 100644 index 0000000000..d34090ff6b --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-get-sym-not-found.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-get-sym-not-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[Get]] internal method with a symbol argument that cannot be found (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. If Type(P) is Symbol, then + a. Return ? OrdinaryGet(O, P, Receiver). + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(ns[Symbol('test262')], undefined, 'Symbol: test262'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-found-init.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-found-init.js new file mode 100644 index 0000000000..b142bc0aff --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-found-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-str-found-init.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a string argument for exported initialized bindings. (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert('local1' in ns, 'in: local1'); + assert(Reflect.has(ns, 'local1'), 'Reflect.has: local1'); + + assert('renamed' in ns, 'in: renamed'); + assert(Reflect.has(ns, 'renamed'), 'Reflect.has: renamed'); + + assert('indirect' in ns, 'in: indirect'); + assert(Reflect.has(ns, 'indirect'), 'Reflect.has: indirect'); + + assert('default' in ns, 'in: default'); + assert(Reflect.has(ns, 'default'), 'Reflect.has: default'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-not-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-not-found.js new file mode 100644 index 0000000000..acaef1dd02 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-str-not-found.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-str-not-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a string argument for non-exported bindings (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + [...] + 2. Let exports be the value of O's [[Exports]] internal slot. + 3. If P is an element of exports, return true. + 4. Return false. + +---*/ +var local2; // not used + + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue('local2' in ns, false, 'in: local2'); + assert.sameValue(Reflect.has(ns, 'local2'), false, 'Reflect.has: local2'); + + assert.sameValue('toStringTag' in ns, false, 'in: toStringTag'); + assert.sameValue( + Reflect.has(ns, 'toStringTag'), false, 'Reflect.has: toStringTag' + ); + + assert.sameValue('iterator' in ns, false, 'in: iterator'); + assert.sameValue(Reflect.has(ns, 'iterator'), false, 'Reflect.has: iterator'); + + assert.sameValue('__proto__' in ns, false, 'in: __proto__'); + assert.sameValue( + Reflect.has(ns, '__proto__'), false, 'Reflect.has: __proto__' + ); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-found.js new file mode 100644 index 0000000000..890a6127b1 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-found.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-sym-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a symbol argument that can be found (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryHasProperty(O, P). + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert(Symbol.toStringTag in ns, 'in: Symbol.toStringTag'); + assert(Reflect.has(ns, Symbol.toStringTag), 'Reflect.has: Symbol.toStringTag'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-not-found.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-not-found.js new file mode 100644 index 0000000000..d737f6a66b --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-has-property-sym-not-found.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-has-property-sym-not-found.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: Behavior of the [[HasProperty]] internal method with a symbol argument that cannot be found (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. If Type(P) is Symbol, return OrdinaryHasProperty(O, P). + +---*/ +var sym = Symbol('test262'); + + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(sym in ns, false, 'in'); + assert.sameValue(Reflect.has(ns, sym), false, 'Reflect.has'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-own-property-keys-sort.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-own-property-keys-sort.js new file mode 100644 index 0000000000..d773959f10 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-own-property-keys-sort.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-own-property-keys-sort.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[OwnPropertyKeys]] internal method reflects the sorted order (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol.toStringTag, dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Let exports be a copy of the value of O's [[Exports]] internal slot. + 2. Let symbolKeys be ! OrdinaryOwnPropertyKeys(O). + 3. Append all the entries of symbolKeys to the end of exports. + 4. Return exports. + +---*/ + +import('./own-keys-sort_FIXTURE.js').then(ns => { + + var stringKeys = Object.getOwnPropertyNames(ns); + + assert.sameValue(stringKeys.length, 16); + assert.sameValue(stringKeys[0], '$', 'stringKeys[0] === "$"'); + assert.sameValue(stringKeys[1], '$$', 'stringKeys[1] === "$$"'); + assert.sameValue(stringKeys[2], 'A', 'stringKeys[2] === "A"'); + assert.sameValue(stringKeys[3], 'Z', 'stringKeys[3] === "Z"'); + assert.sameValue(stringKeys[4], '_', 'stringKeys[4] === "_"'); + assert.sameValue(stringKeys[5], '__', 'stringKeys[5] === "__"'); + assert.sameValue(stringKeys[6], 'a', 'stringKeys[6] === "a"'); + assert.sameValue(stringKeys[7], 'aa', 'stringKeys[7] === "aa"'); + assert.sameValue(stringKeys[8], 'az', 'stringKeys[8] === "az"'); + assert.sameValue(stringKeys[9], 'default', 'stringKeys[9] === "default"'); + assert.sameValue(stringKeys[10], 'z', 'stringKeys[10] === "z"'); + assert.sameValue(stringKeys[11], 'za', 'stringKeys[11] === "za"'); + assert.sameValue(stringKeys[12], 'zz', 'stringKeys[12] === "zz"'); + assert.sameValue(stringKeys[13], '\u03bb', 'stringKeys[13] === "\u03bb"'); + assert.sameValue(stringKeys[14], '\u03bc', 'stringKeys[14] === "\u03bc"'); + assert.sameValue(stringKeys[15], '\u03c0', 'stringKeys[15] === "\u03c0"'); + + var allKeys = Reflect.ownKeys(ns); + assert( + allKeys.length >= 17, + 'at least as many keys as defined by the module and the specification' + ); + assert.sameValue(allKeys[0], '$', 'allKeys[0] === "$"'); + assert.sameValue(allKeys[1], '$$', 'allKeys[1] === "$$"'); + assert.sameValue(allKeys[2], 'A', 'allKeys[2] === "A"'); + assert.sameValue(allKeys[3], 'Z', 'allKeys[3] === "Z"'); + assert.sameValue(allKeys[4], '_', 'allKeys[4] === "_"'); + assert.sameValue(allKeys[5], '__', 'allKeys[5] === "__"'); + assert.sameValue(allKeys[6], 'a', 'allKeys[6] === "a"'); + assert.sameValue(allKeys[7], 'aa', 'allKeys[7] === "aa"'); + assert.sameValue(allKeys[8], 'az', 'allKeys[8] === "az"'); + assert.sameValue(allKeys[9], 'default', 'allKeys[9] === "default"'); + assert.sameValue(allKeys[10], 'z', 'allKeys[10] === "z"'); + assert.sameValue(allKeys[11], 'za', 'allKeys[11] === "za"'); + assert.sameValue(allKeys[12], 'zz', 'allKeys[12] === "zz"'); + assert.sameValue(allKeys[13], '\u03bb', 'allKeys[13] === "\u03bb"'); + assert.sameValue(allKeys[14], '\u03bc', 'allKeys[14] === "\u03bc"'); + assert.sameValue(allKeys[15], '\u03c0', 'allKeys[15] === "\u03c0"'); + assert( + allKeys.indexOf(Symbol.toStringTag) > 15, + 'keys array includes Symbol.toStringTag' + ); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-object.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-object.js new file mode 100644 index 0000000000..0210353312 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-object.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-prevent-extensions-object.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[PreventExtensions]] internal method returns `true` (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +import('./empty_FIXTURE.js').then(ns => { + + // This invocation should not throw an exception + Object.preventExtensions(ns); + + assert.sameValue(Reflect.preventExtensions(ns), true); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-reflect.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-reflect.js new file mode 100644 index 0000000000..8860abb4a3 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-prevent-extensions-reflect.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-prevent-extensions-reflect.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[PreventExtensions]] internal method returns `true` (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +import('./empty_FIXTURE.js').then(ns => { + + assert.sameValue(Reflect.preventExtensions(ns), true); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-prop-descs.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-prop-descs.js index e8785d32ee..dbd285644d 100644 --- a/test/language/module-code/dynamic-import/ns/promise-then-ns-prop-descs.js +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-prop-descs.js @@ -79,23 +79,30 @@ import('./module-code_FIXTURE.js').then(ns => { // object does not. var desc = Object.getOwnPropertyDescriptor(ns, 'default'); -assert.sameValue(desc.value, 42, 'default value is 42'); -assert.sameValue(desc.enumerable, true, 'default reports as enumerable'); -assert.sameValue(desc.writable, true, 'default reports as writable'); -assert.sameValue(desc.configurable, false, 'default reports as non-configurable'); +assert.sameValue(desc.value, 42, 'default: value is 42'); +assert.sameValue(desc.enumerable, true, 'default: is enumerable'); +assert.sameValue(desc.writable, true, 'default: is writable'); +assert.sameValue(desc.configurable, false, 'default: is non-configurable'); -desc = Object.getOwnPropertyDescriptor(ns, 'x'); +desc = Object.getOwnPropertyDescriptor(ns, 'local1'); -assert.sameValue(desc.value, 'Test262', 'x value is "Test262"'); -assert.sameValue(desc.enumerable, true, 'x reports as enumerable'); -assert.sameValue(desc.writable, true, 'x reports as writable'); -assert.sameValue(desc.configurable, false, 'x reports as non-configurable'); +assert.sameValue(desc.value, 'Test262', 'local1: value is "Test262"'); +assert.sameValue(desc.enumerable, true, 'local1: is enumerable'); +assert.sameValue(desc.writable, true, 'local1: is writable'); +assert.sameValue(desc.configurable, false, 'local1: is non-configurable'); -desc = Object.getOwnPropertyDescriptor(ns, 'z'); +desc = Object.getOwnPropertyDescriptor(ns, 'renamed'); -assert.sameValue(desc.value, 42, 'z value is 42'); -assert.sameValue(desc.enumerable, true, 'z reports as enumerable'); -assert.sameValue(desc.writable, true, 'z reports as writable'); -assert.sameValue(desc.configurable, false, 'z reports as non-configurable'); +assert.sameValue(desc.value, 'TC39', 'renamed: value is TC39"'); +assert.sameValue(desc.enumerable, true, 'renamed: is enumerable'); +assert.sameValue(desc.writable, true, 'renamed: is writable'); +assert.sameValue(desc.configurable, false, 'renamed: is non-configurable'); + +desc = Object.getOwnPropertyDescriptor(ns, 'indirect'); + +assert.sameValue(desc.value, 'Test262', 'indirect: value is Test262"'); +assert.sameValue(desc.enumerable, true, 'indirect: is enumerable'); +assert.sameValue(desc.writable, true, 'indirect: is writable'); +assert.sameValue(desc.configurable, false, 'indirect: is non-configurable'); }).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-prototype.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-prototype.js index 8b636c3c2a..5af5a859d3 100644 --- a/test/language/module-code/dynamic-import/ns/promise-then-ns-prototype.js +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-prototype.js @@ -73,6 +73,7 @@ info: | import('./module-code_FIXTURE.js').then(ns => { + assert.sameValue(ns instanceof Object, false); assert.sameValue(Object.getPrototypeOf(ns), null, 'prototype is null'); }).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-set-no-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-no-strict.js new file mode 100644 index 0000000000..759385ffed --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-no-strict.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-no-strict.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[Set]] internal method consistently returns `false`, No Strict Mode (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, noStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ +var sym = Symbol('test262'); + + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(Reflect.set(ns, 'local1'), false, 'Reflect.set: local1'); + assert.sameValue(ns.local1 = null, null, 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'local2'), false, 'Reflect.set: local2'); + assert.sameValue(ns.local2 = null, null, 'AssignmentExpression: local2'); + + assert.sameValue(Reflect.set(ns, 'renamed'), false, 'Reflect.set: renamed'); + assert.sameValue(ns.renamed = null, null, 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect'), false, 'Reflect.set: indirect'); + assert.sameValue(ns.indirect = null, null, 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default'), false, 'Reflect.set: default'); + assert.sameValue(ns.default = null, null, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, null), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.sameValue(ns[Symbol.toStringTag] = null, null, 'AssignmentExpression: Symbol.toStringTag'); + + assert.sameValue(Reflect.set(ns, sym), false, 'Reflect.set: sym'); + assert.sameValue(ns[sym] = null, null, 'AssignmentExpression: sym'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of-null.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of-null.js new file mode 100644 index 0000000000..95e9e8b15a --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of-null.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-prototype-of-null.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[SetPrototypeOf]] internal method returns `true` if passed `null` (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +import('./empty_FIXTURE.js').then(ns => { + + assert.sameValue(typeof Object.setPrototypeOf, 'function'); + assert.sameValue(ns, Object.setPrototypeOf(ns, null)); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of.js new file mode 100644 index 0000000000..9636c173e8 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-prototype-of.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-prototype-of.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[SetPrototypeOf]] internal method returns `false` (value from promise then) +esid: sec-finishdynamicimport +features: [dynamic-import] +flags: [generated, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + var newProto = {}; + + assert.sameValue(typeof Object.setPrototypeOf, 'function'); + + assert.throws(TypeError, function() { + Object.setPrototypeOf(ns, newProto); + }); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-no-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-no-strict.js new file mode 100644 index 0000000000..63d1246935 --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-no-strict.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-same-values-no-strict.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[Set]] internal method consistently returns `false` even setting the same value - No Strict Mode (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, noStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(Reflect.set(ns, 'local1', 'Test262'), false, 'Reflect.set: local1'); + assert.sameValue(ns.local1 = 'Test262', 'Test262', 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'renamed', 'TC39'), false, 'Reflect.set: renamed'); + assert.sameValue(ns.renamed = 'TC39', 'TC39', 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect', 'Test262'), false, 'Reflect.set: indirect'); + assert.sameValue(ns.indirect = 'Test262', 'Test262', 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default', 42), false, 'Reflect.set: default'); + assert.sameValue(ns.default = 42, 42, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, ns[Symbol.toStringTag]), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.sameValue(ns[Symbol.toStringTag] = ns[Symbol.toStringTag], 'Module', 'AssignmentExpression: Symbol.toStringTag'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-strict.js new file mode 100644 index 0000000000..edbc50d19b --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-same-values-strict.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-same-values-strict.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[Set]] internal method consistently returns `false` even setting the same value - Strict Mode (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, onlyStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(Reflect.set(ns, 'local1', 'Test262'), false, 'Reflect.set: local1'); + assert.throws(TypeError, function() { + ns.local1 = 'Test262'; + }, 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'renamed', 'TC39'), false, 'Reflect.set: renamed'); + assert.throws(TypeError, function() { + ns.renamed = 'TC39'; + }, 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect', 'Test262'), false, 'Reflect.set: indirect'); + assert.throws(TypeError, function() { + ns.indirect = 'Test262'; + }, 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default', 42), false, 'Reflect.set: default'); + assert.throws(TypeError, function() { + ns.default = 42; + }, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, ns[Symbol.toStringTag]), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.throws(TypeError, function() { + ns[Symbol.toStringTag] = ns[Symbol.toStringTag]; + }, 'AssignmentExpression: Symbol.toStringTag'); + +}).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/ns/promise-then-ns-set-strict.js b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-strict.js new file mode 100644 index 0000000000..4518fc4d3e --- /dev/null +++ b/test/language/module-code/dynamic-import/ns/promise-then-ns-set-strict.js @@ -0,0 +1,120 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/ns-set-strict.case +// - src/dynamic-import/namespace/promise.template +/*--- +description: The [[Set]] internal method consistently returns `false`, Strict Mode (value from promise then) +esid: sec-finishdynamicimport +features: [Symbol, Symbol.toStringTag, dynamic-import] +flags: [generated, onlyStrict, async] +info: | + Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) + + 1. If completion is an abrupt completion, ... + 2. Otherwise, + ... + d. Let namespace be GetModuleNamespace(moduleRecord). + e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). + f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). + + Runtime Semantics: GetModuleNamespace ( module ) + + ... + 3. Let namespace be module.[[Namespace]]. + 4. If namespace is undefined, then + a. Let exportedNames be ? module.GetExportedNames(« »). + b. Let unambiguousNames be a new empty List. + c. For each name that is an element of exportedNames, do + i. Let resolution be ? module.ResolveExport(name, « »). + ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. + d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). + 5. Return namespace. + + ModuleNamespaceCreate ( module, exports ) + + ... + 4. Let M be a newly created object. + 5. Set M's essential internal methods to the definitions specified in 9.4.6. + 7. Let sortedExports be a new List containing the same values as the list exports where the + values are ordered as if an Array of the same values had been sorted using Array.prototype.sort + using undefined as comparefn. + 8. Set M.[[Exports]] to sortedExports. + 9. Create own properties of M corresponding to the definitions in 26.3. + 10. Set module.[[Namespace]] to M. + 11. Return M. + + 26.3 Module Namespace Objects + + A Module Namespace Object is a module namespace exotic object that provides runtime + property-based access to a module's exported bindings. There is no constructor function for + Module Namespace Objects. Instead, such an object is created for each module that is imported + by an ImportDeclaration that includes a NameSpaceImport. + + In addition to the properties specified in 9.4.6 each Module Namespace Object has the + following own property: + + 26.3.1 @@toStringTag + + The initial value of the @@toStringTag property is the String value "Module". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + + Module Namespace Exotic Objects + + A module namespace object is an exotic object that exposes the bindings exported from an + ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed + own properties of a module namespace exotic object and the binding names exported by the + Module. The exported bindings include any bindings that are indirectly exported using export * + export items. Each String-valued own property key is the StringValue of the corresponding + exported binding name. These are the only String-keyed properties of a module namespace exotic + object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false }. Module namespace objects are not extensible. + + + 1. Return false. + +---*/ +var sym = Symbol('test262'); + + +import('./module-code_FIXTURE.js').then(ns => { + + assert.sameValue(Reflect.set(ns, 'local1'), false, 'Reflect.set: local1'); + assert.throws(TypeError, function() { + ns.local1 = null; + }, 'AssignmentExpression: local1'); + + assert.sameValue(Reflect.set(ns, 'local2'), false, 'Reflect.set: local2'); + assert.throws(TypeError, function() { + ns.local2 = null; + }, 'AssignmentExpression: local2'); + + assert.sameValue(Reflect.set(ns, 'renamed'), false, 'Reflect.set: renamed'); + assert.throws(TypeError, function() { + ns.renamed = null; + }, 'AssignmentExpression: renamed'); + + assert.sameValue(Reflect.set(ns, 'indirect'), false, 'Reflect.set: indirect'); + assert.throws(TypeError, function() { + ns.indirect = null; + }, 'AssignmentExpression: indirect'); + + assert.sameValue(Reflect.set(ns, 'default'), false, 'Reflect.set: default'); + assert.throws(TypeError, function() { + ns.default = null; + }, 'AssignmentExpression: default'); + + assert.sameValue( + Reflect.set(ns, Symbol.toStringTag, null), + false, + 'Reflect.set: Symbol.toStringTag' + ); + assert.throws(TypeError, function() { + ns[Symbol.toStringTag] = null; + }, 'AssignmentExpression: Symbol.toStringTag'); + + assert.sameValue(Reflect.set(ns, sym), false, 'Reflect.set: sym'); + assert.throws(TypeError, function() { + ns[sym] = null; + }, 'AssignmentExpression: sym'); + +}).then($DONE, $DONE).catch($DONE);