content/base/test/test_bug282547.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial