tor-browser

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

test_bug932906.xhtml (2235B)


      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=932906
      6 -->
      7 <window title="Mozilla Bug 932906"
      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=932906"
     14     target="_blank">Mozilla Bug 932906</a>
     15  </body>
     16 
     17  <!-- test code goes here -->
     18  <script type="application/javascript">
     19  <![CDATA[
     20  /** Test for Bug 932906 */
     21  SimpleTest.waitForExplicitFinish();
     22 
     23  function passToContent(shouldThrow) {
     24    try {
     25      $('ifr').contentWindow.obs = Services.obs;
     26      ok(!shouldThrow, "Didn't throw when passing non-DOM XPCWN to content");
     27    } catch (e) {
     28      ok(shouldThrow, "Threw when passing non-DOM XPCWN to content");
     29      ok(/denied/.test(e), "Threw correct exception: " + e);
     30    }
     31  }
     32 
     33  var gLoadCount = 0;
     34  function loaded() {
     35    ++gLoadCount;
     36    if (gLoadCount == 1)
     37      part1();
     38    else if (gLoadCount == 2)
     39      part2();
     40    else
     41      ok(false, "Didn't expect three loads");
     42  }
     43 
     44  function part1() {
     45 
     46    // Make sure that the pref is what we expect for mochitests.
     47    is(Services.prefs.getBoolPref('dom.use_xbl_scopes_for_remote_xul'), true,
     48       "Test harness set up like we expect");
     49 
     50 
     51    // First, test that we can't normally pass non-DOM XPCWNs to content.
     52    passToContent(/* shouldThrow = */ true);
     53 
     54    // Now, make sure we _can_ for the remote xul case. We use SpecialPowers
     55    // for the pref munging because it cleans up after us.
     56    SpecialPowers.pushPrefEnv({set: [['dom.use_xbl_scopes_for_remote_xul', false]]}, function() {
     57      $('ifr').contentWindow.location.reload();
     58    });
     59  }
     60 
     61  function part2() {
     62      passToContent(/* shouldThrow = */ false);
     63      SimpleTest.finish();
     64  }
     65 
     66  ]]>
     67  </script>
     68  <iframe id="ifr" onload="loaded();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
     69 </window>