tor-browser

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

test_getWebIDLCaller.html (1225B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=968335
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 968335</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 
     13  /** Test for Cu.getCallerPrincipal (within JS-implemented WebIDL). **/
     14 
     15  SimpleTest.waitForExplicitFinish();
     16  SpecialPowers.pushPrefEnv({set: [['dom.expose_test_interfaces', true]]}, go);
     17 
     18 
     19  function go() {
     20    var t = new TestInterfaceJS();
     21    is(t.getCallerPrincipal(), location.origin,
     22       "Cu.getCallerPrincipal works right within JS-implemented WebIDL");
     23 
     24    try {
     25      SpecialPowers.Cu.getWebIDLCallerPrincipal();
     26      ok(false, "Should have thrown");
     27    } catch (e) {
     28      ok(/NOT_AVAILABLE/.test(SpecialPowers.wrap(e)),
     29         "API should throw when invoked outside of JS-implemented WebIDL");
     30    }
     31 
     32    SimpleTest.finish();
     33  }
     34 
     35 
     36 
     37 
     38  </script>
     39 </head>
     40 <body>
     41 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=968335">Mozilla Bug 968335</a>
     42 <p id="display"></p>
     43 <div id="content" style="display: none">
     44 
     45 </div>
     46 <pre id="test">
     47 </pre>
     48 </body>
     49 </html>