tor-browser

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

iframe-post-message.html (1368B)


      1 <!DOCTYPE html>
      2 <head>
      3  <script src="/resources/testharness.js"></script>
      4  <script src="/resources/testharnessreport.js"></script>
      5  <script src="/common/get-host-info.sub.js"></script>
      6  <script src="../../resources/test-initiator.js"></script>
      7 
      8  <script src="../../resources/loading-resource-lib.js"></script>
      9 </head>
     10 <body>
     11  <h1>Description</h1>
     12  <p> This test verifies that, for a resource fetched via message handler,
     13      the initiator_url points to script that sends the message.
     14  </p>
     15 </body>
     16 <script>
     17 
     18  const channel = new MessageChannel();
     19  const frame = document.createElement("iframe");
     20  frame.addEventListener("load", () => {
     21    frame.contentWindow.postMessage("port", "*", [channel.port2]);
     22  });
     23  frame.src = "../../resources/iframe-post-message.html";
     24  document.body.appendChild(frame);
     25 
     26  var img = document.createElement("img");
     27  document.body.appendChild(img);
     28 
     29  const label = "initiator_url_iframe_postmessage";
     30  const resource = "/images/blue.png?"+label;
     31  const hostInfo = get_host_info();
     32  const expectedInitiatorUrl = hostInfo["ORIGIN"] +
     33    "/resource-timing/tentative/initiator-url/iframe-post-message.html";
     34 
     35  channel.port1.onmessage = e => {
     36     load_image(label, img);
     37  }
     38 
     39 initiator_url_test(resource, expectedInitiatorUrl, resource +
     40   " initiatorUrl from iframe postMessage()", resource + " timeout");
     41 
     42 </script>