dom/tests/mochitest/whatwg/postMessage_origin_helper.xhtml

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial