tor-browser

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

split-cache-popup-with-iframe.html (1218B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>HTTP Cache - helper</title>
      6  <meta name="help" href="https://fetch.spec.whatwg.org/#http-cache-partitions">
      7  <meta name="timeout" content="normal">
      8  <script src="/resources/testharness.js"></script>
      9  <script src="/common/get-host-info.sub.js"></script>
     10 </head>
     11 <body>
     12 <script>
     13  const host = get_host_info();
     14 
     15  // Create iframe that is same-origin to the opener.
     16  var iframe = document.createElement("iframe");
     17  iframe.src = host.HTTP_ORIGIN + window.location.pathname.replace(/\/[^\/]*$/, '/') + "split-cache-popup.html";
     18  document.body.appendChild(iframe);
     19 
     20  window.addEventListener("message", function listener(event) {
     21    if (event.origin !== host.HTTP_ORIGIN) {
     22      // Ignore messages not from the iframe or opener
     23      return;
     24    } else if (typeof(event.data) === "object") {
     25      // This message came from the opener, pass it on to the iframe
     26      iframe.contentWindow.postMessage(event.data, host.HTTP_ORIGIN);
     27    } else if (typeof(event.data) === "string") {
     28      // This message came from the iframe, pass it on to the opener
     29      window.opener.postMessage(event.data, host.HTTP_ORIGIN);
     30    }
     31  })
     32 </script>
     33 </body>
     34 </html>