tor-browser

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

test_bug1307730.html (1150B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1307730
      5 -->
      6 <head>
      7  <title>Test for Bug 1307730</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1307730">Mozilla Bug 1307730</a>
     13 <p id="display"></p>
     14 <div id="content" style="display: none">
     15 </div>
     16 <pre id="test">
     17 <script type="application/javascript">
     18 
     19 const Cu = SpecialPowers.Cu;
     20 
     21 function runTest() {
     22  var xhr = new XMLHttpRequest();
     23  xhr.open("GET", "https://example.com", false);
     24  try {
     25    xhr.send();
     26  } catch (e) {
     27    return e.name;
     28  }
     29  return 'XHR succeeded';
     30 }
     31 
     32 function evalInSandbox(sandbox, func) {
     33  return SpecialPowers.unwrap(Cu.evalInSandbox(`(${func.toString()})()`, sandbox));
     34 }
     35 
     36 let sandbox = Cu.Sandbox([window, "https://example.org"],
     37                         {wantGlobalProperties: ['XMLHttpRequest']});
     38 is(evalInSandbox(sandbox, runTest), 'NetworkError',
     39   "Shouldn't be able to make a CORS request with an expanded principal");
     40 
     41 </script>
     42 </pre>
     43 </body>
     44 </html>