Bug 1316311 - Do not show the login capture doorhanger during generic mochitests. r=MattN
MozReview-Commit-ID: 6TFACISm9Vb
--- a/browser/base/content/test/general/browser_sanitize-passwordDisabledHosts.js
+++ b/browser/base/content/test/general/browser_sanitize-passwordDisabledHosts.js
@@ -2,16 +2,19 @@
// clearing site-specific settings in Clear Recent History dialog
var tempScope = {};
Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://browser/content/sanitize.js", tempScope);
var Sanitizer = tempScope.Sanitizer;
add_task(function*() {
+ // getLoginSavingEnabled always returns false if password capture is disabled.
+ yield SpecialPowers.pushPrefEnv({"set": [["signon.rememberSignons", true]]});
+
var pwmgr = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
// Add a disabled host
pwmgr.setLoginSavingEnabled("http://example.com", false);
// Sanity check
is(pwmgr.getLoginSavingEnabled("http://example.com"), false,
"example.com should be disabled for password saving since we haven't cleared that yet.");
@@ -31,9 +34,11 @@ add_task(function*() {
itemPrefs.setBoolPref("siteSettings", true);
// Clear it
yield s.sanitize();
// Make sure it's gone
is(pwmgr.getLoginSavingEnabled("http://example.com"), true,
"example.com should be enabled for password saving again now that we've cleared.");
+
+ yield SpecialPowers.popPrefEnv();
});
--- a/testing/profiles/prefs_general.js
+++ b/testing/profiles/prefs_general.js
@@ -350,8 +350,12 @@ user_pref("startup.homepage_welcome_url.
// For Firefox 52 only, ESR will support non-Flash plugins while release will
// not, so we keep testing the non-Flash pathways
user_pref("plugin.load_flash_only", false);
// Don't block old libavcodec libraries when testing, because our test systems
// cannot easily be upgraded.
user_pref("media.libavcodec.allow-obsolete", true);
+
+// Disable password capture, so that mochitests that include forms aren't
+// influenced by the presence of the persistent doorhanger notification.
+user_pref("signon.rememberSignons", false);
--- a/toolkit/components/passwordmgr/test/browser/browser_passwordmgr_contextmenu.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_passwordmgr_contextmenu.js
@@ -1,15 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-function test() {
- waitForExplicitFinish();
-
+add_task(function* test() {
+ yield new Promise(resolve => {
Services.logins.removeAllLogins();
// Add some initial logins
let urls = [
"http://example.com/",
"http://mozilla.org/",
"http://spreadfirefox.com/",
"https://support.mozilla.org/",
@@ -76,25 +75,26 @@ function test() {
(reason ? ": " + reason : ""));
}
function cleanUp() {
Services.ww.registerNotification(function (aSubject, aTopic, aData) {
Services.ww.unregisterNotification(arguments.callee);
Services.logins.removeAllLogins();
doc.getElementById("passwordCol").hidden = true;
- finish();
+ resolve();
});
pwmgrdlg.close();
}
function testPassword() {
info("Testing Copy Password");
waitForClipboard("coded", function copyPassword() {
menuitem = doc.getElementById("context-copypassword");
menuitem.doCommand();
}, cleanUp, cleanUp);
}
info("Testing Copy Username");
waitForClipboard("ehsan", copyField, testPassword, testPassword);
}
-}
+ });
+});
--- a/toolkit/components/passwordmgr/test/browser/browser_passwordmgr_fields.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_passwordmgr_fields.js
@@ -1,14 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-function test() {
- waitForExplicitFinish();
+add_task(function* test() {
+ yield new Promise(resolve => {
let pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
pwmgr.removeAllLogins();
// add login data
let nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1",
Ci.nsILoginInfo, "init");
@@ -51,15 +51,17 @@ function test() {
// cleanup
Services.ww.registerNotification(function (aSubject, aTopic, aData) {
if (aSubject.location == pwmgrdlg.location && aTopic == "domwindowclosed") {
// unregister ourself
Services.ww.unregisterNotification(arguments.callee);
pwmgr.removeAllLogins();
- finish();
+ resolve();
}
});
pwmgrdlg.close();
}
-}
+
+ });
+});
--- a/toolkit/components/passwordmgr/test/browser/browser_passwordmgr_observers.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_passwordmgr_observers.js
@@ -1,13 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
-function test() {
- waitForExplicitFinish();
+add_task(function* test() {
+ yield new Promise(resolve => {
const LOGIN_HOST = "http://example.com";
const LOGIN_COUNT = 5;
let nsLoginInfo = new Components.Constructor(
"@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo, "init");
let pmDialog = window.openDialog(
"chrome://passwordmgr/content/passwordManager.xul",
@@ -117,13 +117,15 @@ function test() {
break;
case 8: // remove all logins
Services.logins.removeAllLogins();
break;
case 9: // finish
Services.obs.removeObserver(
testObserver, "passwordmgr-dialog-updated", false);
pmDialog.close();
- finish();
+ resolve();
break;
}
}
-}
+
+ });
+});
--- a/toolkit/components/passwordmgr/test/browser/browser_passwordmgr_sort.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_passwordmgr_sort.js
@@ -1,14 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-function test() {
- waitForExplicitFinish();
+add_task(function* test() {
+ yield new Promise(resolve => {
let pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
pwmgr.removeAllLogins();
// Add some initial logins
let urls = [
"http://example.com/",
@@ -191,18 +191,19 @@ function test() {
checkColumnEntries(2, expectedValues);
checkSortDirection(passwordCol, true);
// cleanup
Services.ww.registerNotification(function (aSubject, aTopic, aData) {
// unregister ourself
Services.ww.unregisterNotification(arguments.callee);
pwmgr.removeAllLogins();
- finish();
+ resolve();
});
pwmgrdlg.close();
}
}
// Toggle Show Passwords to display Password column, then start tests
toggleShowPasswords(runNextTest);
}
-}
+ });
+});
--- a/toolkit/components/passwordmgr/test/browser/browser_passwordmgr_switchtab.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_passwordmgr_switchtab.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const PROMPT_URL = "chrome://global/content/commonDialog.xul";
var { interfaces: Ci } = Components;
-function test() {
- waitForExplicitFinish();
+add_task(function* test() {
+ yield new Promise(resolve => {
let tab = gBrowser.addTab();
isnot(tab, gBrowser.selectedTab, "New tab shouldn't be selected");
let listener = {
onOpenWindow: function(window) {
var domwindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
@@ -34,9 +34,11 @@ function test() {
Services.wm.removeListener(listener);
gBrowser.removeTab(tab);
});
tab.linkedBrowser.addEventListener("load", () => {
finish();
}, true);
tab.linkedBrowser.loadURI("http://example.com/browser/toolkit/components/passwordmgr/test/browser/authenticate.sjs");
-}
+
+ });
+});
--- a/toolkit/components/passwordmgr/test/browser/browser_passwordmgrdlg.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_passwordmgrdlg.js
@@ -1,14 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-function test() {
- waitForExplicitFinish();
+add_task(function* test() {
+ yield new Promise(resolve => {
let pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
pwmgr.removeAllLogins();
// Add some initial logins
let urls = [
"http://example.com/",
@@ -184,9 +184,10 @@ function test() {
pwmgr.removeAllLogins();
finish();
});
pwmgrdlg.close();
}
step1();
}
-}
+ });
+});
--- a/toolkit/components/passwordmgr/test/browser/head.js
+++ b/toolkit/components/passwordmgr/test/browser/head.js
@@ -1,14 +1,20 @@
const DIRECTORY_PATH = "/browser/toolkit/components/passwordmgr/test/browser/";
Cu.import("resource://testing-common/LoginTestUtils.jsm", this);
Cu.import("resource://testing-common/ContentTaskUtils.jsm", this);
+add_task(function* common_initialize() {
+ yield SpecialPowers.pushPrefEnv({"set": [["signon.rememberSignons", true]]});
+});
+
registerCleanupFunction(function* cleanup_removeAllLoginsAndResetRecipes() {
+ yield SpecialPowers.popPrefEnv();
+
Services.logins.removeAllLogins();
let recipeParent = LoginTestUtils.recipes.getRecipeParent();
if (!recipeParent) {
// No need to reset the recipes if the recipe module wasn't even loaded.
return;
}
yield recipeParent.then(recipeParentResult => recipeParentResult.reset());
--- a/toolkit/components/passwordmgr/test/pwmgr_common.js
+++ b/toolkit/components/passwordmgr/test/pwmgr_common.js
@@ -427,17 +427,19 @@ if (this.addMessageListener) {
});
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
globalMM.addMessageListener("RemoteLogins:onFormSubmit", function onFormSubmit(message) {
sendAsyncMessage("formSubmissionProcessed", message.data, message.objects);
});
} else {
// Code to only run in the mochitest pages (not in the chrome script).
+ SpecialPowers.pushPrefEnv({"set": [["signon.rememberSignons", true]]});
SimpleTest.registerCleanupFunction(() => {
+ SpecialPowers.popPrefEnv();
runInParent(function cleanupParent() {
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/LoginManagerParent.jsm");
// Remove all logins and disabled hosts
Services.logins.removeAllLogins();
--- a/toolkit/components/satchel/test/test_form_submission.html
+++ b/toolkit/components/satchel/test/test_form_submission.html
@@ -449,23 +449,16 @@ function checkSubmit(formNum) {
break;
}
return submitForm(formNum);
}
function submitForm(formNum)
{
- // Forms 13 and 14 would trigger a save-password notification. Temporarily
- // disable pwmgr, then reenable it.
- if (formNum == 12)
- SpecialPowers.setBoolPref("signon.rememberSignons", false);
- if (formNum == 14)
- SpecialPowers.clearUserPref("signon.rememberSignons");
-
// Forms 20 and 21 requires browser.formfill.saveHttpsForms to be false
if (formNum == 19)
SpecialPowers.setBoolPref("browser.formfill.saveHttpsForms", false);
// Reset preference now that 20 and 21 are over
if (formNum == 21)
SpecialPowers.clearUserPref("browser.formfill.saveHttpsForms");
// End the test now on SeaMonkey.