promise-then-ns-delete-exported-init-strict-strict.js (5237B)
1 // |reftest| async 2 'use strict'; 3 // This file was procedurally generated from the following sources: 4 // - src/dynamic-import/ns-delete-exported-init-strict.case 5 // - src/dynamic-import/namespace/promise.template 6 /*--- 7 description: The [[Delete]] behavior for a key that describes an initialized exported binding on strict mode (value from promise then) 8 esid: sec-finishdynamicimport 9 features: [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 [...] 76 2. If Type(P) is Symbol, then 77 a. Return ? OrdinaryDelete(O, P). 78 3. Let exports be O.[[Exports]]. 79 4. If P is an element of exports, return false. 80 5. Return true. 81 82 ---*/ 83 84 import('./module-code_FIXTURE.js').then(ns => { 85 86 assert.throws(TypeError, function() { 87 delete ns.default; 88 }, 'delete: default'); 89 assert.sameValue( 90 Reflect.deleteProperty(ns, 'default'), false, 'Reflect.deleteProperty: default' 91 ); 92 assert.sameValue(ns.default, 42, 'binding unmodified: default'); 93 94 assert.throws(TypeError, function() { 95 delete ns.local1; 96 }, 'delete: local1'); 97 assert.sameValue( 98 Reflect.deleteProperty(ns, 'local1'), false, 'Reflect.deleteProperty: local1' 99 ); 100 assert.sameValue(ns.local1, 'Test262', 'binding unmodified: local1'); 101 102 assert.throws(TypeError, function() { 103 delete ns.renamed; 104 }, 'delete: renamed'); 105 assert.sameValue( 106 Reflect.deleteProperty(ns, 'renamed'), false, 'Reflect.deleteProperty: renamed' 107 ); 108 assert.sameValue(ns.renamed, 'TC39', 'binding unmodified: renamed'); 109 110 assert.throws(TypeError, function() { 111 delete ns.indirect; 112 }, 'delete: indirect'); 113 assert.sameValue( 114 Reflect.deleteProperty(ns, 'indirect'), 115 false, 116 'Reflect.deleteProperty: indirect' 117 ); 118 assert.sameValue(ns.indirect, 'Test262', 'binding unmodified: indirect'); 119 120 }).then($DONE, $DONE).catch($DONE);