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