Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / base / test / test_bug282547.html
blob4c310a27241907ff06abf66ede8dcde8b9d6a651
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>
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();
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();
39 xhr.send(null);
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();
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();
65 xhr.send(null);
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;
73 xhr.onreadystatechange = function() {
74 if (xhr.readyState == 4) {
75 ok(xhr.status == 401, "Status 401");
76 runTests();
80 xhr.send(null);
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;
94 var test = tests.shift();
95 test();
98 runTests();
99 SimpleTest.waitForExplicitFinish();
101 </script>
102 </body>
103 </html>