tor-browser

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

https_test.js (852B)


      1 function sendResponseToParent(response) {
      2  return `
      3    <!DOCTYPE html>
      4    <script>
      5      window.parent.postMessage({status: "done", data: "${response}"}, "*");
      6    </script>
      7  `;
      8 }
      9 
     10 self.addEventListener("fetch", function (event) {
     11  if (event.request.url.includes("index.html")) {
     12    var response = "good";
     13    try {
     14      importScripts("http://example.org/tests/dom/workers/test/foreign.js");
     15    } catch (e) {
     16      dump("Got error " + e + " when importing the script\n");
     17    }
     18    if (response === "good") {
     19      try {
     20        importScripts("/tests/dom/workers/test/redirect_to_foreign.sjs");
     21      } catch (e) {
     22        dump("Got error " + e + " when importing the script\n");
     23      }
     24    }
     25    event.respondWith(
     26      new Response(sendResponseToParent(response), {
     27        headers: { "Content-Type": "text/html" },
     28      })
     29    );
     30  }
     31 });