tor-browser

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

test_dynamicImportErrorMessage.html (910B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>Test the error message from import()</title>
      4 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
      5 <script>
      6  SimpleTest.waitForExplicitFinish();
      7 
      8  let count = 0;
      9  function maybeFinish() {
     10    count++;
     11    if (count == 2) {
     12      SimpleTest.finish();
     13    }
     14  }
     15 
     16  // eslint-disable-next-line no-unused-vars
     17  async function testLoaded() {
     18 
     19    await import("./404.js").catch((error) => {
     20      ok(error instanceof TypeError, "Should be a TypeError.");
     21      ok(error.message.match(/404.js/), "Should have the filename.");
     22      maybeFinish();
     23    });
     24 
     25    await import("./import_404.mjs").catch((error) => {
     26      ok(error instanceof TypeError, "Should be a TypeError.");
     27      ok(error.message.match(/404.js/), "Should have the filename from sub-modules");
     28      maybeFinish();
     29    });
     30  }
     31 </script>
     32 <body onload='testLoaded()'></body>