dom/tests/mochitest/whatwg/postMessage_origin_helper.xhtml

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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   var response = "PASS";
    10   if (evt.origin !== "http://mochi.test:8888")
    11     response += " wrong-origin(" + evt.origin + ")";
    12   if (evt.source !== window.parent)
    13     response += " wrong-source";
    14   if (evt.data !== "PASS")
    15     response += " wrong-data(" + evt.data + ")";
    17   window.parent.postMessage(response, "http://mochi.test:8888");
    18 }
    20 window.addEventListener("message", receiveMessage, false);
    23 // Aids for identifying origins
    25 function setup()
    26 {
    27   var target = document.getElementById("location");
    28   target.textContent = location.hostname + ":" + (location.port || 80);
    29 }
    31 window.addEventListener("load", setup, false);
    32   ]]></script>
    33 </head>
    34 <body>
    35 <h1 id="location">No location!</h1>
    36 </body>
    37 </html>

mercurial