4 <script src=
"resources/recv.js"></script>
6 if (window
.testRunner
) {
7 testRunner
.dumpAsText();
8 testRunner
.waitUntilDone();
11 addEventListener("message", recv
, false);
13 function tryPostMessage(origin
) {
15 win
.postMessage("Trying origin=" + origin
, origin
);
16 document
.getElementById("result").innerHTML
+= "<br>Posted message to '" + origin
+ "' without any exceptions.";
18 document
.getElementById("result").innerHTML
+= "<br>Encountered exception \"" + ex
+ "\" while posting message to '" + origin
+ "'.";
23 var iframe
= document
.getElementById('child');
24 win
= iframe
.contentWindow
;
26 // Non-URLs should fail with a syntax error.
28 tryPostMessage("asdf");
29 tryPostMessage("/tmp/foo");
30 tryPostMessage("//localhost");
32 // URLs without an origin should fail without generating any errors.
33 tryPostMessage("asdf:");
34 tryPostMessage("http:");
36 win
.postMessage('done', '*');
40 <div>window.location.href =
<script>document
.write(window
.location
.href
);</script></div>
41 <div id=
"result">waiting...
</div>
42 <div><iframe src=
"http://localhost:8000/security/postMessage/resources/post-message-listener.html" onload=
"test()"
43 id=
"child" width=
"800" height=
"300" style=
"border: 1px solid black;">