2008-02-26 19:48:54 -08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<head>
|
2008-05-02 12:26:47 -07:00
|
|
|
<title>postMessage origin-testing helper page</title>
|
2008-02-26 19:48:54 -08:00
|
|
|
<script type="application/javascript"><![CDATA[
|
|
|
|
function receiveMessage(evt)
|
|
|
|
{
|
|
|
|
var response = "PASS";
|
|
|
|
|
2010-03-12 13:53:36 -08:00
|
|
|
if (evt.origin !== "http://mochi.test:8888")
|
2008-02-26 19:48:54 -08:00
|
|
|
response += " wrong-origin(" + evt.origin + ")";
|
|
|
|
if (evt.source !== window.parent)
|
|
|
|
response += " wrong-source";
|
|
|
|
if (evt.data !== "PASS")
|
|
|
|
response += " wrong-data(" + evt.data + ")";
|
|
|
|
|
2010-03-12 13:53:36 -08:00
|
|
|
window.parent.postMessage(response, "http://mochi.test:8888");
|
2008-02-26 19:48:54 -08:00
|
|
|
}
|
|
|
|
|
2008-05-02 12:26:47 -07:00
|
|
|
window.addEventListener("message", receiveMessage, false);
|
2008-02-26 19:48:54 -08:00
|
|
|
|
|
|
|
|
|
|
|
// Aids for identifying origins
|
|
|
|
|
|
|
|
function setup()
|
|
|
|
{
|
|
|
|
var target = document.getElementById("location");
|
2008-05-02 12:26:47 -07:00
|
|
|
target.textContent = location.hostname + ":" + (location.port || 80);
|
2008-02-26 19:48:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener("load", setup, false);
|
|
|
|
]]></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1 id="location">No location!</h1>
|
|
|
|
</body>
|
|
|
|
</html>
|