tor-browser

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

request-destination.https.tentative.sub.html (1970B)


      1 <!DOCTYPE html>
      2 <title>
      3  Request's destination must be "webbundle" with the script-based API
      4 </title>
      5 <link
      6  rel="help"
      7  href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
      8 />
      9 <script src="/resources/testharness.js"></script>
     10 <script src="/resources/testharnessreport.js"></script>
     11 <script src="../resources/test-helpers.js"></script>
     12 <body>
     13  <script>
     14    setup(() => {
     15      assert_true(HTMLScriptElement.supports("webbundle"));
     16    });
     17 
     18    // check-sec-fetch-dest-header-and-return-bundle.py returns a valid format
     19    // bundle only if a 'Sec-Fetch-Dest: webbundle' header is present in a request.
     20    // Otherwise, returns an empty body with 400 status code.
     21    //
     22    // In this wpt, we assume that a <script> element fires a load event correctly if
     23    // a valid format webbundle is returned.
     24 
     25    const same_origin_bundle =
     26      "../resources/check-sec-fetch-dest-header-and-return-bundle.py";
     27    const cross_origin_bundle =
     28      "https://{{domains[www1]}}:{{ports[https][0]}}/web-bundle/resources/check-sec-fetch-dest-header-and-return-bundle.py";
     29 
     30    promise_test(async () => {
     31      for (const bundle of [same_origin_bundle, cross_origin_bundle]) {
     32        const element = createWebBundleElement(bundle, /*resources=*/ []);
     33        await addElementAndWaitForLoad(element);
     34        element.remove();
     35      }
     36    }, '"Sec-Fetch-Dest: webbundle" header must be present in a request for a bundle'
     37     + " with <script type=webbundle>.");
     38 
     39    promise_test(async () => {
     40      const res = await fetch(same_origin_bundle);
     41      assert_false(res.ok);
     42    }, '"Sec-Fetch-Dest: webbundle" header must not be present in a fetch request' + " for a same-origin resource.");
     43 
     44    promise_test(async () => {
     45      const res = await fetch(cross_origin_bundle);
     46      assert_false(res.ok);
     47    }, '"Sec-Fetch-Dest: webbundle" header must not be present in a fetch request' + " for a cross-origin resource.");
     48  </script>
     49 </body>