tor-browser

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

usage-from-eval.js (1405B)


      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    ImportCall can be used from eval code
      7 esid: sec-import-call-runtime-semantics-evaluation
      8 info: |
      9    Import Calls
     10 
     11    Runtime Semantics: Evaluation
     12    
     13    ImportCall : import(AssignmentExpression)
     14    
     15    1. Let referencingScriptOrModule be ! GetActiveScriptOrModule().
     16    2. Let argRef be the result of evaluating AssignmentExpression.
     17    3. Let specifier be ? GetValue(argRef).
     18    4. Let promiseCapability be ! NewPromiseCapability(%Promise%).
     19    5. Let specifierString be ToString(specifier).
     20    6. IfAbruptRejectPromise(specifierString, promiseCapability).
     21    7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability).
     22    8. Return promiseCapability.[[Promise]].
     23 features: [dynamic-import]
     24 flags: [async]
     25 ---*/
     26 
     27 const p = eval("import('./module-code_FIXTURE.js');");
     28 
     29 assert.sameValue(Promise.resolve(p), p, 'constructor is %Promise%');
     30 assert.sameValue(Object.getPrototypeOf(p), Promise.prototype, 'prototype is %PromisePrototype%');
     31 
     32 p.then(imported => {
     33    assert.sameValue(imported.default, 42);
     34    assert.sameValue(imported.local1, 'Test262');
     35    assert.sameValue(imported.renamed, 'TC39');
     36    assert.sameValue(imported.indirect, 'Test262');
     37 }).then($DONE, $DONE);