1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/whatwg/postMessage_joined_helper2.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<!-- 1.7 +http://example.org/tests/dom/tests/mochitest/whatwg/postMessage_joined_helper2.html 1.8 +--> 1.9 +<head> 1.10 + <title>postMessage joined domains, innermost frame</title> 1.11 + <script type="application/javascript" src="browserFu.js"></script> 1.12 + <script type="application/javascript"> 1.13 + function receiveMessage(evt) 1.14 + { 1.15 + var response = "subframe-test-finished"; 1.16 + 1.17 + if (evt.origin !== "http://sub1.test1.example.org") 1.18 + { 1.19 + response += " wrong-origin(" + evt.origin + ")"; 1.20 + response += " location(" + window.location.href + ")"; 1.21 + } 1.22 + 1.23 + if (evt.data !== "start-test") 1.24 + response += " incorrect-subframe-data(" + evt.data + ")"; 1.25 + if (evt.type !== "message") 1.26 + response += " wrong-type(" + evt.type + ")"; 1.27 + if (evt.target !== window) 1.28 + { 1.29 + response += " wrong-target(" + evt.target + ")"; 1.30 + response += " location(" + window.location.href + ")"; 1.31 + } 1.32 + 1.33 + if (isMozilla) 1.34 + { 1.35 + if (evt.isTrusted !== false) 1.36 + response += " unexpected-trusted-event"; 1.37 + } 1.38 + 1.39 + if (evt.source !== window.parent) 1.40 + { 1.41 + response += " unexpected-source(" + evt.source + ")"; 1.42 + response += " window-parent-is(" + window.parent + ")"; 1.43 + response += " location(" + window.location.href + ")"; 1.44 + } 1.45 + 1.46 + // verify that document.domain was actually joined with this domain 1.47 + try 1.48 + { 1.49 + var passed = evt.source.document.domain === document.domain; 1.50 + } 1.51 + catch (e) 1.52 + { 1.53 + } 1.54 + 1.55 + if (!passed) 1.56 + response += " expected-joined-domains"; 1.57 + 1.58 + window.parent.postMessage(response, "http://sub1.test1.example.org"); 1.59 + } 1.60 + 1.61 + function setup() 1.62 + { 1.63 + var oldDomain = document.domain; 1.64 + var newDomain = "example.org"; // join with parent 1.65 + 1.66 + document.domain = newDomain; 1.67 + 1.68 + var target = document.getElementById("location"); 1.69 + target.textContent = "Location: " + oldDomain + 1.70 + ", effective domain: " + newDomain; 1.71 + 1.72 + window.addEventListener("message", receiveMessage, false); 1.73 + } 1.74 + 1.75 + window.addEventListener("load", setup, false); 1.76 + </script> 1.77 +</head> 1.78 +<body> 1.79 +<p id="location">No location!</p> 1.80 +</body> 1.81 +</html>