4 https://bugzilla.mozilla.org/show_bug.cgi?id=282547
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" />
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=282547">Mozilla Bug
282547</a>
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');
23 ok(xhr.status ==
401,
"Status 401");
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");
42 function xhr_auth_header_sync() {
43 var xhr = new XMLHttpRequest();
44 xhr.open('GET', 'bug282547.sjs', false);
45 xhr.setRequestHeader(
"Authorization",
"42");
48 ok(xhr.status ==
401,
"Status 401");
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");
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");
83 var tests = [ xhr_userpass_sync,
86 xhr_auth_header_async,
87 /* Disabled: bug799540 xhr_crossorigin_sync */ ];
94 var test = tests.shift();
99 SimpleTest.waitForExplicitFinish();