dom/tests/mochitest/whatwg/postMessage_idn_helper.html

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 <!DOCTYPE html>
     2 <html>
     3 <head>
     4   <title>postMessage IDN test page</title>
     5   <script type="application/javascript">
     6     function receiveMessage(evt)
     7     {
     8       var response = "idn-response";
    10       if (!(evt instanceof MessageEvent))
    11         response += " not-a-MessageEvent";
    12       if (evt.origin !== "http://mochi.test:8888")
    13         response += " wrong-sender-origin(" + evt.origin + ")";
    14       if (evt.data !== "idn-message")
    15         response += " wrong-data(" + evt.data + ")";
    16       if (evt.lastEventId !== "")
    17         response += " wrong-lastEventId(" + evt.lastEventId + ")";
    18       if (evt.source !== window.parent)
    19         response += " wrong-source";
    20       if (evt.target !== window)
    21         response += " wrong-target";
    22       if (evt.type !== "message")
    23         response += " wrong-type(" + evt.type + ")";
    25       evt.source.postMessage(response, evt.origin);
    26     }
    27     window.addEventListener("message", receiveMessage, false);
    29     function setup()
    30     {
    31       var target = document.getElementById("location");
    32       target.textContent = location.hostname + ":" + (location.port || 80);
    33     }
    35     window.addEventListener("load", setup, false);
    36   </script>
    37 </head>
    38 <body>
    39 <h1 id="location">No location!</h1>
    40 </body>
    41 </html>

mercurial