toolkit/components/passwordmgr/test/test_basic_form_pwonly.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 <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: forms and logins without a username.
    11 <script>
    12 commonInit();
    13 SimpleTest.waitForExplicitFinish();
    15 var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
    16                          .getService(SpecialPowers.Ci.nsILoginManager);
    18 var nsLoginInfo = new SpecialPowers.wrap(SpecialPowers.Components).Constructor("@mozilla.org/login-manager/loginInfo;1", SpecialPowers.Ci.nsILoginInfo);
    19 ok(nsLoginInfo != null, "nsLoginInfo constructor");
    21 // pwlogin1 uses a unique formSubmitURL, to check forms where no other logins
    22 // will apply. pwlogin2 uses the normal formSubmitURL, so that we can test
    23 // forms with a mix of username and non-username logins that might apply.
    24 //
    25 // Note: pwlogin2 is deleted at the end of the test.
    27 pwlogin1 = new nsLoginInfo();
    28 pwlogin2 = new nsLoginInfo();
    30 pwlogin1.init("http://mochi.test:8888", "http://mochi.test:1111", null,
    31     "", "1234", "uname", "pword");
    33 pwlogin2.init("http://mochi.test:8888", "http://mochi.test:8888", null,
    34     "", "1234", "uname", "pword");
    36 try {
    37     pwmgr.addLogin(pwlogin1);
    38     pwmgr.addLogin(pwlogin2);
    39 } catch (e) {
    40     ok(false, "addLogin threw: " + e);
    41 }
    43 </script>
    44 <p id="display"></p>
    46 <div id="content" style="display: none">
    49 <!-- simple form: no username field, 1 password field -->
    50 <form id='form1' action='http://mochi.test:1111/formtest.js'> 1
    51     <input type='password' name='pname' value=''>
    53     <button type='submit'>Submit</button>
    54     <button type='reset'> Reset </button>
    55 </form>
    57 <!-- simple form: no username field, 2 password fields -->
    58 <form id='form2' action='http://mochi.test:1111/formtest.js'> 2
    59     <input type='password' name='pname1' value=''>
    60     <input type='password' name='pname2' value=''>
    62     <button type='submit'>Submit</button>
    63     <button type='reset'> Reset </button>
    64 </form>
    66 <!-- simple form: no username field, 3 password fields -->
    67 <form id='form3' action='http://mochi.test:1111/formtest.js'> 3
    68     <input type='password' name='pname1' value=''>
    69     <input type='password' name='pname2' value=''>
    70     <input type='password' name='pname3' value=''>
    72     <button type='submit'>Submit</button>
    73     <button type='reset'> Reset </button>
    74 </form>
    76 <!-- 4 password fields, should be ignored. -->
    77 <form id='form4' action='http://mochi.test:1111/formtest.js'> 4
    78     <input type='password' name='pname1' value=''>
    79     <input type='password' name='pname2' value=''>
    80     <input type='password' name='pname3' value=''>
    81     <input type='password' name='pname4' value=''>
    83     <button type='submit'>Submit</button>
    84     <button type='reset'> Reset </button>
    85 </form>
    89 <!-- 1 username field -->
    90 <form id='form5' action='http://mochi.test:1111/formtest.js'> 5
    91     <input type='text'     name='uname' value=''>
    92     <input type='password' name='pname' value=''>
    94     <button type='submit'>Submit</button>
    95     <button type='reset'> Reset </button>
    96 </form>
    99 <!-- 1 username field, with a value set -->
   100 <form id='form6' action='http://mochi.test:1111/formtest.js'> 6
   101     <input type='text'     name='uname' value='someuser'>
   102     <input type='password' name='pname' value=''>
   104     <button type='submit'>Submit</button>
   105     <button type='reset'> Reset </button>
   106 </form>
   110 <!--
   111 (The following forms have 2 potentially-matching logins, on is
   112 password-only, the other is username+password)
   113 -->
   117 <!-- 1 username field, with value set. Fill in the matching U+P login -->
   118 <form id='form7' action='formtest.js'> 7
   119     <input type='text'     name='uname' value='testuser'>
   120     <input type='password' name='pname' value=''>
   122     <button type='submit'>Submit</button>
   123     <button type='reset'> Reset </button>
   124 </form>
   126 <!-- 1 username field, with value set. Don't fill in U+P login-->
   127 <form id='form8' action='formtest.js'> 8
   128     <input type='text'     name='uname' value='someuser'>
   129     <input type='password' name='pname' value=''>
   131     <button type='submit'>Submit</button>
   132     <button type='reset'> Reset </button>
   133 </form>
   137 <!-- 1 username field, too small for U+P login -->
   138 <form id='form9' action='formtest.js'> 9
   139     <input type='text'     name='uname' value='' maxlength="4">
   140     <input type='password' name='pname' value=''>
   142     <button type='submit'>Submit</button>
   143     <button type='reset'> Reset </button>
   144 </form>
   146 <!-- 1 username field, too small for U+P login -->
   147 <form id='form10' action='formtest.js'> 10
   148     <input type='text'     name='uname' value='' maxlength="0">
   149     <input type='password' name='pname' value=''>
   151     <button type='submit'>Submit</button>
   152     <button type='reset'> Reset </button>
   153 </form>
   155 <!-- 1 username field, too small for U+P login -->
   156 <form id='form11' action='formtest.js'> 11
   157     <input type='text'     name='uname' value=''>
   158     <input type='password' name='pname' value='' maxlength="4">
   160     <button type='submit'>Submit</button>
   161     <button type='reset'> Reset </button>
   162 </form>
   164 <!-- 1 username field, too small for either login -->
   165 <form id='form12' action='formtest.js'> 12
   166     <input type='text'     name='uname' value=''>
   167     <input type='password' name='pname' value='' maxlength="1">
   169     <button type='submit'>Submit</button>
   170     <button type='reset'> Reset </button>
   171 </form>
   173 <!-- 1 username field, too small for either login -->
   174 <form id='form13' action='formtest.js'> 13
   175     <input type='text'     name='uname' value=''>
   176     <input type='password' name='pname' value='' maxlength="0">
   178     <button type='submit'>Submit</button>
   179     <button type='reset'> Reset </button>
   180 </form>
   184 </div>
   186 <pre id="test">
   187 <script class="testbody" type="text/javascript">
   189 /** Test for Login Manager: password-only logins **/
   190 function startTest() {
   192     checkForm(1, "1234");
   193     checkForm(2, "1234", "");
   194     checkForm(3, "1234", "", "");
   195     checkUnmodifiedForm(4);
   197     checkForm(5, "", "1234");
   198     checkForm(6, "someuser", "");
   200     checkForm(7, "testuser", "testpass");
   201     checkForm(8, "someuser", "");
   203     checkForm(9, "", "1234");
   204     checkForm(10, "", "1234");
   205     checkForm(11, "", "1234");
   207     checkUnmodifiedForm(12);
   208     checkUnmodifiedForm(13);
   210     pwmgr.removeLogin(pwlogin2);
   211     SimpleTest.finish();
   212 }
   214 window.onload = startTest;
   215 </script>
   216 </pre>
   217 </body>
   218 </html>

mercurial