content/base/test/test_bug282547.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 type="text/javascript" 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>
    16 <script class="testbody" type="text/javascript">
    18 function xhr_userpass_sync() {
    19   var xhr = new XMLHttpRequest();
    20   xhr.open('GET', 'bug282547.sjs', false, 'username', 'password');
    22   xhr.send(null);
    23   ok(xhr.status == 401, "Status 401");
    25   runTests();
    26 }
    28 function xhr_userpass_async() {
    29   xhr = new XMLHttpRequest();
    30   xhr.open('GET', 'bug282547.sjs', true, 'username', 'password');
    32   xhr.onreadystatechange = function() {
    33     if (xhr.readyState == 4) {
    34       ok(xhr.status == 401, "Status 401");
    35       runTests();
    36     }
    37   }
    39   xhr.send(null);
    40 }
    42 function xhr_auth_header_sync() {
    43   var xhr = new XMLHttpRequest();
    44   xhr.open('GET', 'bug282547.sjs', false);
    45   xhr.setRequestHeader("Authorization", "42");
    47   xhr.send(null);
    48   ok(xhr.status == 401, "Status 401");
    50   runTests();
    51 }
    53 function xhr_auth_header_async() {
    54   var xhr = new XMLHttpRequest();
    55   xhr.open('GET', 'bug282547.sjs', true);
    56   xhr.setRequestHeader("Authorization", "42");
    58   xhr.onreadystatechange = function() {
    59     if (xhr.readyState == 4) {
    60       ok(xhr.status == 401, "Status 401");
    61       runTests();
    62     }
    63   }
    65   xhr.send(null);
    66 }
    68 function xhr_crossorigin_sync() {
    69   var xhr = new XMLHttpRequest();
    70   xhr.open('GET', 'http://example.com/tests/content/base/test/bug282547.sjs', true);
    71   xhr.withCredentials = true;
    73   xhr.onreadystatechange = function() {
    74     if (xhr.readyState == 4) {
    75       ok(xhr.status == 401, "Status 401");
    76       runTests();
    77     }
    78   }
    80   xhr.send(null);
    81 }
    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   }
    94   var test = tests.shift();
    95   test();
    96 }
    98 runTests();
    99 SimpleTest.waitForExplicitFinish();
   101 </script>
   102 </body>
   103 </html>

mercurial