tor-browser

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

test_prefOnConstructor.html (1688B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1604340
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 1604340</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     11  <script type="application/javascript">
     12  /* global WrapperCachedNonISupportsTestInterface */
     13  SimpleTest.waitForExplicitFinish();
     14  SpecialPowers.pushPrefEnv({set: [["dom.expose_test_interfaces", true]]}, go);
     15 
     16  async function go() {
     17    await SpecialPowers.pushPrefEnv({set: [["dom.webidl.test1", false]]});
     18    let result = null;
     19    let constructorThrew = false;
     20 
     21    try {
     22      result = new WrapperCachedNonISupportsTestInterface();
     23    } catch {
     24      constructorThrew = true;
     25    }
     26 
     27    is(result, null, "The result value should remain null if the constructor threw an exception as intended.");
     28    ok(constructorThrew, "The constructor should throw an exception if its pref is not set to true.");
     29 
     30    await SpecialPowers.pushPrefEnv({set: [["dom.webidl.test1", true]]});
     31    result = null;
     32    constructorThrew = false;
     33 
     34    try {
     35      result = new WrapperCachedNonISupportsTestInterface();
     36    } catch {
     37      constructorThrew = true;
     38    }
     39 
     40    isnot(result, null, "Constructor should have executed successfully.");
     41    ok(!constructorThrew, "The constructor should not throw an exception if its pref is set.");
     42 
     43    SimpleTest.finish();
     44  }
     45 
     46  </script>
     47 </head>
     48 <body>
     49 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1604340">Mozilla Bug 1604340</a>
     50 <p id="display"></p>
     51 <div id="content" style="display: none">
     52 
     53 </div>
     54 <pre id="test">
     55 </pre>
     56 </body>
     57 </html>