OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title> event.data returns the data of the message </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="{{location[scheme]}}://{
{domains[www]}}:{{location[port]}}/webmessaging/support/ChildWindowPostMessage.h
tm"></iframe> |
| 13 <iframe width="70%" onload="PostMessageTest()" src="./support/ChildWindowPos
tMessage.htm"></iframe> |
| 14 </div> |
| 15 |
| 16 <script> |
| 17 |
| 18 |
| 19 var description = "Test Description: event.data returns the data of the mess
age."; |
| 20 |
| 21 var t = async_test(description); |
| 22 |
| 23 var PORT = location.port !== "" ? ":" + location.port : ""; |
| 24 var DATA = "STRING"; |
| 25 var TYPE = "string"; |
| 26 var TARGET1 = document.querySelectorAll("iframe")[0]; |
| 27 var TARGET2 = document.querySelectorAll("iframe")[1]; |
| 28 var XORIGIN = "{{location[scheme]}}://{{domains[www]}}" + PORT; |
| 29 var SORIGIN = "{{location[scheme]}}://{{host}}" + PORT; |
| 30 var ExpectedResult = [DATA, TYPE, DATA, TYPE]; |
| 31 var ActualResult = []; |
| 32 var loaded = 0; |
| 33 |
| 34 function PostMessageTest() |
| 35 { |
| 36 loaded++; |
| 37 |
| 38 if (loaded == 2) |
| 39 { |
| 40 TARGET1.contentWindow.postMessage(DATA, XORIGIN); |
| 41 TARGET2.contentWindow.postMessage(DATA, SORIGIN); |
| 42 } |
| 43 } |
| 44 |
| 45 window.onmessage = t.step_func(function(e) |
| 46 { |
| 47 if (e.data.toString() === "STRING") { |
| 48 ActualResult.push(e.data, typeof(e.data)); |
| 49 |
| 50 if (ActualResult.length >= ExpectedResult.length) { |
| 51 assert_array_equals(ActualResult, ExpectedResult, "ActualResult")
; |
| 52 t.done(); |
| 53 } |
| 54 } |
| 55 }); |
| 56 </script> |
| 57 </body> |
| 58 </html> |
OLD | NEW |