Wed, 31 Dec 2014 06:09:35 +0100
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=654348
5 -->
6 <head>
7 <title>Test for Bug 654348</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 onload="startTest()">
12 <script class="testbody" type="text/javascript">
14 /**
15 * This test checks we correctly ignore authentication entry
16 * for a subpath and use creds from the URL when provided when XHR
17 * is used with filled user name and password.
18 *
19 * 1. connect authenticate.sjs that excepts user1:pass1 password
20 * 2. connect authenticate.sjs that this time expects differentuser2:pass2 password
21 * we must use the creds that are provided to the xhr witch are different and expected
22 */
24 SimpleTest.waitForExplicitFinish();
26 function clearAuthCache()
27 {
28 var authMgr = SpecialPowers.Cc['@mozilla.org/network/http-auth-manager;1']
29 .getService(SpecialPowers.Ci.nsIHttpAuthManager);
30 authMgr.clearAll();
31 }
33 function doxhr(URL, user, pass, code, next)
34 {
35 var xhr = new XMLHttpRequest();
36 if (user && pass)
37 xhr.open("POST", URL, true, user, pass);
38 else
39 xhr.open("POST", URL, true);
40 xhr.onload = function()
41 {
42 is(xhr.status, code, "expected response code " + code);
43 next();
44 }
45 xhr.onerror = function()
46 {
47 ok(false, "request passed");
48 finishTest();
49 }
50 xhr.send();
51 }
53 function startTest()
54 {
55 clearAuthCache();
56 doxhr("authenticate.sjs?user=dummy&pass=pass1&realm=realm1&formauth=1", "dummy", "dummy", 403, function() {
57 doxhr("authenticate.sjs?user=dummy&pass=pass1&realm=realm1&formauth=1", "dummy", "pass1", 200, finishTest);
58 });
59 }
61 function finishTest()
62 {
63 clearAuthCache();
64 SimpleTest.finish();
65 }
67 </script>
68 </body>
69 </html>