promise-then-ns-set-strict-strict.js (5316B)
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/promise.template 6 /*--- 7 description: The [[Set]] internal method consistently returns `false`, Strict Mode (value from promise then) 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 import('./module-code_FIXTURE.js').then(ns => { 82 83 assert.sameValue(Reflect.set(ns, 'local1'), false, 'Reflect.set: local1'); 84 assert.throws(TypeError, function() { 85 ns.local1 = null; 86 }, 'AssignmentExpression: local1'); 87 88 assert.sameValue(Reflect.set(ns, 'local2'), false, 'Reflect.set: local2'); 89 assert.throws(TypeError, function() { 90 ns.local2 = null; 91 }, 'AssignmentExpression: local2'); 92 93 assert.sameValue(Reflect.set(ns, 'renamed'), false, 'Reflect.set: renamed'); 94 assert.throws(TypeError, function() { 95 ns.renamed = null; 96 }, 'AssignmentExpression: renamed'); 97 98 assert.sameValue(Reflect.set(ns, 'indirect'), false, 'Reflect.set: indirect'); 99 assert.throws(TypeError, function() { 100 ns.indirect = null; 101 }, 'AssignmentExpression: indirect'); 102 103 assert.sameValue(Reflect.set(ns, 'default'), false, 'Reflect.set: default'); 104 assert.throws(TypeError, function() { 105 ns.default = null; 106 }, 'AssignmentExpression: default'); 107 108 assert.sameValue( 109 Reflect.set(ns, Symbol.toStringTag, null), 110 false, 111 'Reflect.set: Symbol.toStringTag' 112 ); 113 assert.throws(TypeError, function() { 114 ns[Symbol.toStringTag] = null; 115 }, 'AssignmentExpression: Symbol.toStringTag'); 116 117 assert.sameValue(Reflect.set(ns, sym), false, 'Reflect.set: sym'); 118 assert.throws(TypeError, function() { 119 ns[sym] = null; 120 }, 'AssignmentExpression: sym'); 121 122 }).then($DONE, $DONE).catch($DONE);