tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_passwords.js (2689B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 EnableEngines(["passwords"]);
      5 
      6 /*
      7 * The list of phases mapped to their corresponding profiles.  The object
      8 * here must be in JSON format as it will get parsed by the Python
      9 * testrunner. It is parsed by the YAML package, so it relatively flexible.
     10 */
     11 var phases = {
     12  phase1: "profile1",
     13  phase2: "profile2",
     14  phase3: "profile1",
     15  phase4: "profile2",
     16 };
     17 
     18 /*
     19 * Password asset lists: these define password entries that are used during
     20 * the test
     21 */
     22 
     23 // initial password list to be loaded into the browser
     24 var passwords_initial = [
     25  {
     26    hostname: "http://www.example.com",
     27    submitURL: "http://login.example.com",
     28    username: "joe",
     29    password: "SeCrEt123",
     30    usernameField: "uname",
     31    passwordField: "pword",
     32    changes: {
     33      password: "zippity-do-dah",
     34    },
     35  },
     36  {
     37    hostname: "http://www.example.com",
     38    realm: "login",
     39    username: "joe",
     40    password: "secretlogin",
     41  },
     42 ];
     43 
     44 // expected state of passwords after the changes in the above list are applied
     45 var passwords_after_first_update = [
     46  {
     47    hostname: "http://www.example.com",
     48    submitURL: "http://login.example.com",
     49    username: "joe",
     50    password: "zippity-do-dah",
     51    usernameField: "uname",
     52    passwordField: "pword",
     53  },
     54  {
     55    hostname: "http://www.example.com",
     56    realm: "login",
     57    username: "joe",
     58    password: "secretlogin",
     59  },
     60 ];
     61 
     62 var passwords_to_delete = [
     63  {
     64    hostname: "http://www.example.com",
     65    realm: "login",
     66    username: "joe",
     67    password: "secretlogin",
     68  },
     69 ];
     70 
     71 var passwords_absent = [
     72  {
     73    hostname: "http://www.example.com",
     74    realm: "login",
     75    username: "joe",
     76    password: "secretlogin",
     77  },
     78 ];
     79 
     80 // expected state of passwords after the delete operation
     81 var passwords_after_second_update = [
     82  {
     83    hostname: "http://www.example.com",
     84    submitURL: "http://login.example.com",
     85    username: "joe",
     86    password: "zippity-do-dah",
     87    usernameField: "uname",
     88    passwordField: "pword",
     89  },
     90 ];
     91 
     92 /*
     93 * Test phases
     94 */
     95 
     96 Phase("phase1", [[Passwords.add, passwords_initial], [Sync]]);
     97 
     98 Phase("phase2", [
     99  [Sync],
    100  [Passwords.verify, passwords_initial],
    101  [Passwords.modify, passwords_initial],
    102  [Passwords.verify, passwords_after_first_update],
    103  [Sync],
    104 ]);
    105 
    106 Phase("phase3", [
    107  [Sync],
    108  [Passwords.verify, passwords_after_first_update],
    109  [Passwords.delete, passwords_to_delete],
    110  [Passwords.verify, passwords_after_second_update],
    111  [Passwords.verifyNot, passwords_absent],
    112  [Sync],
    113 ]);
    114 
    115 Phase("phase4", [
    116  [Sync],
    117  [Passwords.verify, passwords_after_second_update],
    118  [Passwords.verifyNot, passwords_absent],
    119 ]);