toolkit/components/passwordmgr/test/test_basic_form_2.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: simple form fill with autofillForms disabled
    11 <script>
    12 commonInit();
    13 SimpleTest.waitForExplicitFinish();
    15 var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
    16                          .getService(SpecialPowers.Ci.nsILoginManager);
    17 // Assume that the pref starts out true, so set to false
    18 SpecialPowers.setBoolPref("signon.autofillForms", false);
    19 </script>
    21 <p id="display"></p>
    23 <div id="content" style="display: block">
    25   <form id="form1" action="formtest.js">
    26     <p>This is form 1.</p>
    27     <input  type="text"       name="uname">
    28     <input  type="password"   name="pword">
    30     <button type="submit">Submit</button>
    31     <button type="reset"> Reset </button>
    32   </form>
    34 </div>
    36 <pre id="test">
    37 <script class="testbody" type="text/javascript">
    39 /** Test for Login Manager: simple form fill with autofillForms disabled **/
    41 function startTest(){
    42   // Ensure the form is empty at start
    43   is($_(1, "uname").value, "", "Checking for blank username");
    44   is($_(1, "pword").value, "", "Checking for blank password");
    46   // Call the public method, check return value
    47   is(pwmgr.fillForm(document.getElementById("form1")), true,
    48      "Checking return value of fillForm");
    50   // Check that the form was filled
    51   is($_(1, "uname").value, "testuser", "Checking for filled username");
    52   is($_(1, "pword").value, "testpass", "Checking for filled password");
    54   // Reset pref (since we assumed it was true to start)
    55   SpecialPowers.setBoolPref("signon.autofillForms", true);
    57   SimpleTest.finish();
    58 }
    59 window.onload = startTest;
    61 </script>
    62 </pre>
    63 </body>
    64 </html>

mercurial