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