toolkit/components/passwordmgr/test/test_bug_654348.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

     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>

mercurial