dom/tests/mochitest/chrome/test_sandbox_postMessage.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>Testing postMessage from sandbox</title>
     5   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     6   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
     7 <script type="application/javascript">
     8   SimpleTest.waitForExplicitFinish();
     9   function doTest() {
    10     var sandbox = Components.utils.Sandbox("http://mochi.test:8888/", { wantXrays: true });
    11     var win = window.frames["sameDomain"];
    12     sandbox.win = win;
    13     sandbox.is = is;
    14     sandbox.done = SimpleTest.finish;
    16     result = Components.utils.evalInSandbox('var data = {some:"data"};'
    17     +'win.addEventListener("message", receiveMessage, false);'
    18     +'function receiveMessage(event)'
    19     +'{'
    20     +'  is(JSON.stringify(event.data), JSON.stringify(data), "Received the expected message data");'
    21     +'  done();'
    22     +'}'
    23     +'win.postMessage(data, "*")'
    24     , sandbox);
    25   }
    27   addLoadEvent(doTest);
    28 </script>
    29 </head>
    30 <body>
    31 <iframe src="http://mochi.test:8888/"
    32   id="sameDomain" name="sameDomain">
    33 </iframe>
    34 </body>
    35 </html>

mercurial