tor-browser

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

import-errored-module.js (2480B)


      1 // |reftest| async
      2 // Copyright (C) 2025 Igalia, S.L. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-ContinueDynamicImport
      7 description: >
      8  Dynamic import of an already errored module should fail
      9 info: |
     10  ContinueDynamicImport ( _promiseCapability_, _moduleCompletion_ )
     11    1. ...
     12    1. Let _module_ be _moduleCompletion_.[[Value]].
     13    1. Let _loadPromise_ be _module_.LoadRequestedModules().
     14    1. Let _rejectedClosure_ be a new Abstract Closure with parameters (_reason_) that captures _promiseCapability_ and performs the following steps when called:
     15      1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _reason_ »).
     16      1. Return ~unused~.
     17    1. Let _onRejected_ be CreateBuiltinFunction(_rejectedClosure_, 1, *""*, « »).
     18    1. Let _linkAndEvaluateClosure_ be a new Abstract Closure with no parameters that captures _module_, _promiseCapability_, and _onRejected_ and performs the following steps when called:
     19      1. Let _link_ be Completion(_module_.Link()).
     20      1. ...
     21      1. Let _evaluatePromise_ be _module_.Evaluate().
     22      1. Let _fulfilledClosure_ be a new Abstract Closure with no parameters that captures _module_ and _promiseCapability_ and performs the following steps when called:
     23        1. Let _namespace_ be GetModuleNamespace(_module_).
     24        1. Perform ! <emu-meta effects="user-code">Call</emu-meta>(_promiseCapability_.[[Resolve]], *undefined*, « _namespace_ »).
     25        1. Return ~unused~.
     26      1. Let _onFulfilled_ be CreateBuiltinFunction(_fulfilledClosure_, 0, *""*, « »).
     27      1. Perform PerformPromiseThen(_evaluatePromise_, _onFulfilled_, _onRejected_).
     28      1. Return ~unused~.
     29    1. Let _linkAndEvaluate_ be CreateBuiltinFunction(_linkAndEvaluateClosure_, 0, *""*, « »).
     30    1. Perform PerformPromiseThen(_loadPromise_, _linkAndEvaluate_, _onRejected_).
     31    1. Return ~unused~.
     32 
     33  _module_ . Evaluate (  )
     34    4. If _module_.[[TopLevelCapability]] is not ~empty~, then
     35       a. Return _module_.[[TopLevelCapability]].[[Promise]].
     36 
     37 flags: [async]
     38 features: [dynamic-import]
     39 includes: [asyncHelpers.js]
     40 ---*/
     41 
     42 asyncTest(async function () {
     43  await assert.throwsAsync(
     44    Error,
     45    () => import('./import-errored-module_FIXTURE.js'),
     46    'The import should reject (first import)'
     47  );
     48  await assert.throwsAsync(
     49    Error,
     50    () => import('./import-errored-module_FIXTURE.js'),
     51    'The import should reject (second import)'
     52  );
     53 });