tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_postMessage_onOther.html (1558B)


      1 <!DOCTYPE html>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage
      5 -->
      6 <head>
      7  <title>postMessage called through a different same-origin page</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>        
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage">Mozilla Bug 387706</a>
     13 <p id="display"></p>
     14 <div id="content" style="display: none"></div>
     15 
     16 <iframe src="http://example.com/tests/dom/tests/mochitest/whatwg/postMessage_onOther.html"
     17        name="topDomainFrame"></iframe>
     18 <iframe src="http://test1.example.com/tests/dom/tests/mochitest/whatwg/postMessage_onOther.html"
     19        name="subDomainFrame"></iframe>
     20 
     21 
     22 <pre id="test">
     23 <script class="testbody" type="application/javascript">
     24 /** Test for Bug 387706 */
     25 
     26 SimpleTest.waitForExplicitFinish();
     27 
     28 /** Receives MessageEvents to this window. */
     29 function messageReceiver(evt)
     30 {
     31  ok(evt instanceof MessageEvent, "wrong event type");
     32  is(evt.origin, "http://test1.example.com", "unexpected origin");
     33  is(evt.lastEventId, "", "postMessage creates events with empty lastEventId");
     34  is(evt.data, "test-finished",
     35     "unexpected data in message");
     36 
     37  SimpleTest.finish();
     38 }
     39 
     40 function run()
     41 {
     42  window.frames.subDomainFrame.postMessage("start-test",
     43                                           "http://test1.example.com");
     44 }
     45 
     46 window.addEventListener("message", messageReceiver);
     47 window.addEventListener("load", run);
     48 </script>
     49 </pre>
     50 </body>
     51 </html>