tor-browser

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

test_bug792280.xhtml (1629B)


      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=792280
      6 -->
      7 <window title="Mozilla Bug 792280"
      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=792280"
     14     target="_blank">Mozilla Bug 792280</a>
     15  </body>
     16 
     17  <!-- test code goes here -->
     18  <script type="application/javascript">
     19  <![CDATA[
     20  /** Test for Bug 792280 */
     21  function checkSb(sb, expect) {
     22    var target = new Cu.Sandbox("https://www.example.com");
     23    Cu.evalInSandbox('function fun() { return arguments.callee.caller; };', target);
     24    sb.fun = target.fun;
     25    let allowed = false;
     26    try {
     27      allowed = Cu.evalInSandbox('function doTest() { return fun() == doTest; }; doTest()', sb);
     28      isnot(expect, "throw", "Should have thrown");
     29    } catch (e) {
     30      is(expect, "throw", "Should expect exception");
     31      ok(/denied|insecure/.test(e), "Should be a security exception: " + e);
     32    }
     33    is(allowed, expect == "allow", "should censor appropriately");
     34  }
     35 
     36  // Note that COWs are callable, but XOWs are not.
     37  checkSb(new Cu.Sandbox("https://www.example.com"), "allow");
     38  checkSb(new Cu.Sandbox("https://www.example.org"), "throw");
     39  checkSb(new Cu.Sandbox(window), "censor");
     40 
     41  ]]>
     42  </script>
     43 </window>