tor-browser

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

test_bug396851.html (1489B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=396851
      5 -->
      6 <head>
      7  <title>Test for Bug 396851</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     10 
     11  <script type="text/javascript">
     12  function throws(func, pattern, msg) {
     13    try {
     14      func();
     15      ok(false, msg);
     16    } catch (e) {
     17      ok(pattern.test(e), `${msg}: Expect exception mathing ${pattern}`);
     18    }
     19  }
     20 
     21  function go() {
     22    var iframe = $("ifr");
     23    var win = iframe.contentWindow;
     24    throws(() => win.document,
     25           /Permission denied/,
     26           "Unprivileged code should not be able to access cross-origin document");
     27 
     28    if (SpecialPowers.useRemoteSubframes) {
     29      throws(() => win.document,
     30             /Permission denied/,
     31             "Privileged code should not be able to access cross-process document");
     32    } else {
     33      ok(SpecialPowers.wrap(win).document != null,
     34         "Able to access the cross-origin document");
     35    }
     36    SimpleTest.finish();
     37  }
     38  </script>
     39 </head>
     40 <body>
     41 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=396851">Mozilla Bug 396851</a>
     42 <p id="display"></p>
     43 <div id="content" style="display: none">
     44 </div>
     45 <script type="text/javascript">
     46    SimpleTest.waitForExplicitFinish();
     47 </script>
     48 <iframe id="ifr"
     49        src="http://example.org/tests/js/xpconnect/tests/mochitest/inner.html"
     50        onload="go()">
     51 </iframe>
     52 </body>
     53 </html>