tor-browser

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

test_nested_modules.html (1267B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>Test nested module</title>
      4 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      5 <script>
      6  SimpleTest.waitForExplicitFinish();
      7  SimpleTest.requestLongerTimeout(2);
      8 
      9  // eslint-disable-next-line no-unused-vars
     10  function testLoaded() {
     11    ok(true, 'Not crash');
     12    SimpleTest.finish();
     13  }
     14 
     15  async function generateModules(n, parseError) {
     16    const urls = [];
     17 
     18    const leaf = parseError ? `^%$#@!` :
     19      `console.log("Hello from module ${n}");`;
     20 
     21    for (let i = n; i >= 1; i--) {
     22      const nextUrl = urls[0] || '';
     23      const content = i === n
     24        ? leaf
     25        : `import "${nextUrl}";\nconsole.log("Entered module ${i}");`;
     26 
     27      const blob = new Blob([content], { type: 'application/javascript' });
     28      const blobURL = URL.createObjectURL(blob);
     29      urls.unshift(blobURL); // Add to the beginning for next import
     30    }
     31 
     32    // Start execution from the topmost module
     33    const mainModuleURL = urls[0];
     34    try {
     35      await import(mainModuleURL);
     36    } catch (e) {
     37      console.error("Module import failed:", e);
     38    }
     39 
     40    urls.forEach(URL.revokeObjectURL);
     41  }
     42 
     43  generateModules(4000);
     44  generateModules(10000);
     45  generateModules(10000, true);
     46 </script>
     47 <body onload='testLoaded()'></body>