imported-self-update.js (1448B)
1 // |reftest| module async 2 // Copyright (C) 2018 Leo Balter. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 /*--- 5 description: > 6 Imported self bindings should update the references 7 esid: sec-finishdynamicimport 8 info: | 9 Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion ) 10 11 2. Otherwise, 12 a. Assert: completion is a normal completion and completion.[[Value]] is undefined. 13 b. Let moduleRecord be ! HostResolveImportedModule(referencingScriptOrModule, specifier). 14 c. Assert: Evaluate has already been invoked on moduleRecord and successfully completed. 15 d. Let namespace be GetModuleNamespace(moduleRecord). 16 ... 17 f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »). 18 flags: [async, module] 19 features: [dynamic-import] 20 ---*/ 21 22 let x = 0; 23 export { x, x as y }; 24 async function fn() { 25 var imported = await import('./imported-self-update.js'); 26 assert.sameValue(imported.x, 0, 'original value, direct binding'); 27 assert.sameValue(imported.y, 0, 'original value, indirect binding'); 28 x = 1; 29 assert.sameValue(imported.x, 1, 'updated value, direct binding'); 30 assert.sameValue(imported.y, 1, 'updated value, indirect binding'); 31 } 32 33 // Do not use asyncTest: when self imported, $DONE is not defined, asyncTest will throw 34 fn().then($DONE, $DONE);