dom/tests/mochitest/whatwg/postMessage_override_helper.html

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.

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4   <title>Overriding postMessage and dispatchEvent bindings</title>
     5   <script type="application/javascript">
     6     window.postMessage = function (evt)
     7     {
     8       window.parent.postMessage("FAIL overridden postMessage called", "*");
     9     };
    11     var count = 0;
    13     function receiveMessage(evt)
    14     {
    15       count++;
    16       if (count == 1)
    17       {
    18         window.dispatchEvent = function(evt)
    19         {
    20           window.parent.postMessage("FAIL", "*");
    21           throw "dispatchEvent threw";
    22         };
    23       }
    25       window.parent.postMessage(evt.data, "http://mochi.test:8888");
    26     }
    28     function setup()
    29     {
    30       var target = document.getElementById("location");
    31       target.textContent = location.hostname + ":" + (location.port || 80);
    32     }
    34     window.addEventListener("message", receiveMessage, false);
    36     window.addEventListener("load", setup, false);
    37   </script>
    38 </head>
    39 <body>
    40 <h1 id="location">No location!</h1>
    41 </body>
    42 </html>

mercurial