test_postMessage_idn.xhtml (1895B)
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE html> 3 <html xmlns="http://www.w3.org/1999/xhtml"> 4 <!-- 5 https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage 6 --> 7 <head> 8 <title>postMessage uri/domain values and IDN encoding</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage">Mozilla Bug 387706</a> 14 <p id="display"></p> 15 <div id="content" style="display: none"></div> 16 17 <iframe src="http://sub1.ält.example.org:8000/tests/dom/tests/mochitest/whatwg/postMessage_idn_helper.html"></iframe> 18 19 <pre id="test"> 20 <script class="testbody" type="application/javascript"> 21 /** Test for Bug 387706 */ 22 23 SimpleTest.waitForExplicitFinish(); 24 25 var responseReceived = false; 26 var idnWindow = null; 27 28 function receiveMessage(evt) 29 { 30 ok(evt instanceof MessageEvent, "umm, how did we get this?"); 31 is(evt.type, "message", "expected events of type 'message'"); 32 ok(evt.isTrusted === true, "should have been a trusted event"); 33 34 is(evt.origin, "http://sub1.xn--lt-uia.example.org:8000", 35 "wrong origin -- IDN issue, perhaps?"); 36 37 is(evt.data, "idn-response", "unexpected test result"); 38 is(evt.lastEventId, "", "postMessage creates events with empty lastEventId"); 39 ok(evt.source === idnWindow, "wrong source"); 40 41 SimpleTest.finish(); 42 } 43 window.addEventListener("message", receiveMessage); 44 45 var xhtmlns = "http://www.w3.org/1999/xhtml"; 46 47 function setup() 48 { 49 var idnFrame = document.getElementsByTagNameNS(xhtmlns, "iframe")[0]; 50 idnWindow = idnFrame.contentWindow; 51 try 52 { 53 idnWindow.postMessage("idn-message", "http://sub1.ält.example.org:8000"); 54 } 55 catch (e) 56 { 57 ok(false, "failed to post message: " + e); 58 SimpleTest.finish(); 59 } 60 } 61 62 addLoadEvent(setup); 63 </script> 64 </pre> 65 </body> 66 </html>