dom/tests/mochitest/whatwg/postMessage_override_helper.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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