toolkit/components/passwordmgr/test/test_bug_444968.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 <head>
     4   <title>Test for Login Manager</title>
     5   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>  
     6   <script type="text/javascript" src="pwmgr_common.js"></script>
     7   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     8 </head>
     9 <body>
    10 Login Manager test: 444968
    11 <script>
    12 commonInit();
    13 SimpleTest.waitForExplicitFinish();
    15 const Ci = SpecialPowers.Ci;
    16 const Cc = SpecialPowers.Cc;
    17 pwmgr = Cc["@mozilla.org/login-manager;1"].
    18         getService(Ci.nsILoginManager);
    20 login1A  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    21            createInstance(Ci.nsILoginInfo);
    22 login1B  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    23            createInstance(Ci.nsILoginInfo);
    24 login2A  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    25            createInstance(Ci.nsILoginInfo);
    26 login2B  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    27            createInstance(Ci.nsILoginInfo);
    28 login2C  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    29            createInstance(Ci.nsILoginInfo);
    31 login1A.init("http://mochi.test:8888", "http://bug444968-1", null,
    32             "testuser1A", "testpass1A", "", "");
    33 login1B.init("http://mochi.test:8888", "http://bug444968-1", null,
    34             "", "testpass1B", "", "");
    36 login2A.init("http://mochi.test:8888", "http://bug444968-2", null,
    37             "testuser2A", "testpass2A", "", "");
    38 login2B.init("http://mochi.test:8888", "http://bug444968-2", null,
    39             "", "testpass2B", "", "");
    40 login2C.init("http://mochi.test:8888", "http://bug444968-2", null,
    41             "testuser2C", "testpass2C", "", "");
    43 pwmgr.addLogin(login1A);
    44 pwmgr.addLogin(login1B);
    45 pwmgr.addLogin(login2A);
    46 pwmgr.addLogin(login2B);
    47 pwmgr.addLogin(login2C);
    48 </script>
    50 <p id="display"></p>
    51 <div id="content" style="display: none">
    52   <!-- first 3 forms have matching user+pass and pass-only logins -->
    54   <!-- user+pass form. -->
    55   <form id="form1" action="http://bug444968-1">
    56     <input  type="text"     name="uname">
    57     <input  type="password" name="pword">
    58     <button type="submit">Submit</button>
    59   </form>
    61   <!-- password-only form. -->
    62   <form id="form2" action="http://bug444968-1">
    63     <input  type="password" name="pword">
    64     <button type="submit">Submit</button>
    65   </form>
    67   <!-- user+pass form, username prefilled -->
    68   <form id="form3" action="http://bug444968-1">
    69     <input  type="text"     name="uname" value="testuser1A">
    70     <input  type="password" name="pword">
    71     <button type="submit">Submit</button>
    72   </form>
    75   <!-- next 4 forms have matching user+pass (2x) and pass-only (1x) logins -->
    77   <!-- user+pass form. -->
    78   <form id="form4" action="http://bug444968-2">
    79     <input  type="text"     name="uname">
    80     <input  type="password" name="pword">
    81     <button type="submit">Submit</button>
    82   </form>
    84   <!-- password-only form. -->
    85   <form id="form5" action="http://bug444968-2">
    86     <input  type="password" name="pword">
    87     <button type="submit">Submit</button>
    88   </form>
    90   <!-- user+pass form, username prefilled -->
    91   <form id="form6" action="http://bug444968-2">
    92     <input  type="text"     name="uname" value="testuser2A">
    93     <input  type="password" name="pword">
    94     <button type="submit">Submit</button>
    95   </form>
    97   <!-- user+pass form, username prefilled -->
    98   <form id="form7" action="http://bug444968-2">
    99     <input  type="text"     name="uname" value="testuser2C">
   100     <input  type="password" name="pword">
   101     <button type="submit">Submit</button>
   102   </form>
   104 </div>
   105 <pre id="test">
   106 <script class="testbody" type="text/javascript">
   108 /* Test for Login Manager: 444968 (password-only forms should prefer a
   109  * password-only login when present )
   110  */
   111 function startTest() {
   112   checkForm(1, "testuser1A", "testpass1A");
   113   checkForm(2, "testpass1B");
   114   checkForm(3, "testuser1A", "testpass1A");
   116   checkUnmodifiedForm(4); // 2 logins match
   117   checkForm(5, "testpass2B");
   118   checkForm(6, "testuser2A", "testpass2A");
   119   checkForm(7, "testuser2C", "testpass2C");
   121   pwmgr.removeLogin(login1A);
   122   pwmgr.removeLogin(login1B);
   123   pwmgr.removeLogin(login2A);
   124   pwmgr.removeLogin(login2B);
   125   pwmgr.removeLogin(login2C);
   127   SimpleTest.finish();
   128 }
   130 window.onload = startTest;
   131 </script>
   132 </pre>
   133 </body>
   134 </html>

mercurial