event.data.sub.htm (1440B)
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 <script> 12 13 14 var description = "Test Description: event.data returns the data of the message."; 15 16 var t = async_test(description); 17 18 var PORT = location.port !== "" ? ":" + location.port : ""; 19 var DATA = "STRING"; 20 var TYPE = "string"; 21 var XORIGIN = "{{location[scheme]}}://{{domains[www]}}" + PORT; 22 var SORIGIN = "{{location[scheme]}}://{{host}}" + PORT; 23 var ExpectedResult = [DATA, TYPE, DATA, TYPE]; 24 var ActualResult = []; 25 26 window.onmessage = t.step_func(function(e) 27 { 28 if (e.data.toString() === "STRING") { 29 ActualResult.push(e.data, typeof(e.data)); 30 31 if (ActualResult.length >= ExpectedResult.length) { 32 assert_array_equals(ActualResult, ExpectedResult, "ActualResult"); 33 t.done(); 34 } 35 } 36 }); 37 </script> 38 39 <div style="display:none"> 40 <iframe width="70%" onload="this.contentWindow.postMessage(DATA, XORIGIN)" src="{{location[scheme]}}://{{domains[www]}}:{{location[port]}}/webmessaging/support/ChildWindowPostMessage.htm"></iframe> 41 <iframe width="70%" onload="this.contentWindow.postMessage(DATA, SORIGIN)" src="./support/ChildWindowPostMessage.htm"></iframe> 42 </div> 43 </body> 44 </html>