dom/tests/mochitest/whatwg/postMessage_joined_helper2.html

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>
michael@0 3 <!--
michael@0 4 http://example.org/tests/dom/tests/mochitest/whatwg/postMessage_joined_helper2.html
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>postMessage joined domains, innermost frame</title>
michael@0 8 <script type="application/javascript" src="browserFu.js"></script>
michael@0 9 <script type="application/javascript">
michael@0 10 function receiveMessage(evt)
michael@0 11 {
michael@0 12 var response = "subframe-test-finished";
michael@0 13
michael@0 14 if (evt.origin !== "http://sub1.test1.example.org")
michael@0 15 {
michael@0 16 response += " wrong-origin(" + evt.origin + ")";
michael@0 17 response += " location(" + window.location.href + ")";
michael@0 18 }
michael@0 19
michael@0 20 if (evt.data !== "start-test")
michael@0 21 response += " incorrect-subframe-data(" + evt.data + ")";
michael@0 22 if (evt.type !== "message")
michael@0 23 response += " wrong-type(" + evt.type + ")";
michael@0 24 if (evt.target !== window)
michael@0 25 {
michael@0 26 response += " wrong-target(" + evt.target + ")";
michael@0 27 response += " location(" + window.location.href + ")";
michael@0 28 }
michael@0 29
michael@0 30 if (isMozilla)
michael@0 31 {
michael@0 32 if (evt.isTrusted !== false)
michael@0 33 response += " unexpected-trusted-event";
michael@0 34 }
michael@0 35
michael@0 36 if (evt.source !== window.parent)
michael@0 37 {
michael@0 38 response += " unexpected-source(" + evt.source + ")";
michael@0 39 response += " window-parent-is(" + window.parent + ")";
michael@0 40 response += " location(" + window.location.href + ")";
michael@0 41 }
michael@0 42
michael@0 43 // verify that document.domain was actually joined with this domain
michael@0 44 try
michael@0 45 {
michael@0 46 var passed = evt.source.document.domain === document.domain;
michael@0 47 }
michael@0 48 catch (e)
michael@0 49 {
michael@0 50 }
michael@0 51
michael@0 52 if (!passed)
michael@0 53 response += " expected-joined-domains";
michael@0 54
michael@0 55 window.parent.postMessage(response, "http://sub1.test1.example.org");
michael@0 56 }
michael@0 57
michael@0 58 function setup()
michael@0 59 {
michael@0 60 var oldDomain = document.domain;
michael@0 61 var newDomain = "example.org"; // join with parent
michael@0 62
michael@0 63 document.domain = newDomain;
michael@0 64
michael@0 65 var target = document.getElementById("location");
michael@0 66 target.textContent = "Location: " + oldDomain +
michael@0 67 ", effective domain: " + newDomain;
michael@0 68
michael@0 69 window.addEventListener("message", receiveMessage, false);
michael@0 70 }
michael@0 71
michael@0 72 window.addEventListener("load", setup, false);
michael@0 73 </script>
michael@0 74 </head>
michael@0 75 <body>
michael@0 76 <p id="location">No location!</p>
michael@0 77 </body>
michael@0 78 </html>

mercurial