Bug 1316311 - Do not show the login capture doorhanger during generic mochitests. r=MattN

MozReview-Commit-ID: 6TFACISm9Vb

--HG--
extra : source : a29ad5792c609d1e41a3a1391b4c11f26729b35a
This commit is contained in:
Paolo Amadini 2016-11-10 13:47:07 +01:00
parent 10001144bc
commit 5543a483f7
11 changed files with 48 additions and 30 deletions

View File

@ -7,6 +7,9 @@ Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader)
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
@ -36,4 +39,6 @@ add_task(function*() {
// 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();
});

View File

@ -355,3 +355,7 @@ 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);

View File

@ -2,9 +2,8 @@
* 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
@ -81,7 +80,7 @@ function test() {
Services.ww.unregisterNotification(arguments.callee);
Services.logins.removeAllLogins();
doc.getElementById("passwordCol").hidden = true;
finish();
resolve();
});
pwmgrdlg.close();
}
@ -97,4 +96,5 @@ function test() {
info("Testing Copy Username");
waitForClipboard("ehsan", copyField, testPassword, testPassword);
}
}
});
});

View File

@ -2,8 +2,8 @@
* 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);
@ -56,10 +56,12 @@ function test() {
pwmgr.removeAllLogins();
finish();
resolve();
}
});
pwmgrdlg.close();
}
}
});
});

View File

@ -1,8 +1,8 @@
/* 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;
@ -122,8 +122,10 @@ function test() {
Services.obs.removeObserver(
testObserver, "passwordmgr-dialog-updated", false);
pmDialog.close();
finish();
resolve();
break;
}
}
}
});
});

View File

@ -2,8 +2,8 @@
* 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);
@ -196,7 +196,7 @@ function test() {
Services.ww.unregisterNotification(arguments.callee);
pwmgr.removeAllLogins();
finish();
resolve();
});
pwmgrdlg.close();
}
@ -205,4 +205,5 @@ function test() {
// Toggle Show Passwords to display Password column, then start tests
toggleShowPasswords(runNextTest);
}
}
});
});

View File

@ -5,8 +5,8 @@
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");
@ -39,4 +39,6 @@ function test() {
finish();
}, true);
tab.linkedBrowser.loadURI("http://example.com/browser/toolkit/components/passwordmgr/test/browser/authenticate.sjs");
}
});
});

View File

@ -2,8 +2,8 @@
* 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);
@ -189,4 +189,5 @@ function test() {
step1();
}
}
});
});

View File

@ -3,7 +3,13 @@ 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();

View File

@ -432,7 +432,9 @@ if (this.addMessageListener) {
});
} 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");

View File

@ -454,13 +454,6 @@ function checkSubmit(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);