зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
dd41ede7e4
Коммит
e01f4c4edd
|
@ -34,7 +34,6 @@ support-files =
|
||||||
# This test doesn't pass because we can't ensure a cross-platform event that
|
# This test doesn't pass because we can't ensure a cross-platform event that
|
||||||
# occurs between DOMContentLoaded and Pageload
|
# occurs between DOMContentLoaded and Pageload
|
||||||
skip-if = true
|
skip-if = true
|
||||||
[test_autofill_password-only.html]
|
|
||||||
[test_basic_form.html]
|
[test_basic_form.html]
|
||||||
[test_basic_form_0pw.html]
|
[test_basic_form_0pw.html]
|
||||||
[test_basic_form_1pw.html]
|
[test_basic_form_1pw.html]
|
||||||
|
|
|
@ -3,4 +3,5 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g'
|
||||||
support-files =
|
support-files =
|
||||||
../pwmgr_common.js
|
../pwmgr_common.js
|
||||||
|
|
||||||
|
[test_autofill_password-only.html]
|
||||||
[test_recipe_login_fields.html]
|
[test_recipe_login_fields.html]
|
||||||
|
|
|
@ -10,42 +10,56 @@
|
||||||
<body>
|
<body>
|
||||||
Login Manager test: Bug 444968
|
Login Manager test: Bug 444968
|
||||||
<script>
|
<script>
|
||||||
commonInit();
|
let pwmgrCommonScript = loadParentTestFile("pwmgr_common.js");
|
||||||
|
pwmgrCommonScript.sendSyncMessage("setupParent");
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
const Ci = SpecialPowers.Ci;
|
let chromeScript = runFunctionInParent(function chromeSetup() {
|
||||||
const Cc = SpecialPowers.Cc;
|
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||||
pwmgr = Cc["@mozilla.org/login-manager;1"].
|
let pwmgr = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
|
||||||
getService(Ci.nsILoginManager);
|
|
||||||
|
|
||||||
login1A = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
let login1A = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||||
createInstance(Ci.nsILoginInfo);
|
createInstance(Ci.nsILoginInfo);
|
||||||
login1B = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
let login1B = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||||
createInstance(Ci.nsILoginInfo);
|
createInstance(Ci.nsILoginInfo);
|
||||||
login2A = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
let login2A = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||||
createInstance(Ci.nsILoginInfo);
|
createInstance(Ci.nsILoginInfo);
|
||||||
login2B = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
let login2B = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||||
createInstance(Ci.nsILoginInfo);
|
createInstance(Ci.nsILoginInfo);
|
||||||
login2C = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
let login2C = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||||
createInstance(Ci.nsILoginInfo);
|
createInstance(Ci.nsILoginInfo);
|
||||||
|
|
||||||
login1A.init("http://mochi.test:8888", "http://bug444968-1", null,
|
login1A.init("http://mochi.test:8888", "http://bug444968-1", null,
|
||||||
"testuser1A", "testpass1A", "", "");
|
"testuser1A", "testpass1A", "", "");
|
||||||
login1B.init("http://mochi.test:8888", "http://bug444968-1", null,
|
login1B.init("http://mochi.test:8888", "http://bug444968-1", null,
|
||||||
"", "testpass1B", "", "");
|
"", "testpass1B", "", "");
|
||||||
|
|
||||||
login2A.init("http://mochi.test:8888", "http://bug444968-2", null,
|
login2A.init("http://mochi.test:8888", "http://bug444968-2", null,
|
||||||
"testuser2A", "testpass2A", "", "");
|
"testuser2A", "testpass2A", "", "");
|
||||||
login2B.init("http://mochi.test:8888", "http://bug444968-2", null,
|
login2B.init("http://mochi.test:8888", "http://bug444968-2", null,
|
||||||
"", "testpass2B", "", "");
|
"", "testpass2B", "", "");
|
||||||
login2C.init("http://mochi.test:8888", "http://bug444968-2", null,
|
login2C.init("http://mochi.test:8888", "http://bug444968-2", null,
|
||||||
"testuser2C", "testpass2C", "", "");
|
"testuser2C", "testpass2C", "", "");
|
||||||
|
|
||||||
pwmgr.addLogin(login1A);
|
pwmgr.addLogin(login1A);
|
||||||
pwmgr.addLogin(login1B);
|
pwmgr.addLogin(login1B);
|
||||||
pwmgr.addLogin(login2A);
|
pwmgr.addLogin(login2A);
|
||||||
pwmgr.addLogin(login2B);
|
pwmgr.addLogin(login2B);
|
||||||
pwmgr.addLogin(login2C);
|
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>
|
</script>
|
||||||
|
|
||||||
<p id="display"></p>
|
<p id="display"></p>
|
||||||
|
@ -119,12 +133,6 @@ function startTest() {
|
||||||
checkForm(6, "testuser2A", "testpass2A");
|
checkForm(6, "testuser2A", "testpass2A");
|
||||||
checkForm(7, "testuser2C", "testpass2C");
|
checkForm(7, "testuser2C", "testpass2C");
|
||||||
|
|
||||||
pwmgr.removeLogin(login1A);
|
|
||||||
pwmgr.removeLogin(login1B);
|
|
||||||
pwmgr.removeLogin(login2A);
|
|
||||||
pwmgr.removeLogin(login2B);
|
|
||||||
pwmgr.removeLogin(login2C);
|
|
||||||
|
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,10 @@ function commonInit(selfFilling) {
|
||||||
if (selfFilling)
|
if (selfFilling)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
registerRunTests();
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerRunTests() {
|
||||||
// We provide a general mechanism for our tests to know when they can
|
// 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
|
// 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
|
// 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() {
|
function getRecipeParent() {
|
||||||
var { LoginManagerParent } = SpecialPowers.Cu.import("resource://gre/modules/LoginManagerParent.jsm", {});
|
var { LoginManagerParent } = SpecialPowers.Cu.import("resource://gre/modules/LoginManagerParent.jsm", {});
|
||||||
|
if (!LoginManagerParent.recipeParentPromise) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return LoginManagerParent.recipeParentPromise.then((recipeParent) => {
|
return LoginManagerParent.recipeParentPromise.then((recipeParent) => {
|
||||||
return SpecialPowers.wrap(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
|
// Code to run when loaded as a chrome script in tests via loadChromeScript
|
||||||
if (this.addMessageListener) {
|
if (this.addMessageListener) {
|
||||||
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||||
|
@ -304,6 +334,11 @@ if (this.addMessageListener) {
|
||||||
} else {
|
} else {
|
||||||
// Code to only run in the mochitest pages (not in the chrome script).
|
// Code to only run in the mochitest pages (not in the chrome script).
|
||||||
SimpleTest.registerCleanupFunction(() => {
|
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());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче