mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1251151 - Make test_autofill_password-only.html work for e10s. r=dolske
MozReview-Commit-ID: Atwqt9mp6Da --HG-- rename : toolkit/components/passwordmgr/test/test_autofill_password-only.html => toolkit/components/passwordmgr/test/mochitest/test_autofill_password-only.html extra : amend_source : aaf81c75cc91b4855f5a5ea10e2a276e56cfd06e
This commit is contained in:
parent
dd41ede7e4
commit
e01f4c4edd
@ -34,7 +34,6 @@ support-files =
|
||||
# This test doesn't pass because we can't ensure a cross-platform event that
|
||||
# occurs between DOMContentLoaded and Pageload
|
||||
skip-if = true
|
||||
[test_autofill_password-only.html]
|
||||
[test_basic_form.html]
|
||||
[test_basic_form_0pw.html]
|
||||
[test_basic_form_1pw.html]
|
||||
|
@ -3,4 +3,5 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g'
|
||||
support-files =
|
||||
../pwmgr_common.js
|
||||
|
||||
[test_autofill_password-only.html]
|
||||
[test_recipe_login_fields.html]
|
||||
|
@ -10,42 +10,56 @@
|
||||
<body>
|
||||
Login Manager test: Bug 444968
|
||||
<script>
|
||||
commonInit();
|
||||
let pwmgrCommonScript = loadParentTestFile("pwmgr_common.js");
|
||||
pwmgrCommonScript.sendSyncMessage("setupParent");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const Ci = SpecialPowers.Ci;
|
||||
const Cc = SpecialPowers.Cc;
|
||||
pwmgr = Cc["@mozilla.org/login-manager;1"].
|
||||
getService(Ci.nsILoginManager);
|
||||
let chromeScript = runFunctionInParent(function chromeSetup() {
|
||||
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||
let 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);
|
||||
let login1A = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||
createInstance(Ci.nsILoginInfo);
|
||||
let login1B = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||
createInstance(Ci.nsILoginInfo);
|
||||
let login2A = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||
createInstance(Ci.nsILoginInfo);
|
||||
let login2B = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||
createInstance(Ci.nsILoginInfo);
|
||||
let 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", "", "");
|
||||
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", "", "");
|
||||
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);
|
||||
pwmgr.addLogin(login1A);
|
||||
pwmgr.addLogin(login1B);
|
||||
pwmgr.addLogin(login2A);
|
||||
pwmgr.addLogin(login2B);
|
||||
pwmgr.addLogin(login2C);
|
||||
|
||||
addMessageListener("removeLogins", function removeLogins() {
|
||||
pwmgr.removeLogin(login1A);
|
||||
pwmgr.removeLogin(login1B);
|
||||
pwmgr.removeLogin(login2A);
|
||||
pwmgr.removeLogin(login2B);
|
||||
pwmgr.removeLogin(login2C);
|
||||
});
|
||||
});
|
||||
|
||||
SimpleTest.registerCleanupFunction(() => chromeScript.sendSyncMessage("removeLogins"));
|
||||
|
||||
registerRunTests();
|
||||
</script>
|
||||
|
||||
<p id="display"></p>
|
||||
@ -119,12 +133,6 @@ function startTest() {
|
||||
checkForm(6, "testuser2A", "testpass2A");
|
||||
checkForm(7, "testuser2C", "testpass2C");
|
||||
|
||||
pwmgr.removeLogin(login1A);
|
||||
pwmgr.removeLogin(login1B);
|
||||
pwmgr.removeLogin(login2A);
|
||||
pwmgr.removeLogin(login2B);
|
||||
pwmgr.removeLogin(login2C);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -160,6 +160,10 @@ function commonInit(selfFilling) {
|
||||
if (selfFilling)
|
||||
return;
|
||||
|
||||
registerRunTests();
|
||||
}
|
||||
|
||||
function registerRunTests() {
|
||||
// We provide a general mechanism for our tests to know when they can
|
||||
// safely run: we add a final form that we know will be filled in, wait
|
||||
// for the login manager to tell us that it's filled in and then continue
|
||||
@ -253,6 +257,9 @@ function dumpLogin(label, login) {
|
||||
|
||||
function getRecipeParent() {
|
||||
var { LoginManagerParent } = SpecialPowers.Cu.import("resource://gre/modules/LoginManagerParent.jsm", {});
|
||||
if (!LoginManagerParent.recipeParentPromise) {
|
||||
return null;
|
||||
}
|
||||
return LoginManagerParent.recipeParentPromise.then((recipeParent) => {
|
||||
return SpecialPowers.wrap(recipeParent);
|
||||
});
|
||||
@ -275,6 +282,29 @@ function promiseFormsProcessed(expectedCount = 1) {
|
||||
});
|
||||
}
|
||||
|
||||
function loadParentTestFile(aRelativeFilePath) {
|
||||
let fileURL = SimpleTest.getTestFileURL(aRelativeFilePath);
|
||||
let testScript = SpecialPowers.loadChromeScript(fileURL);
|
||||
SimpleTest.registerCleanupFunction(function destroyChromeScript() {
|
||||
testScript.destroy();
|
||||
});
|
||||
return testScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a function synchronously in the parent process and destroy it in the test cleanup function.
|
||||
* @param {Function} aFunction - function that will be stringified and run.
|
||||
* @return {Object} - the return value of loadChromeScript providing message-related methods.
|
||||
* @see loadChromeScript in specialpowersAPI.js
|
||||
*/
|
||||
function runFunctionInParent(aFunction) {
|
||||
let chromeScript = SpecialPowers.loadChromeScript(aFunction);
|
||||
SimpleTest.registerCleanupFunction(() => {
|
||||
chromeScript.destroy();
|
||||
});
|
||||
return chromeScript;
|
||||
}
|
||||
|
||||
// Code to run when loaded as a chrome script in tests via loadChromeScript
|
||||
if (this.addMessageListener) {
|
||||
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||
@ -304,6 +334,11 @@ if (this.addMessageListener) {
|
||||
} else {
|
||||
// Code to only run in the mochitest pages (not in the chrome script).
|
||||
SimpleTest.registerCleanupFunction(() => {
|
||||
getRecipeParent().then(recipeParent => recipeParent.reset());
|
||||
let recipeParent = getRecipeParent();
|
||||
if (!recipeParent) {
|
||||
// No need to reset the recipes if the module wasn't even loaded.
|
||||
return;
|
||||
}
|
||||
recipeParent.then(recipeParent => recipeParent.reset());
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user