tor-browser

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

postMessage_origin_helper.xhtml (991B)


      1 <!DOCTYPE html>
      2 <html xmlns="http://www.w3.org/1999/xhtml">
      3 <head>
      4  <title>postMessage origin-testing helper page</title>
      5  <script type="application/javascript"><![CDATA[
      6 function receiveMessage(evt)
      7 {
      8  if (event.data === "PING") {
      9    window.parent.postMessage("PONG", "*");
     10    return;
     11  }
     12 
     13  var response = "PASS";
     14 
     15  if (evt.origin !== "http://mochi.test:8888")
     16    response += " wrong-origin(" + evt.origin + ")";
     17  if (evt.source !== window.parent)
     18    response += " wrong-source";
     19  if (evt.data !== "PASS")
     20    response += " wrong-data(" + evt.data + ")";
     21 
     22  window.parent.postMessage(response, "http://mochi.test:8888");
     23 }
     24 
     25 window.addEventListener("message", receiveMessage);
     26 
     27 
     28 // Aids for identifying origins
     29 
     30 function setup()
     31 {
     32  var target = document.getElementById("location");
     33  target.textContent = location.hostname + ":" + (location.port || 80);
     34 }
     35 
     36 window.addEventListener("load", setup);
     37  ]]></script>
     38 </head>
     39 <body>
     40 <h1 id="location">No location!</h1>
     41 </body>
     42 </html>