tor-browser

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

fetch-local-http.html (1265B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Fetch HTTP local with targetAddressSpace local </title>
      4 
      5 <script src="/resources/testdriver.js"></script>
      6 <script src="/resources/testdriver-vendor.js"></script>
      7 <script src="support.sub.js"></script>
      8 <script>
      9 "use strict";
     10 
     11 // Fetch a local address over HTTP. Fetch is annotated with a
     12 // targetAddressSpace of local to allow for mixed content check bypassing.
     13 //
     14 // TODO(crbug.com/406991278): consolidate with fetch-local.html adding
     15 // options to minimize # of resources needed.
     16 Promise.resolve().then(async () => {
     17  test_driver.set_test_context(opener);
     18  await test_driver.set_permission({ name: 'local-network-access' }, 'granted');
     19 
     20  const target = {
     21    server: Server.HTTP_LOCAL,
     22    behavior: { response: ResponseBehavior.allowCrossOrigin() },
     23  };
     24  const targetUrl = resolveTargetUrl(target);
     25 
     26  fetch(targetUrl, {targetAddressSpace: 'local'})
     27      .then(async function(response) {
     28        const body = await response.text();
     29        const message = {
     30          ok: response.ok,
     31          type: response.type,
     32          body: body,
     33        };
     34        opener.postMessage(message, "*");
     35      })
     36      .catch(error => {
     37        opener.postMessage({ error: error.toString() }, "*");
     38      });
     39 });
     40 </script>