1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/whatwg/postMessage_origin_helper.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,37 @@ 1.4 +<!DOCTYPE html> 1.5 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.6 +<head> 1.7 + <title>postMessage origin-testing helper page</title> 1.8 + <script type="application/javascript"><![CDATA[ 1.9 +function receiveMessage(evt) 1.10 +{ 1.11 + var response = "PASS"; 1.12 + 1.13 + if (evt.origin !== "http://mochi.test:8888") 1.14 + response += " wrong-origin(" + evt.origin + ")"; 1.15 + if (evt.source !== window.parent) 1.16 + response += " wrong-source"; 1.17 + if (evt.data !== "PASS") 1.18 + response += " wrong-data(" + evt.data + ")"; 1.19 + 1.20 + window.parent.postMessage(response, "http://mochi.test:8888"); 1.21 +} 1.22 + 1.23 +window.addEventListener("message", receiveMessage, false); 1.24 + 1.25 + 1.26 +// Aids for identifying origins 1.27 + 1.28 +function setup() 1.29 +{ 1.30 + var target = document.getElementById("location"); 1.31 + target.textContent = location.hostname + ":" + (location.port || 80); 1.32 +} 1.33 + 1.34 +window.addEventListener("load", setup, false); 1.35 + ]]></script> 1.36 +</head> 1.37 +<body> 1.38 +<h1 id="location">No location!</h1> 1.39 +</body> 1.40 +</html>