Bug 901409 - Update password manager tests to prepare for bug 355063. r=mattn

This commit is contained in:
Justin Dolske 2013-08-09 14:56:50 -07:00
Родитель 066d4fc25d
Коммит b2b9fa240f
16 изменённых файлов: 382 добавлений и 450 удалений

Просмотреть файл

@ -8,6 +8,23 @@
</head>
<body>
Login Manager test: simple form fill
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
/** Test for Login Manager: form fill, multiple forms. **/
function startTest() {
is($_(1, "uname").value, "testuser", "Checking for filled username");
is($_(1, "pword").value, "testpass", "Checking for filled password");
SimpleTest.finish();
}
window.onload = startTest;
</script>
<p id="display"></p>
<div id="content" style="display: none">
@ -23,25 +40,7 @@ Login Manager test: simple form fill
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
commonInit();
/** Test for Login Manager: form fill, multiple forms. **/
// Make sure that all forms in a document are processed.
function startTest() {
is($_(1, "uname").value, "testuser", "Checking for filled username");
is($_(1, "pword").value, "testpass", "Checking for filled password");
SimpleTest.finish();
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<pre id="test"></pre>
</body>
</html>

Просмотреть файл

@ -8,6 +8,16 @@
</head>
<body>
Login Manager test: simple form fill with autofillForms disabled
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
.getService(SpecialPowers.Ci.nsILoginManager);
// Assume that the pref starts out true, so set to false
SpecialPowers.setBoolPref("signon.autofillForms", false);
</script>
<p id="display"></p>
<div id="content" style="display: block">
@ -28,18 +38,6 @@ Login Manager test: simple form fill with autofillForms disabled
/** Test for Login Manager: simple form fill with autofillForms disabled **/
commonInit();
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var pwmgr = Components.classes["@mozilla.org/login-manager;1"].
getService(Components.interfaces.nsILoginManager);
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefService);
prefs = prefs.getBranch("signon.");
// Assume that the pref starts out true, so set to false
prefs.setBoolPref("autofillForms", false);
function startTest(){
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
// Ensure the form is empty at start
@ -55,14 +53,12 @@ function startTest(){
is($_(1, "pword").value, "testpass", "Checking for filled password");
// Reset pref (since we assumed it was true to start)
prefs.setBoolPref("autofillForms", true);
SpecialPowers.setBoolPref("signon.autofillForms", true);
SimpleTest.finish();
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>

Просмотреть файл

@ -9,86 +9,14 @@
</head>
<body>
Login Manager test: multiple login autocomplete
<p id="display"></p>
<!-- we presumably can't hide the content for this test. -->
<div id="content">
<!-- form1 tests multiple matching logins -->
<form id="form1" action="http://autocomplete:8888/formtest.js" onsubmit="return false;">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- other forms test single logins, with autocomplete=off set -->
<form id="form2" action="http://autocomplete2" onsubmit="return false;">
<input type="text" name="uname">
<input type="password" name="pword" autocomplete="off">
<button type="submit">Submit</button>
</form>
<form id="form3" action="http://autocomplete2" onsubmit="return false;">
<input type="text" name="uname" autocomplete="off">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<form id="form4" action="http://autocomplete2" onsubmit="return false;" autocomplete="off">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<form id="form5" action="http://autocomplete2" onsubmit="return false;">
<input type="text" name="uname" autocomplete="off">
<input type="password" name="pword" autocomplete="off">
<button type="submit">Submit</button>
</form>
<!-- control -->
<form id="form6" action="http://autocomplete2" onsubmit="return false;">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- This form will be manipulated to insert a different username field. -->
<form id="form7" action="http://autocomplete3" onsubmit="return false;">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- test for no autofill after onblur with blank username -->
<form id="form8" action="http://autocomplete4" onsubmit="return false;">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- test autocomplete dropdown -->
<form id="form9" action="http://autocomplete5" onsubmit="return false;">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Login Manager: multiple login autocomplete. **/
<script>
commonInit();
var uname = $_(1, "uname");
var pword = $_(1, "pword");
const shiftModifier = Components.interfaces.nsIDOMEvent.SHIFT_MASK;
SimpleTest.waitForExplicitFinish();
// Get the pwmgr service
var pwmgr = SpecialPowers.wrap(Components).classes["@mozilla.org/login-manager;1"]
.getService(Components.interfaces.nsILoginManager);
var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
.getService(SpecialPowers.Ci.nsILoginManager);
ok(pwmgr != null, "nsLoginManager service");
// Create some logins just for this form, since we'll be deleting them.
@ -164,6 +92,82 @@ try {
ok(false, "addLogin threw: " + e);
}
</script>
<p id="display"></p>
<!-- we presumably can't hide the content for this test. -->
<div id="content">
<!-- form1 tests multiple matching logins -->
<form id="form1" action="http://autocomplete:8888/formtest.js" onsubmit="return false;">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- other forms test single logins, with autocomplete=off set -->
<form id="form2" action="http://autocomplete2" onsubmit="return false;">
<input type="text" name="uname">
<input type="password" name="pword" autocomplete="off">
<button type="submit">Submit</button>
</form>
<form id="form3" action="http://autocomplete2" onsubmit="return false;">
<input type="text" name="uname" autocomplete="off">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<form id="form4" action="http://autocomplete2" onsubmit="return false;" autocomplete="off">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<form id="form5" action="http://autocomplete2" onsubmit="return false;">
<input type="text" name="uname" autocomplete="off">
<input type="password" name="pword" autocomplete="off">
<button type="submit">Submit</button>
</form>
<!-- control -->
<form id="form6" action="http://autocomplete2" onsubmit="return false;">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- This form will be manipulated to insert a different username field. -->
<form id="form7" action="http://autocomplete3" onsubmit="return false;">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- test for no autofill after onblur with blank username -->
<form id="form8" action="http://autocomplete4" onsubmit="return false;">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
<!-- test autocomplete dropdown -->
<form id="form9" action="http://autocomplete5" onsubmit="return false;">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
</form>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Login Manager: multiple login autocomplete. **/
var uname = $_(1, "uname");
var pword = $_(1, "pword");
const shiftModifier = Components.interfaces.nsIDOMEvent.SHIFT_MASK;
// Restore the form to the default state.
function restoreForm() {
@ -812,8 +816,6 @@ function startTest() {
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>

Просмотреть файл

@ -8,6 +8,39 @@
</head>
<body>
Login Manager test: html5 input types (email, tel, url, etc.)
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
const Ci = SpecialPowers.Ci;
const Cc = SpecialPowers.Cc;
pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
login1 = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login2 = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login3 = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login4 = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login1.init("http://mochi.test:8888", "http://bug600551-1", null,
"testuser@example.com", "testpass1", "", "");
login2.init("http://mochi.test:8888", "http://bug600551-2", null,
"555-555-5555", "testpass2", "", "");
login3.init("http://mochi.test:8888", "http://bug600551-3", null,
"http://mozilla.org", "testpass3", "", "");
login4.init("http://mochi.test:8888", "http://bug600551-4", null,
"123456789", "testpass4", "", "");
pwmgr.addLogin(login1);
pwmgr.addLogin(login2);
pwmgr.addLogin(login3);
pwmgr.addLogin(login4);
</script>
<p id="display"></p>
<div id="content" style="display: none">
@ -99,38 +132,6 @@ Login Manager test: html5 input types (email, tel, url, etc.)
/* Test for Login Manager: 600551
(Password manager not working with input type=email)
*/
commonInit();
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const Ci = Components.interfaces;
const Cc = Components.classes;
pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
login1 = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login2 = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login3 = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login4 = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login1.init("http://mochi.test:8888", "http://bug600551-1", null,
"testuser@example.com", "testpass1", "", "");
login2.init("http://mochi.test:8888", "http://bug600551-2", null,
"555-555-5555", "testpass2", "", "");
login3.init("http://mochi.test:8888", "http://bug600551-3", null,
"http://mozilla.org", "testpass3", "", "");
login4.init("http://mochi.test:8888", "http://bug600551-4", null,
"123456789", "testpass4", "", "");
pwmgr.addLogin(login1);
pwmgr.addLogin(login2);
pwmgr.addLogin(login3);
pwmgr.addLogin(login4);
function startTest() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
@ -166,9 +167,6 @@ function startTest() {
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>

Просмотреть файл

@ -8,6 +8,17 @@
</head>
<body>
Login Manager test: simple form with autocomplete off and notifying observers & normal form
<script>
const Cc = SpecialPowers.Cc;
const Ci = SpecialPowers.Ci;
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
commonInit();
SimpleTest.waitForExplicitFinish();
</script>
<p id="display"></p>
<div id="content" style="display: block">
@ -20,7 +31,7 @@ Login Manager test: simple form with autocomplete off and notifying observers &
<button type="submit">Submit</button>
<button type="reset"> Reset </button>
</form>
<form id="form2" action="formtest.js">
<p>This is form 2.</p>
<input type="text" name="uname">
@ -36,15 +47,6 @@ Login Manager test: simple form with autocomplete off and notifying observers &
<script class="testbody" type="text/javascript">
/** Test for Login Manager: simple form with autocomplete off and notifying observers & normal form **/
commonInit();
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
var TestObserver = {
receivedNotification1 : false,
receivedNotification2 : false,
@ -99,8 +101,6 @@ function startTest(){
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>

Просмотреть файл

@ -8,6 +8,21 @@
</head>
<body>
Login Manager test: simple form with autofillForms disabled and notifying observers
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
const Cc = SpecialPowers.Cc;
const Ci = SpecialPowers.Ci;
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
// Assume that the pref starts out true, so set to false
SpecialPowers.setBoolPref("signon.autofillForms", false);
</script>
<p id="display"></p>
<div id="content" style="display: block">
@ -28,20 +43,6 @@ Login Manager test: simple form with autofillForms disabled and notifying observ
/** Test for Login Manager: simple form with autofillForms disabled and notifying observers **/
commonInit();
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService);
prefs = prefs.getBranch("signon.");
// Assume that the pref starts out true, so set to false
prefs.setBoolPref("autofillForms", false);
var TestObserver = {
receivedNotificationFoundForm : false,
receivedNotificationFoundLogins : false,
@ -92,7 +93,7 @@ function startTest(){
"Checking selectedLogin is found login");
// Reset pref (since we assumed it was true to start)
prefs.setBoolPref("autofillForms", true);
SpecialPowers.setBoolPref("signon.autofillForms", true);
// Remove the observer
os.removeObserver(TestObserver, "passwordmgr-found-form");
@ -102,8 +103,6 @@ function startTest(){
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>

Просмотреть файл

@ -8,66 +8,13 @@
</head>
<body>
Login Manager test: notifying observers of passwordmgr-found-logins
<p id="display"></p>
<div id="content" style="display: block">
<form id="form1" action="formtest.js">
<p>This is form 1.</p>
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
<button type="reset"> Reset </button>
</form>
<form id="form2" action="formtest.js">
<p>This is form 2.</p>
<input type="text" name="uname" value="existing">
<input type="password" name="pword">
<button type="submit">Submit</button>
<button type="reset"> Reset </button>
</form>
<form id="form3" action="formtest.js">
<p>This is form 3.</p>
<input type="text" name="uname">
<input type="password" name="pword" value="existing">
<button type="submit">Submit</button>
<button type="reset"> Reset </button>
</form>
<form id="form4" action="formtest.js" autocomplete="off">
<p>This is form 4.</p>
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
<button type="reset"> Reset </button>
</form>
<form id="form5" action="http://www.example.com">
<p>This is form 5.</p>
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
<button type="reset"> Reset </button>
</form>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Login Manager: notifying observers of passwordmgr-found-logins **/
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
const Cc = SpecialPowers.Cc;
const Ci = SpecialPowers.Ci;
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@ -110,6 +57,63 @@ for (var formID of ["form1", "form2", "form3", "form4", "form5"])
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.addObserver(TestObserver, "passwordmgr-found-logins", false);
</script>
<p id="display"></p>
<div id="content" style="display: block">
<form id="form1" action="formtest.js">
<p>This is form 1.</p>
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
<button type="reset"> Reset </button>
</form>
<form id="form2" action="formtest.js">
<p>This is form 2.</p>
<input type="text" name="uname" value="existing">
<input type="password" name="pword">
<button type="submit">Submit</button>
<button type="reset"> Reset </button>
</form>
<form id="form3" action="formtest.js">
<p>This is form 3.</p>
<input type="text" name="uname">
<input type="password" name="pword" value="existing">
<button type="submit">Submit</button>
<button type="reset"> Reset </button>
</form>
<form id="form4" action="formtest.js" autocomplete="off">
<p>This is form 4.</p>
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
<button type="reset"> Reset </button>
</form>
<form id="form5" action="http://www.example.com">
<p>This is form 5.</p>
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
<button type="reset"> Reset </button>
</form>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Login Manager: notifying observers of passwordmgr-found-logins **/
function startTest(){
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
@ -181,8 +185,6 @@ function startTest(){
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>

Просмотреть файл

@ -8,6 +8,39 @@
</head>
<body>
Login Manager test: forms and logins without a username.
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
.getService(SpecialPowers.Ci.nsILoginManager);
var nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1", Components.interfaces.nsILoginInfo);
ok(nsLoginInfo != null, "nsLoginInfo constructor");
// pwlogin1 uses a unique formSubmitURL, to check forms where no other logins
// will apply. pwlogin2 uses the normal formSubmitURL, so that we can test
// forms with a mix of username and non-username logins that might apply.
//
// Note: pwlogin2 is deleted at the end of the test.
pwlogin1 = new nsLoginInfo();
pwlogin2 = new nsLoginInfo();
pwlogin1.init("http://mochi.test:8888", "http://mochi.test:1111", null,
"", "1234", "uname", "pword");
pwlogin2.init("http://mochi.test:8888", "http://mochi.test:8888", null,
"", "1234", "uname", "pword");
try {
pwmgr.addLogin(pwlogin1);
pwmgr.addLogin(pwlogin2);
} catch (e) {
ok(false, "addLogin threw: " + e);
}
</script>
<p id="display"></p>
<div id="content" style="display: none">
@ -154,8 +187,6 @@ password-only, the other is username+password)
<script class="testbody" type="text/javascript">
/** Test for Login Manager: password-only logins **/
commonInit();
function startTest() {
checkForm(1, "1234");
@ -181,48 +212,7 @@ function startTest() {
SimpleTest.finish();
}
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
// Get the pwmgr service
var Cc_pwmgr = Components.classes["@mozilla.org/login-manager;1"];
ok(Cc_pwmgr != null, "Access Cc[@mozilla.org/login-manager;1]");
var Ci_pwmgr = Components.interfaces.nsILoginManager;
ok(Ci_pwmgr != null, "Access Ci.nsILoginManager");
var pwmgr = Cc_pwmgr.getService(Ci_pwmgr);
ok(pwmgr != null, "pwmgr getService()");
var nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1", Components.interfaces.nsILoginInfo);
ok(nsLoginInfo != null, "nsLoginInfo constructor");
// pwlogin1 uses a unique formSubmitURL, to check forms where no other logins
// will apply. pwlogin2 uses the normal formSubmitURL, so that we can test
// forms with a mix of username and non-username logins that might apply.
//
// Note: pwlogin2 is deleted at the end of the test.
pwlogin1 = new nsLoginInfo();
pwlogin2 = new nsLoginInfo();
pwlogin1.init("http://mochi.test:8888", "http://mochi.test:1111", null,
"", "1234", "uname", "pword");
pwlogin2.init("http://mochi.test:8888", "http://mochi.test:8888", null,
"", "1234", "uname", "pword");
try {
pwmgr.addLogin(pwlogin1);
pwmgr.addLogin(pwlogin2);
} catch (e) {
ok(false, "addLogin threw: " + e);
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>

Просмотреть файл

@ -8,9 +8,17 @@
</head>
<body>
Login Manager test: 227640
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
.getService(SpecialPowers.Ci.nsILoginManager);
</script>
<p id="display"></p>
<div id="content" style="display: none">
<!-- no autocomplete for password field -->
<form id="form1" onsubmit="return checkSubmit(1)" method="get">
<input type="text" name="uname" value="">
@ -147,7 +155,6 @@ Login Manager test: 227640
/** Test for Login Manager: 227640 (password is saved even when the
password field has autocomplete="off") **/
commonInit();
// This test ensures that pwmgr does not save a username or password when
// autocomplete=off is present.
@ -230,24 +237,7 @@ function countLogins() {
return logins.length;
}
// Get the pwmgr service
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var Cc_pwmgr = Components.classes["@mozilla.org/login-manager;1"];
ok(Cc_pwmgr != null, "Access Cc[@mozilla.org/login-manager;1]");
var Ci_pwmgr = Components.interfaces.nsILoginManager;
ok(Ci_pwmgr != null, "Access Ci.nsILoginManager");
var pwmgr = Cc_pwmgr.getService(Ci_pwmgr);
ok(pwmgr != null, "pwmgr getService()");
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>

Просмотреть файл

@ -8,6 +8,28 @@
</head>
<body>
Login Manager test: form with JS submit action
<script>
SimpleTest.waitForExplicitFinish();
var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
.getService(SpecialPowers.Ci.nsILoginManager);
var jslogin = SpecialPowers.Cc["@mozilla.org/login-manager/loginInfo;1"]
.createInstance(SpecialPowers.Ci.nsILoginInfo);
jslogin.init("http://mochi.test:8888", "javascript:", null,
"jsuser", "jspass123", "uname", "pword");
pwmgr.addLogin(jslogin);
/** Test for Login Manager: JS action URL **/
function startTest() {
checkForm(1, "jsuser", "jspass123");
pwmgr.removeLogin(jslogin);
SimpleTest.finish();
}
window.onload = startTest;
</script>
<p id="display"></p>
<div id="content" style="display: none">
@ -23,51 +45,7 @@ Login Manager test: form with JS submit action
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Login Manager: JS action URL **/
function startTest() {
checkForm(1, "jsuser", "jspass123");
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
pwmgr.removeLogin(jslogin);
SimpleTest.finish();
}
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
// Get the pwmgr service
var Cc_pwmgr = Components.classes["@mozilla.org/login-manager;1"];
ok(Cc_pwmgr != null, "Access Cc[@mozilla.org/login-manager;1]");
var Ci_pwmgr = Components.interfaces.nsILoginManager;
ok(Ci_pwmgr != null, "Access Ci.nsILoginManager");
var pwmgr = Cc_pwmgr.getService(Ci_pwmgr);
ok(pwmgr != null, "pwmgr getService()");
var jslogin = Components.classes["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Components.interfaces.nsILoginInfo);
ok(jslogin != null, "create a login");
jslogin.init("http://mochi.test:8888", "javascript:", null,
"jsuser", "jspass123", "uname", "pword");
try {
pwmgr.addLogin(jslogin);
} catch (e) {
ok(false, "addLogin threw: " + e);
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<pre id="test"></pre>
</body>
</html>

Просмотреть файл

@ -8,6 +8,45 @@
</head>
<body>
Login Manager test: 444968
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
const Ci = SpecialPowers.Ci;
const Cc = SpecialPowers.Cc;
pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
login1A = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login1B = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login2A = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login2B = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login2C = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login1A.init("http://mochi.test:8888", "http://bug444968-1", null,
"testuser1A", "testpass1A", "", "");
login1B.init("http://mochi.test:8888", "http://bug444968-1", null,
"", "testpass1B", "", "");
login2A.init("http://mochi.test:8888", "http://bug444968-2", null,
"testuser2A", "testpass2A", "", "");
login2B.init("http://mochi.test:8888", "http://bug444968-2", null,
"", "testpass2B", "", "");
login2C.init("http://mochi.test:8888", "http://bug444968-2", null,
"testuser2C", "testpass2C", "", "");
pwmgr.addLogin(login1A);
pwmgr.addLogin(login1B);
pwmgr.addLogin(login2A);
pwmgr.addLogin(login2B);
pwmgr.addLogin(login2C);
</script>
<p id="display"></p>
<div id="content" style="display: none">
<!-- first 3 forms have matching user+pass and pass-only logins -->
@ -69,47 +108,7 @@ Login Manager test: 444968
/* Test for Login Manager: 444968 (password-only forms should prefer a
* password-only login when present )
*/
commonInit();
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const Ci = Components.interfaces;
const Cc = Components.classes;
pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
login1A = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login1B = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login2A = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login2B = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login2C = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login1A.init("http://mochi.test:8888", "http://bug444968-1", null,
"testuser1A", "testpass1A", "", "");
login1B.init("http://mochi.test:8888", "http://bug444968-1", null,
"", "testpass1B", "", "");
login2A.init("http://mochi.test:8888", "http://bug444968-2", null,
"testuser2A", "testpass2A", "", "");
login2B.init("http://mochi.test:8888", "http://bug444968-2", null,
"", "testpass2B", "", "");
login2C.init("http://mochi.test:8888", "http://bug444968-2", null,
"testuser2C", "testpass2C", "", "");
pwmgr.addLogin(login1A);
pwmgr.addLogin(login1B);
pwmgr.addLogin(login2A);
pwmgr.addLogin(login2B);
pwmgr.addLogin(login2C);
function startTest() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
checkForm(1, "testuser1A", "testpass1A");
checkForm(2, "testpass1B");
checkForm(3, "testuser1A", "testpass1A");
@ -124,14 +123,11 @@ function startTest() {
pwmgr.removeLogin(login2A);
pwmgr.removeLogin(login2B);
pwmgr.removeLogin(login2C);
SimpleTest.finish();
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>

Просмотреть файл

@ -9,6 +9,32 @@
</head>
<body>
Login Manager test: master password.
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
.getService(SpecialPowers.Ci.nsILoginManager);
var pwcrypt = SpecialPowers.Cc["@mozilla.org/login-manager/crypto/SDR;1"]
.getService(Ci.nsILoginManagerCrypto);
var nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo);
var exampleCom = "http://example.com/tests/toolkit/components/passwordmgr/test/";
var exampleOrg = "http://example.org/tests/toolkit/components/passwordmgr/test/";
var login1 = new nsLoginInfo();
var login2 = new nsLoginInfo();
login1.init("http://example.com", "http://example.com", null,
"user1", "pass1", "uname", "pword");
login2.init("http://example.org", "http://example.org", null,
"user2", "pass2", "uname", "pword");
pwmgr.addLogin(login1);
pwmgr.addLogin(login2);
</script>
<p id="display"></p>
<div id="content" style="display: none">
@ -18,9 +44,9 @@ Login Manager test: master password.
<pre id="test">
<script class="testbody" type="text/javascript">
commonInit();
var testNum = 1;
var iframe1 = document.getElementById("iframe1");
var iframe2 = document.getElementById("iframe2");
/*
* handleDialog
@ -79,8 +105,12 @@ function handleDialog(doc, testNum) {
ok(true, "handleDialog done");
didDialog = true;
if (testNum == 4)
if (testNum == 3)
SimpleTest.executeSoon(checkTest3);
else if (testNum == 4)
checkTest4A();
else if (testNum == 5)
SimpleTest.executeSoon(checkTest4C);
}
@ -119,12 +149,6 @@ function startTest1() {
// --- Test 3 ---
// Load a single iframe to trigger a MP
testNum++;
// Note that because DOMContentLoaded is dispatched synchronously, the
// document's load event is blocked until after the MP entry (because
// pwmgr's listener doesn't return until after it processes the form,
// which is blocked waiting on a MP entry).
iframe1.onload = checkTest3;
iframe1.src = exampleCom + "subtst_master_pass.html";
startCallbackTimer();
}
@ -147,7 +171,6 @@ function checkTest3() {
// --- Test 4 ---
// first part of loading 2 MP-triggering iframes
testNum++;
iframe1.onload = checkTest4C;
iframe1.src = exampleOrg + "subtst_master_pass.html";
// start the callback, but we'll not enter the MP, just call checkTest4A
startCallbackTimer();
@ -170,7 +193,9 @@ function checkTest4A() {
// Load another iframe with a login form
// This should detect that there's already a pending MP prompt, and not
// put up a second one. The load event will fire.
// put up a second one. The load event will fire (note that when pwmgr is
// driven from DOMContentLoaded, if that blocks due to prompting for a MP,
// the load even will also be blocked until the prompt is dismissed).
iframe2.onload = checkTest4B;
iframe2.src = exampleCom + "subtst_master_pass.html";
}
@ -196,7 +221,6 @@ function checkTest4B() {
}
function checkTest4C() {
// iframe1 finally loads after the MP entry.
ok(true, "checkTest4C starting");
ok(didDialog, "handleDialog was invoked");
@ -232,41 +256,7 @@ function finishTest() {
SimpleTest.finish();
}
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
// Get the pwmgr service
var pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
ok(pwmgr != null, "pwmgr getService()");
var pwcrypt = Cc["@mozilla.org/login-manager/crypto/SDR;1"].
getService(Ci.nsILoginManagerCrypto);
ok(pwcrypt != null, "pwcrypt getService()");
var nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo);
ok(nsLoginInfo != null, "nsLoginInfo constructor");
var exampleCom = "http://example.com/tests/toolkit/components/passwordmgr/test/";
var exampleOrg = "http://example.org/tests/toolkit/components/passwordmgr/test/";
var login1 = new nsLoginInfo();
var login2 = new nsLoginInfo();
login1.init("http://example.com", "http://example.com", null,
"user1", "pass1", "uname", "pword");
login2.init("http://example.org", "http://example.org", null,
"user2", "pass2", "uname", "pword");
pwmgr.addLogin(login1);
pwmgr.addLogin(login2);
var iframe1 = document.getElementById("iframe1");
var iframe2 = document.getElementById("iframe2");
window.onload = startTest1;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>

Просмотреть файл

@ -11,8 +11,6 @@ Login Manager test: master password cleanup
<p id="display"></p>
<div id="content" style="display: none">
<iframe id="iframe1"></iframe>
<iframe id="iframe2"></iframe>
</div>
<pre id="test">

Просмотреть файл

@ -12,8 +12,10 @@ Test limiting number of forms filled.
<p id="display"></p>
<div id="content" style="display: none"></div>
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
var FORMS_TO_CREATE = 39;
function createForm(id) {
@ -34,7 +36,6 @@ theDiv.innerHTML = formsHtml;
<pre id="test">
<script class="testbody" type="text/javascript">
commonInit();
/** Test for Login Manager: form fill, multiple forms. **/
function startTest() {
@ -52,10 +53,7 @@ function startTest() {
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -12,8 +12,10 @@ Test limiting number of forms filled.
<p id="display"></p>
<div id="content" style="display: none"></div>
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
var FORMS_TO_CREATE = 40;
function createForm(id) {
@ -34,7 +36,6 @@ theDiv.innerHTML = formsHtml;
<pre id="test">
<script class="testbody" type="text/javascript">
commonInit();
/** Test for Login Manager: form fill, multiple forms. **/
function startTest() {
@ -52,10 +53,7 @@ function startTest() {
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -12,8 +12,10 @@ Test limiting number of forms filled.
<p id="display"></p>
<div id="content" style="display: none"></div>
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
var FORMS_TO_CREATE = 41;
function createForm(id) {
@ -34,7 +36,6 @@ theDiv.innerHTML = formsHtml;
<pre id="test">
<script class="testbody" type="text/javascript">
commonInit();
/** Test for Login Manager: form fill, multiple forms. **/
function startTest() {
@ -52,10 +53,7 @@ function startTest() {
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>