1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug282547.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,104 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=282547 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 282547</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=282547">Mozilla Bug 282547</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"></div> 1.18 + 1.19 +<script class="testbody" type="text/javascript"> 1.20 + 1.21 +function xhr_userpass_sync() { 1.22 + var xhr = new XMLHttpRequest(); 1.23 + xhr.open('GET', 'bug282547.sjs', false, 'username', 'password'); 1.24 + 1.25 + xhr.send(null); 1.26 + ok(xhr.status == 401, "Status 401"); 1.27 + 1.28 + runTests(); 1.29 +} 1.30 + 1.31 +function xhr_userpass_async() { 1.32 + xhr = new XMLHttpRequest(); 1.33 + xhr.open('GET', 'bug282547.sjs', true, 'username', 'password'); 1.34 + 1.35 + xhr.onreadystatechange = function() { 1.36 + if (xhr.readyState == 4) { 1.37 + ok(xhr.status == 401, "Status 401"); 1.38 + runTests(); 1.39 + } 1.40 + } 1.41 + 1.42 + xhr.send(null); 1.43 +} 1.44 + 1.45 +function xhr_auth_header_sync() { 1.46 + var xhr = new XMLHttpRequest(); 1.47 + xhr.open('GET', 'bug282547.sjs', false); 1.48 + xhr.setRequestHeader("Authorization", "42"); 1.49 + 1.50 + xhr.send(null); 1.51 + ok(xhr.status == 401, "Status 401"); 1.52 + 1.53 + runTests(); 1.54 +} 1.55 + 1.56 +function xhr_auth_header_async() { 1.57 + var xhr = new XMLHttpRequest(); 1.58 + xhr.open('GET', 'bug282547.sjs', true); 1.59 + xhr.setRequestHeader("Authorization", "42"); 1.60 + 1.61 + xhr.onreadystatechange = function() { 1.62 + if (xhr.readyState == 4) { 1.63 + ok(xhr.status == 401, "Status 401"); 1.64 + runTests(); 1.65 + } 1.66 + } 1.67 + 1.68 + xhr.send(null); 1.69 +} 1.70 + 1.71 +function xhr_crossorigin_sync() { 1.72 + var xhr = new XMLHttpRequest(); 1.73 + xhr.open('GET', 'http://example.com/tests/content/base/test/bug282547.sjs', true); 1.74 + xhr.withCredentials = true; 1.75 + 1.76 + xhr.onreadystatechange = function() { 1.77 + if (xhr.readyState == 4) { 1.78 + ok(xhr.status == 401, "Status 401"); 1.79 + runTests(); 1.80 + } 1.81 + } 1.82 + 1.83 + xhr.send(null); 1.84 +} 1.85 + 1.86 +var tests = [ xhr_userpass_sync, 1.87 + xhr_userpass_async, 1.88 + xhr_auth_header_sync, 1.89 + xhr_auth_header_async, 1.90 + /* Disabled: bug799540 xhr_crossorigin_sync */ ]; 1.91 +function runTests() { 1.92 + if (!tests.length) { 1.93 + SimpleTest.finish(); 1.94 + return; 1.95 + } 1.96 + 1.97 + var test = tests.shift(); 1.98 + test(); 1.99 +} 1.100 + 1.101 +runTests(); 1.102 +SimpleTest.waitForExplicitFinish(); 1.103 + 1.104 +</script> 1.105 +</body> 1.106 +</html> 1.107 +