dom/tests/mochitest/whatwg/test_postMessage_idn.xhtml

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

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

mercurial