tor-browser

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

location-ancestorOrigins-inner.https.html (1791B)


      1 <!DOCTYPE html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="utils.js"></script>
      4 <title>Fenced frame content to report the value of location.ancestorOrigins</title>
      5 
      6 <body>
      7 <script>
      8 async function init() { // Needed in order to use top-level await.
      9  // This file is meant to run in a <fencedframe>. It reports back to the
     10  // outermost page the value of `location.ancestorOrigins` correct for:
     11  //   1.) Top-level fenced frames
     12  //   2.) Nested iframes inside a fenced frame
     13  //   3.) Nested fenced frames
     14  const url = new URL(location.href);
     15 
     16  const [location_ao_key, location_ao_ack_key, nested] = parseKeylist();
     17 
     18  const is_nested_fenced_frame = nested == "nested";
     19 
     20  // Report `location.ancestorOrigins`.
     21  writeValueToServer(location_ao_key, Array.from(location.ancestorOrigins).join());
     22 
     23  // If this page is a nested fenced frame, all we need to do is report the
     24  // top-level value.
     25  if (is_nested_fenced_frame)
     26    return;
     27 
     28  // Wait for ACK, so we know that the outer page has read the last value from
     29  // the `location_ao_key` stash and we can write to it again.
     30  await nextValueFromServer(location_ao_ack_key);
     31 
     32  const nested_url = generateURL("location-ancestorOrigins-inner.https.html",
     33      [location_ao_key, location_ao_ack_key, "nested"]);
     34 
     35  // Send `location.ancestorOrigins` from an iframe.
     36  const iframe = document.createElement('iframe');
     37  iframe.src = nested_url;
     38  const load_promise = new Promise((resolve, reject) => {
     39    iframe.onload = resolve;
     40    iframe.onerror = reject;
     41  });
     42  document.body.append(iframe);
     43 
     44  // Wait for ACK, so we know that the outer page has read the ancestorOrigins
     45  // from the iframe.
     46  await nextValueFromServer(location_ao_ack_key);
     47 
     48  attachFencedFrame(nested_url);
     49 }
     50 
     51 init();
     52 </script>
     53 </body>