tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

reuse-namespace-object-from-import.js (1589B)


      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    Reuse the resolved namespace object already imported from a static import
      7 esid: sec-import-call-runtime-semantics-evaluation
      8 info: |
      9    Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion )
     10 
     11        1. If completion is an abrupt completion, ...
     12        2. Otherwise,
     13            ...
     14            d. Let namespace be GetModuleNamespace(moduleRecord).
     15            e. If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »).
     16            f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »).
     17 
     18    Runtime Semantics: GetModuleNamespace ( module )
     19 
     20        ...
     21        3. Let namespace be module.[[Namespace]].
     22        4. If namespace is undefined, then
     23            ...
     24            d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames).
     25        5. Return namespace.
     26 features: [dynamic-import]
     27 flags: [async, module]
     28 ---*/
     29 
     30 import * as ns from './module-code_FIXTURE.js';
     31 
     32 Promise.all([
     33    import('./module-code_FIXTURE.js'),
     34    import('./module-code_FIXTURE.js'),
     35 ]).then(([a, b]) => {
     36    assert.sameValue(a, b, 'it returns the same namespace are the same');
     37    assert.sameValue(a, ns, 'dynamic imported a is the same object as ns');
     38    assert.sameValue(b, ns, 'dynamic imported b is the same object as ns');
     39 }).then($DONE, $DONE);