Backed out changeset c93e30cbbed8 (bug 1269039)

This commit is contained in:
Carsten "Tomcat" Book 2016-05-03 12:29:40 +02:00
Родитель 5be95fc3fc
Коммит 9448d792be
4 изменённых файлов: 53 добавлений и 67 удалений

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

@ -38,7 +38,7 @@ skip-if = toolkit == 'android' # Bug 1259768
[test_input_events.html]
[test_input_events_for_identical_values.html]
[test_master_password.html]
skip-if = toolkit == 'android' # Tests desktop prompts
skip-if = toolkit == 'android' || e10s # Tests desktop prompts
support-files =
subtst_master_pass.html
[test_maxlength.html]

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

@ -17,29 +17,29 @@ Login Manager test: master password.
// Force parent to not look for tab-modal prompts, as they're not used for auth prompts.
isTabModal = false;
var chromeScript = runChecksAfterCommonInit();
commonInit();
SimpleTest.requestFlakyTimeout("untriaged");
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 SpecialPowers.wrap(SpecialPowers.Components).Constructor("@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo);
var exampleCom = "http://example.com/tests/toolkit/components/passwordmgr/test/mochitest/";
var exampleOrg = "http://example.org/tests/toolkit/components/passwordmgr/test/mochitest/";
runInParent(() => {
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
var pwmgr = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
var login1 = new nsLoginInfo();
var login2 = new nsLoginInfo();
var nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo);
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");
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);
});
pwmgr.addLogin(login1);
pwmgr.addLogin(login2);
</script>
<p id="display"></p>
@ -55,9 +55,9 @@ var iframe1 = document.getElementById("iframe1");
var iframe2 = document.getElementById("iframe2");
add_task(function* test_1() {
ok(isLoggedIn(), "should be initially logged in (no MP)");
ok(pwcrypt.isLoggedIn, "should be initially logged in (no MP)");
enableMasterPassword();
ok(!isLoggedIn(), "should be logged out after setting MP");
ok(!pwcrypt.isLoggedIn, "should be logged out after setting MP");
// Trigger a MP prompt via the API
var state = {
@ -80,14 +80,14 @@ add_task(function* test_1() {
};
var promptDone = handlePrompt(state, action);
var logins = chromeScript.sendSyncMessage("getAllLogins")[0][0];
var logins = pwmgr.getAllLogins();
yield promptDone;
is(logins.length, 3, "expected number of logins");
ok(isLoggedIn(), "should be logged in after MP prompt");
ok(pwcrypt.isLoggedIn, "should be logged in after MP prompt");
logoutMasterPassword();
ok(!isLoggedIn(), "should be logged out");
ok(!pwcrypt.isLoggedIn, "should be logged out");
});
add_task(function* test_2() {
@ -114,12 +114,12 @@ add_task(function* test_2() {
var failedAsExpected = false;
var logins = null;
try {
logins = chromeScript.sendSyncMessage("getAllLogins")[0][0];
logins = pwmgr.getAllLogins();
} catch (e) { failedAsExpected = true; }
yield promptDone;
ok(failedAsExpected, "getAllLogins should have thrown");
is(logins, null, "shouldn't have gotten logins");
ok(!isLoggedIn(), "should still be logged out");
ok(!pwcrypt.isLoggedIn, "should still be logged out");
});
add_task(function* test_3() {
@ -161,9 +161,9 @@ add_task(function* test_3() {
is(u.value, "user1", "checking expected user to have been filled in");
is(p.value, "pass1", "checking expected pass to have been filled in");
ok(isLoggedIn(), "should be logged in");
ok(pwcrypt.isLoggedIn, "should be logged in");
logoutMasterPassword();
ok(!isLoggedIn(), "should be logged out");
ok(!pwcrypt.isLoggedIn, "should be logged out");
});
add_task(function* test_4() {
@ -197,7 +197,7 @@ add_task(function* test_4() {
is(u.value, "", "checking expected empty user");
is(p.value, "", "checking expected empty pass");
ok(!isLoggedIn(), "should be logged out");
ok(!pwcrypt.isLoggedIn, "should be logged out");
// XXX check that there's 1 MP window open
@ -223,7 +223,7 @@ add_task(function* test_4() {
is(p.value, "", "checking expected empty pass");
// XXX check that there's 1 MP window open
ok(!isLoggedIn(), "should be logged out");
ok(!pwcrypt.isLoggedIn, "should be logged out");
// Ok, now enter the MP. The MP prompt is already up.
@ -243,7 +243,7 @@ add_task(function* test_4() {
// filling of iframe2's data. We notify observers synchronously, so
// iframe2's observer will process iframe2 before iframe1 even finishes
// processing the form.
ok(isLoggedIn(), "should be logged in");
ok(pwcrypt.isLoggedIn, "should be logged in");
// check contents of iframe1 fields
u = SpecialPowers.wrap(iframe1).contentDocument.getElementById("userfield");
@ -262,6 +262,9 @@ add_task(function* test_4() {
SimpleTest.registerCleanupFunction(function finishTest() {
disableMasterPassword();
pwmgr.removeLogin(login1);
pwmgr.removeLogin(login2);
});
</script>

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

@ -207,19 +207,26 @@ function disableMasterPassword() {
}
function setMasterPassword(enable) {
chromeScript.sendSyncMessage("setMasterPassword", { enable });
var oldPW, newPW;
if (enable) {
oldPW = "";
newPW = masterPassword;
} else {
oldPW = masterPassword;
newPW = "";
}
// Set master password. Note that this does not log you in, so the next
// invocation of pwmgr can trigger a MP prompt.
var pk11db = Cc["@mozilla.org/security/pk11tokendb;1"].getService(Ci.nsIPK11TokenDB);
var token = pk11db.findTokenByName("");
info("MP change from " + oldPW + " to " + newPW);
token.changePassword(oldPW, newPW);
}
function logoutMasterPassword() {
runInParent(function parent_logoutMasterPassword() {
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
var sdr = Cc["@mozilla.org/security/sdr;1"].getService(Ci.nsISecretDecoderRing);
sdr.logoutAndTeardown();
});
}
function isLoggedIn() {
return chromeScript.sendSyncMessage("isLoggedIn")[0][0];
var sdr = Cc["@mozilla.org/security/sdr;1"].getService(Ci.nsISecretDecoderRing);
sdr.logoutAndTeardown();
}
function dumpLogins(pwmgr) {
@ -354,7 +361,6 @@ if (this.addMessageListener) {
// Ignore ok/is in commonInit since they aren't defined in a chrome script.
ok = is = () => {}; // eslint-disable-line no-native-reassign
Cu.import("resource://gre/modules/LoginHelper.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Task.jsm");
@ -389,32 +395,6 @@ if (this.addMessageListener) {
return Services.logins.countLogins(formOrigin, submitOrigin, httpRealm);
});
addMessageListener("getAllLogins", () => {
return LoginHelper.loginsToVanillaObjects(Services.logins.getAllLogins());
});
addMessageListener("isLoggedIn", () => {
return Services.logins.isLoggedIn;
});
addMessageListener("setMasterPassword", ({ enable }) => {
var oldPW, newPW;
if (enable) {
oldPW = "";
newPW = masterPassword;
} else {
oldPW = masterPassword;
newPW = "";
}
// Set master password. Note that this does not log you in, so the next
// invocation of pwmgr can trigger a MP prompt.
var pk11db = Cc["@mozilla.org/security/pk11tokendb;1"].getService(Ci.nsIPK11TokenDB);
var token = pk11db.findTokenByName("");
dump("MP change from " + oldPW + " to " + newPW + "\n");
token.changePassword(oldPW, newPW);
});
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
globalMM.addMessageListener("RemoteLogins:onFormSubmit", function onFormSubmit(message) {
sendAsyncMessage("formSubmissionProcessed", message.data, message.objects);

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

@ -1,4 +1,7 @@
const { Cc, Ci } = SpecialPowers;
const Ci = SpecialPowers.Ci;
const Cc = SpecialPowers.Cc;
ok(Ci != null, "Access Ci");
ok(Cc != null, "Access Cc");
function hasTabModalPrompts() {
var prefName = "prompts.tab_modal.enabled";