dom/tests/mochitest/whatwg/test_postMessage_idn.xhtml

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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>
    18 <iframe src="http://sub1.ält.example.org:8000/tests/dom/tests/mochitest/whatwg/postMessage_idn_helper.html"></iframe>
    20 <pre id="test">
    21 <script class="testbody" type="application/javascript">
    22 /** Test for Bug 387706 **/
    24 SimpleTest.waitForExplicitFinish();
    26 var responseReceived = false;
    27 var idnWindow = null;
    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'");
    34   if (isMozilla)
    35   {
    36     ok(evt.isTrusted === false, "shouldn't have been a trusted event");
    37   }
    39   is(evt.origin, "http://sub1.ält.example.org:8000",
    40      "wrong origin -- IDN issue, perhaps?");
    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");
    46   SimpleTest.finish();
    47 }
    48 window.addEventListener("message", receiveMessage, false);
    50 var xhtmlns = "http://www.w3.org/1999/xhtml";
    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 }
    67 addLoadEvent(setup);
    68 </script>
    69 </pre>
    70 </body>
    71 </html>

mercurial