tor-browser

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

reuse-namespace-object-from-script.js (1519B)


      1 // |reftest| 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 from a script code.
      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]
     28 ---*/
     29 
     30 // empty_FIXTURE.js does not export anything, so it wouldn't suit for a module code exported namespace
     31 // we use this to assume it's a close example to a script code imported.
     32 Promise.all([
     33    import('./empty_FIXTURE.js'),
     34    import('./empty_FIXTURE.js'),
     35 ]).then(([a, b]) => {
     36    assert.sameValue(a, b, 'it returns the same namespace are the same');
     37 }).then($DONE, $DONE);