| 1 |
// |reftest| async |
| 2 |
// This file was procedurally generated from the following sources: |
| 3 |
// - src/dynamic-import/ns-get-nested-namespace-dflt-direct.case |
| 4 |
// - src/dynamic-import/namespace/await.template |
| 5 |
/*--- |
| 6 |
description: Direct Default exports are included in an imported module namespace object when a namespace object is created. (value from await resolving) |
| 7 |
esid: sec-finishdynamicimport |
| 8 |
features: [export-star-as-namespace-from-module, dynamic-import] |
| 9 |
flags: [generated, async] |
| 10 |
info: | |
| 11 |
Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) |
| 12 |
|
| 13 |
1. If completion is an abrupt completion, ... |
| 14 |
2. Otherwise, |
| 15 |
... |
| 16 |
d. Let namespace be GetModuleNamespace(moduleRecord). |
| 17 |
e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »). |
| 18 |
f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). |
| 19 |
|
| 20 |
Runtime Semantics: GetModuleNamespace ( module ) |
| 21 |
|
| 22 |
... |
| 23 |
3. Let namespace be module.[[Namespace]]. |
| 24 |
4. If namespace is undefined, then |
| 25 |
a. Let exportedNames be ? module.GetExportedNames(« »). |
| 26 |
b. Let unambiguousNames be a new empty List. |
| 27 |
c. For each name that is an element of exportedNames, do |
| 28 |
i. Let resolution be ? module.ResolveExport(name, « »). |
| 29 |
ii. If resolution is a ResolvedBinding Record, append name to unambiguousNames. |
| 30 |
d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). |
| 31 |
5. Return namespace. |
| 32 |
|
| 33 |
ModuleNamespaceCreate ( module, exports ) |
| 34 |
|
| 35 |
... |
| 36 |
4. Let M be a newly created object. |
| 37 |
5. Set M's essential internal methods to the definitions specified in 9.4.6. |
| 38 |
7. Let sortedExports be a new List containing the same values as the list exports where the |
| 39 |
values are ordered as if an Array of the same values had been sorted using Array.prototype.sort |
| 40 |
using undefined as comparefn. |
| 41 |
8. Set M.[[Exports]] to sortedExports. |
| 42 |
9. Create own properties of M corresponding to the definitions in 26.3. |
| 43 |
10. Set module.[[Namespace]] to M. |
| 44 |
11. Return M. |
| 45 |
|
| 46 |
26.3 Module Namespace Objects |
| 47 |
|
| 48 |
A Module Namespace Object is a module namespace exotic object that provides runtime |
| 49 |
property-based access to a module's exported bindings. There is no constructor function for |
| 50 |
Module Namespace Objects. Instead, such an object is created for each module that is imported |
| 51 |
by an ImportDeclaration that includes a NameSpaceImport. |
| 52 |
|
| 53 |
In addition to the properties specified in 9.4.6 each Module Namespace Object has the |
| 54 |
following own property: |
| 55 |
|
| 56 |
26.3.1 @@toStringTag |
| 57 |
|
| 58 |
The initial value of the @@toStringTag property is the String value "Module". |
| 59 |
|
| 60 |
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. |
| 61 |
|
| 62 |
Module Namespace Exotic Objects |
| 63 |
|
| 64 |
A module namespace object is an exotic object that exposes the bindings exported from an |
| 65 |
ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between the String-keyed |
| 66 |
own properties of a module namespace exotic object and the binding names exported by the |
| 67 |
Module. The exported bindings include any bindings that are indirectly exported using export * |
| 68 |
export items. Each String-valued own property key is the StringValue of the corresponding |
| 69 |
exported binding name. These are the only String-keyed properties of a module namespace exotic |
| 70 |
object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, |
| 71 |
[[Configurable]]: false }. Module namespace objects are not extensible. |
| 72 |
|
| 73 |
|
| 74 |
[...] |
| 75 |
6. Let binding be ! m.ResolveExport(P, « »). |
| 76 |
7. Assert: binding is a ResolvedBinding Record. |
| 77 |
8. Let targetModule be binding.[[Module]]. |
| 78 |
9. Assert: targetModule is not undefined. |
| 79 |
10. If binding.[[BindingName]] is "*namespace*", then |
| 80 |
11. Return ? GetModuleNamespace(targetModule). |
| 81 |
|
| 82 |
Runtime Semantics: GetModuleNamespace |
| 83 |
[...] |
| 84 |
3. If namespace is undefined, then |
| 85 |
a. Let exportedNames be ? module.GetExportedNames(« »). |
| 86 |
b. Let unambiguousNames be a new empty List. |
| 87 |
c. For each name that is an element of exportedNames, |
| 88 |
i. Let resolution be ? module.ResolveExport(name, « », « »). |
| 89 |
ii. If resolution is null, throw a SyntaxError exception. |
| 90 |
iii. If resolution is not "ambiguous", append name to |
| 91 |
unambiguousNames. |
| 92 |
d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). |
| 93 |
[...] |
| 94 |
|
| 95 |
---*/ |
| 96 |
|
| 97 |
async function fn() { |
| 98 |
const ns = await import('./get-nested-namespace-dflt-skip-prod_FIXTURE.js'); |
| 99 |
|
| 100 |
var desc = Object.getOwnPropertyDescriptor(ns, 'productionNS2'); |
| 101 |
|
| 102 |
assert.sameValue(desc.enumerable, true, 'ns.productionNS2: is enumerable'); |
| 103 |
assert.sameValue(desc.writable, true, 'ns.productionNS2: is writable'); |
| 104 |
assert.sameValue(desc.configurable, false, 'ns.productionNS2: is non-configurable'); |
| 105 |
|
| 106 |
var keys = Object.getOwnPropertyNames(ns.productionNS2); |
| 107 |
|
| 108 |
assert.sameValue(keys.length, 2); |
| 109 |
assert.sameValue(keys[0], 'default'); |
| 110 |
assert.sameValue(keys[1], 'productionOther'); |
| 111 |
|
| 112 |
desc = Object.getOwnPropertyDescriptor(ns.productionNS2, 'productionOther'); |
| 113 |
|
| 114 |
assert.sameValue(desc.value, null, 'ns.productionNS2.productionOther: value is null'); |
| 115 |
assert.sameValue(desc.enumerable, true, 'ns.productionNS2.productionOther: is enumerable'); |
| 116 |
assert.sameValue(desc.writable, true, 'ns.productionNS2.productionOther: is writable'); |
| 117 |
assert.sameValue(desc.configurable, false, 'ns.productionNS2.productionOther: is non-configurable'); |
| 118 |
|
| 119 |
desc = Object.getOwnPropertyDescriptor(ns.productionNS2, 'default'); |
| 120 |
|
| 121 |
assert.sameValue(desc.value, 42, 'ns.productionNS2.default value is 42'); |
| 122 |
assert.sameValue(desc.enumerable, true, 'ns.productionNS2.default is enumerable'); |
| 123 |
assert.sameValue(desc.writable, true, 'ns.productionNS2.default is writable'); |
| 124 |
assert.sameValue(desc.configurable, false, 'ns.productionNS2.default is non-configurable'); |
| 125 |
} |
| 126 |
|
| 127 |
fn().then($DONE, $DONE).catch($DONE); |