tor-browser

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

test_bug282547.html (2309B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=282547
      5 -->
      6 <head>
      7  <title>Test for Bug 282547</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=282547">Mozilla Bug 282547</a>
     13 <p id="display"></p>
     14 <div id="content" style="display: none"></div>
     15 
     16 <script class="testbody" type="text/javascript">
     17 
     18 function xhr_userpass_sync() {
     19  var xhr = new XMLHttpRequest();
     20  xhr.open('GET', 'bug282547.sjs', false, 'username', 'password');
     21 
     22  xhr.send(null);
     23  ok(xhr.status == 401, "Status 401");
     24 
     25  runTests();
     26 }
     27 
     28 function xhr_userpass_async() {
     29  xhr = new XMLHttpRequest();
     30  xhr.open('GET', 'bug282547.sjs', true, 'username', 'password');
     31 
     32  xhr.onreadystatechange = function() {
     33    if (xhr.readyState == 4) {
     34      ok(xhr.status == 401, "Status 401");
     35      runTests();
     36    }
     37  }
     38 
     39  xhr.send(null);
     40 }
     41 
     42 function xhr_auth_header_sync() {
     43  var xhr = new XMLHttpRequest();
     44  xhr.open('GET', 'bug282547.sjs', false);
     45  xhr.setRequestHeader("Authorization", "42");
     46 
     47  xhr.send(null);
     48  ok(xhr.status == 401, "Status 401");
     49 
     50  runTests();
     51 }
     52 
     53 function xhr_auth_header_async() {
     54  var xhr = new XMLHttpRequest();
     55  xhr.open('GET', 'bug282547.sjs', true);
     56  xhr.setRequestHeader("Authorization", "42");
     57 
     58  xhr.onreadystatechange = function() {
     59    if (xhr.readyState == 4) {
     60      ok(xhr.status == 401, "Status 401");
     61      runTests();
     62    }
     63  }
     64 
     65  xhr.send(null);
     66 }
     67 
     68 function xhr_crossorigin_sync() {
     69  var xhr = new XMLHttpRequest();
     70  xhr.open('GET', 'http://example.com/tests/dom/base/test/bug282547.sjs', true);
     71  xhr.withCredentials = true;
     72 
     73  xhr.onreadystatechange = function() {
     74    if (xhr.readyState == 4) {
     75      ok(xhr.status == 401, "Status 401");
     76      runTests();
     77    }
     78  }
     79 
     80  xhr.send(null);
     81 }
     82 
     83 var tests = [ xhr_userpass_sync,
     84              xhr_userpass_async,
     85              xhr_auth_header_sync,
     86              xhr_auth_header_async,
     87              /* Disabled: bug799540 xhr_crossorigin_sync */ ];
     88 function runTests() {
     89  if (!tests.length) {
     90    SimpleTest.finish();
     91    return;
     92  }
     93 
     94  var test = tests.shift();
     95  test();
     96 }
     97 
     98 runTests();
     99 SimpleTest.waitForExplicitFinish();
    100 
    101 </script>
    102 </body>
    103 </html>