OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title> Same-origin postMessage with targetOrigin == "/" </title> |
| 5 <script src="/resources/testharness.js"></script> |
| 6 <script src="/resources/testharnessreport.js"></script> |
| 7 </head> |
| 8 <body> |
| 9 <div id=log></div> |
| 10 |
| 11 <div style="display:none"> |
| 12 <iframe width="70%" onload="PostMessageTest()" src="./support/ChildWindowPos
tMessage.htm"></iframe> |
| 13 </div> |
| 14 |
| 15 <script> |
| 16 |
| 17 |
| 18 var description = "Test Description: " + |
| 19 "To restrict the message to same-origin targets only, with
out needing to explicitly " + |
| 20 "state the origin, set the target origin to '/'."; |
| 21 |
| 22 var t = async_test(description); |
| 23 |
| 24 var DATA = "/"; |
| 25 var TARGET = document.querySelector("iframe"); |
| 26 var SORIGIN = location.protocol + "//" + location.host; |
| 27 var ExpectedResult = [DATA, SORIGIN]; |
| 28 var ActualResult = []; |
| 29 |
| 30 function PostMessageTest() |
| 31 { |
| 32 TARGET.contentWindow.postMessage(DATA, "/"); |
| 33 } |
| 34 |
| 35 window.onmessage = t.step_func(function(e) |
| 36 { |
| 37 ActualResult.push(e.data, e.origin); |
| 38 assert_array_equals(ActualResult, ExpectedResult, "ActualResult"); |
| 39 t.done(); |
| 40 }); |
| 41 </script> |
| 42 </body> |
| 43 </html> |
OLD | NEW |