tor-browser

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

relative-url-with-base.https.tentative.html (2278B)


      1 <!DOCTYPE html>
      2 <title>
      3  Subresource loading using relative URLs in the 'resources' attribute with a
      4  base element
      5 </title>
      6 <base href="../resources/wbn/" />
      7 <link
      8  rel="help"
      9  href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
     10 />
     11 <script src="/resources/testharness.js"></script>
     12 <script src="/resources/testharnessreport.js"></script>
     13 
     14 <body>
     15  <script type="webbundle">
     16    {
     17      "source": "static-element.wbn",
     18      "resources": ["static-element/resources/script.js"]
     19    }
     20  </script>
     21  <script id="script" src="static-element/resources/script.js"></script>
     22 
     23  <script type="webbundle">
     24    {
     25      "source": "dynamic1.wbn",
     26      "scopes": ["dynamic/resource"]
     27    }
     28  </script>
     29 
     30  <script>
     31    setup(() => {
     32      assert_true(HTMLScriptElement.supports("webbundle"));
     33    });
     34 
     35    test(() => {
     36      assert_equals(resources_script_result, "loaded from webbundle");
     37    }, "A subresource script.js should be loaded from WebBundle using the relative " + "URL and a base element.");
     38 
     39    promise_test(async () => {
     40      const module = await import(
     41        "/web-bundle/resources/wbn/dynamic/resource1.js"
     42      );
     43      assert_equals(module.result, "resource1 from dynamic1.wbn");
     44      const module2 = await import(
     45        "/web-bundle/resources/wbn/dynamic/resource2.js"
     46      );
     47      assert_equals(module2.result, "resource2 from dynamic1.wbn");
     48      const module3 = await import(
     49        "/web-bundle/resources/wbn/dynamic/resource3.js"
     50      );
     51      assert_equals(module3.result, "resource3 from dynamic1.wbn");
     52      const module4 = await import(
     53        "/web-bundle/resources/wbn/dynamic/resource4.js"
     54      );
     55      assert_equals(module4.result, "resource4 from dynamic1.wbn");
     56      const result_promise = new Promise((resolve) => {
     57        // This function will be called from script.js
     58        window.report_result = resolve;
     59      });
     60 
     61      const script = document.createElement("script");
     62      script.src = "/web-bundle/resources/wbn/dynamic/classic_script.js";
     63      document.body.appendChild(script);
     64      assert_equals(await result_promise, "classic script from network");
     65    }, "Subresources that start with 'resource' should be loaded from dynamic1.wbn while others from network.");
     66  </script>
     67 </body>