tor-browser

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

test_bug860494.xhtml (2727B)


      1 <?xml version="1.0"?>
      2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
      3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
      4 <!--
      5 https://bugzilla.mozilla.org/show_bug.cgi?id=860494
      6 -->
      7 <window title="Mozilla Bug 860494"
      8        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
     10 
     11  <!-- test results are displayed in the html:body -->
     12  <body xmlns="http://www.w3.org/1999/xhtml">
     13  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=860494"
     14     target="_blank">Mozilla Bug 860494</a>
     15  </body>
     16 
     17  <!-- test code goes here -->
     18  <script type="application/javascript">
     19  <![CDATA[
     20  /** Test for Bug 860494 */
     21 
     22  SimpleTest.waitForExplicitFinish();
     23 
     24  function go() {
     25    var iwin = $('ifr').contentWindow;
     26    // NB: mochitest-chrome actually runs the test as a content docshell.
     27    is(iwin.top, window.top, "iframe names shouldn't shadow |top| via Xray");
     28    is(iwin.parent, window, "iframe names shouldn't shadow |parent| via Xray");
     29    ok(!!/http/.exec(iwin.location), "iframe names shouldn't shadow |location| via Xray");
     30    is(iwin.length, 7, "iframe names shouldn't shadow |length| via Xray");
     31    is(iwin.window, iwin, "iframe names shouldn't shadow |window| via Xray");
     32    is(iwin.navigator, Cu.unwaiveXrays(iwin.wrappedJSObject.navigator),
     33       "iframe names shouldn't shadow |navigator| via Xray");
     34    ok(iwin.alert instanceof Function,
     35       "iframe names shouldn't shadow |alert| via Xray");
     36 
     37    // Now test XOWs.
     38    var sb = new Cu.Sandbox("https://www.example.com");
     39    sb.win = iwin;
     40    sb.topWin = top;
     41    sb.parentWin = window;
     42    sb.is = is;
     43    sb.ok = ok;
     44    Cu.evalInSandbox('ok(win.top === topWin, "iframe names shouldnt shadow |top| via cross-origin Xray");', sb);
     45    Cu.evalInSandbox('ok(win.parent === parentWin, "iframe names shouldnt shadow |parent| via cross-origin Xray");', sb);
     46    Cu.evalInSandbox('is(win.length, 7, "iframe names shouldnt shadow |length| via cross-origin Xray");', sb);
     47    Cu.evalInSandbox('ok(win.window === win, "iframe names shouldnt shadow |window| via cross-origin Xray");', sb);
     48    Cu.evalInSandbox('ok(win.navigator === win[5], "iframe names that correspond to non-cross-origin-visible properties should expose the subframe: navigator");', sb);
     49    Cu.evalInSandbox('ok(win.alert === win[6], "iframe names that correspond to non-cross-origin-visible properties should expose the subframe: alert");', sb);
     50 
     51    SimpleTest.finish();
     52  }
     53 
     54  ]]>
     55  </script>
     56  <iframe id="ifr" type="content" onload="go();" src="https://example.org/tests/js/xpconnect/tests/mochitest/file_bug860494.html" />
     57 </window>