tor-browser

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

import-source.js (1200B)


      1 // |reftest| skip async -- source-phase-imports is not supported
      2 // Copyright (C) 2025 Bloomberg LP. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 description: >
      7  Verify that ImportDeclaration can be correctly parsed.
      8 esid: sec-modules
      9 features: [source-phase-imports]
     10 flags: [async]
     11 includes: [asyncHelpers.js]
     12 ---*/
     13 
     14 function assertImportSourceResolutionFailure(specifier) {
     15  // Import the module and assert that the promise is rejected with a host
     16  // defined error during the resolution phase.
     17  // Note that this is not a `import.source`.
     18  return import(specifier).then(
     19    () => {
     20      throw new Test262Error(`${specifier}: Promise should be rejected`);
     21    },
     22    error => {
     23      if (error instanceof SyntaxError) {
     24        throw new Test262Error(`${specifier}: Promise should be rejected with a non-SyntaxError`);
     25      }
     26    }
     27  );
     28 }
     29 
     30 asyncTest(async function () {
     31  await assertImportSourceResolutionFailure('./import-source-binding-name_FIXTURE.js');
     32  await assertImportSourceResolutionFailure('./import-source-binding-name-2_FIXTURE.js');
     33  await assertImportSourceResolutionFailure('./import-source-newlines_FIXTURE.js');
     34 });