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