blob: be4e4c96ff225a69672ea1bb0de8f9fd6a7aef0e [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="resources/recv.js"></script>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
addEventListener("message", recv, false);
function tryPostMessage(origin) {
try {
win.postMessage("Trying origin=" + origin, origin);
document.getElementById("result").innerHTML += "<br>Posted message to '" + origin + "' without any exceptions.";
} catch(ex) {
document.getElementById("result").innerHTML += "<br>Encountered exception " + ex + " while posting message to '" + origin + "'.";
}
}
function test() {
var iframe = document.getElementById('child');
win = iframe.contentWindow;
// Non-URLs should fail with a syntax error.
tryPostMessage("");
tryPostMessage("asdf");
tryPostMessage("/tmp/foo");
tryPostMessage("//localhost");
// URLs without an origin should fail with a syntax error.
tryPostMessage("asdf:");
tryPostMessage("http:");
win.postMessage('done', '*');
}
</script>
<body>
<div>window.location.href = <script>document.write(window.location.href);</script></div>
<div id="result">waiting...</div>
<div><iframe src="http://localhost:8000/security/postMessage/resources/post-message-listener.html" onload="test()"
id="child" width="800" height="300" style="border: 1px solid black;">
</iframe></div>
</body>
</html>