Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=776171 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 776171</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 onload="startTest()"> |
michael@0 | 12 | <script class="testbody" type="text/javascript"> |
michael@0 | 13 | |
michael@0 | 14 | /** |
michael@0 | 15 | * This test checks we correctly ignore authentication entry |
michael@0 | 16 | * for a subpath and use creds from the URL when provided when XHR |
michael@0 | 17 | * is used with filled user name and password. |
michael@0 | 18 | * |
michael@0 | 19 | * 1. connect auth2/authenticate.sjs that excepts user1:pass1 password |
michael@0 | 20 | * 2. connect a dummy URL at the same path |
michael@0 | 21 | * 3. connect authenticate.sjs that again expects user1:pass1 password |
michael@0 | 22 | * in this case, however, we have an entry without an identity |
michael@0 | 23 | * for this path (that is a parent for auth2 path in the first step) |
michael@0 | 24 | */ |
michael@0 | 25 | |
michael@0 | 26 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 27 | |
michael@0 | 28 | function clearAuthCache() |
michael@0 | 29 | { |
michael@0 | 30 | var authMgr = SpecialPowers.Cc['@mozilla.org/network/http-auth-manager;1'] |
michael@0 | 31 | .getService(SpecialPowers.Ci.nsIHttpAuthManager); |
michael@0 | 32 | authMgr.clearAll(); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | function doxhr(URL, user, pass, next) |
michael@0 | 36 | { |
michael@0 | 37 | var xhr = new XMLHttpRequest(); |
michael@0 | 38 | if (user && pass) |
michael@0 | 39 | xhr.open("POST", URL, true, user, pass); |
michael@0 | 40 | else |
michael@0 | 41 | xhr.open("POST", URL, true); |
michael@0 | 42 | xhr.onload = function() |
michael@0 | 43 | { |
michael@0 | 44 | is(xhr.status, 200, "Got status 200"); |
michael@0 | 45 | next(); |
michael@0 | 46 | } |
michael@0 | 47 | xhr.onerror = function() |
michael@0 | 48 | { |
michael@0 | 49 | ok(false, "request passed"); |
michael@0 | 50 | finishTest(); |
michael@0 | 51 | } |
michael@0 | 52 | xhr.send(); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | function startTest() |
michael@0 | 56 | { |
michael@0 | 57 | clearAuthCache(); |
michael@0 | 58 | doxhr("auth2/authenticate.sjs?user=user1&pass=pass1&realm=realm1", "user1", "pass1", function() { |
michael@0 | 59 | doxhr("auth2", null, null, function() { |
michael@0 | 60 | doxhr("authenticate.sjs?user=user1&pass=pass1&realm=realm1", "user1", "pass1", finishTest); |
michael@0 | 61 | }); |
michael@0 | 62 | }); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | function finishTest() |
michael@0 | 66 | { |
michael@0 | 67 | clearAuthCache(); |
michael@0 | 68 | SimpleTest.finish(); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | </script> |
michael@0 | 72 | </body> |
michael@0 | 73 | </html> |
michael@0 | 74 |