зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1357905 - Add missing _removeMasterPassword function that got lost in the re-org, as well as a test to confirm that the master password functionality works. r=mossop
I checked each function of the old security.js to make sure there weren't any other missing functions. MozReview-Commit-ID: DpFcAYsfcyg --HG-- extra : rebase_source : 5d1b25ebde5a0cf8849210315c773bf25c10e7a3
This commit is contained in:
Родитель
d686f44878
Коммит
edf52b9061
|
@ -959,6 +959,27 @@ var gPrivacyPane = {
|
||||||
this._initMasterPasswordUI();
|
this._initMasterPasswordUI();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the "remove master password" dialog to allow the user to remove
|
||||||
|
* the current master password. When the dialog is dismissed, master password
|
||||||
|
* UI is automatically updated.
|
||||||
|
*/
|
||||||
|
_removeMasterPassword() {
|
||||||
|
var secmodDB = Cc["@mozilla.org/security/pkcs11moduledb;1"].
|
||||||
|
getService(Ci.nsIPKCS11ModuleDB);
|
||||||
|
if (secmodDB.isFIPSEnabled) {
|
||||||
|
var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
|
||||||
|
getService(Ci.nsIPromptService);
|
||||||
|
var bundle = document.getElementById("bundlePreferences");
|
||||||
|
promptService.alert(window,
|
||||||
|
bundle.getString("pw_change_failed_title"),
|
||||||
|
bundle.getString("pw_change2empty_in_fips_mode"));
|
||||||
|
this._initMasterPasswordUI();
|
||||||
|
} else {
|
||||||
|
gSubDialog.open("chrome://mozapps/content/preferences/removemp.xul",
|
||||||
|
null, null, this._initMasterPasswordUI.bind(this));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a dialog in which the master password may be changed.
|
* Displays a dialog in which the master password may be changed.
|
||||||
|
|
|
@ -29,6 +29,7 @@ skip-if = os != "win" # This test tests the windows-specific app selection dialo
|
||||||
skip-if = true || !healthreport # Bug 1185403 for the "true"
|
skip-if = true || !healthreport # Bug 1185403 for the "true"
|
||||||
[browser_homepages_filter_aboutpreferences.js]
|
[browser_homepages_filter_aboutpreferences.js]
|
||||||
[browser_layersacceleration.js]
|
[browser_layersacceleration.js]
|
||||||
|
[browser_masterpassword.js]
|
||||||
[browser_notifications_do_not_disturb.js]
|
[browser_notifications_do_not_disturb.js]
|
||||||
[browser_permissions_urlFieldHidden.js]
|
[browser_permissions_urlFieldHidden.js]
|
||||||
[browser_proxy_backup.js]
|
[browser_proxy_backup.js]
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
add_task(function*() {
|
||||||
|
let prefs = yield openPreferencesViaOpenPreferencesAPI("panePrivacy", {leaveOpen: true});
|
||||||
|
is(prefs.selectedPane, "panePrivacy", "Privacy pane was selected");
|
||||||
|
|
||||||
|
let doc = gBrowser.contentDocument;
|
||||||
|
// Fake the subdialog and LoginHelper
|
||||||
|
let win = doc.defaultView;
|
||||||
|
let dialogURL = "";
|
||||||
|
win.gSubDialog = {
|
||||||
|
open(aDialogURL, unused, unused2, aCallback) {
|
||||||
|
dialogURL = aDialogURL;
|
||||||
|
masterPasswordSet = masterPasswordNextState;
|
||||||
|
aCallback();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let masterPasswordSet = false;
|
||||||
|
win.LoginHelper = {
|
||||||
|
isMasterPasswordSet() {
|
||||||
|
return masterPasswordSet;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let checkbox = doc.querySelector("#useMasterPassword");
|
||||||
|
ok(!checkbox.checked, "master password checkbox should be unchecked by default");
|
||||||
|
let button = doc.getElementById("changeMasterPassword");
|
||||||
|
ok(button.disabled, "master password button should be disabled by default");
|
||||||
|
|
||||||
|
let masterPasswordNextState = true;
|
||||||
|
checkbox.click();
|
||||||
|
is(dialogURL,
|
||||||
|
"chrome://mozapps/content/preferences/changemp.xul",
|
||||||
|
"clicking on the checkbox should open the masterpassword dialog");
|
||||||
|
ok(!button.disabled, "master password button should now be enabled");
|
||||||
|
ok(checkbox.checked, "master password checkbox should be checked now");
|
||||||
|
|
||||||
|
dialogURL = "";
|
||||||
|
button.doCommand();
|
||||||
|
is(dialogURL,
|
||||||
|
"chrome://mozapps/content/preferences/changemp.xul",
|
||||||
|
"clicking on the button should open the masterpassword dialog");
|
||||||
|
ok(!button.disabled, "master password button should still be enabled");
|
||||||
|
ok(checkbox.checked, "master password checkbox should be checked still");
|
||||||
|
|
||||||
|
masterPasswordNextState = false;
|
||||||
|
dialogURL = "";
|
||||||
|
checkbox.click();
|
||||||
|
is(dialogURL,
|
||||||
|
"chrome://mozapps/content/preferences/removemp.xul",
|
||||||
|
"clicking on the checkbox to uncheck master password should show the removal dialog");
|
||||||
|
ok(button.disabled, "master password button should now be disabled");
|
||||||
|
ok(!checkbox.checked, "master password checkbox should now be unchecked");
|
||||||
|
|
||||||
|
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||||
|
});
|
Загрузка…
Ссылка в новой задаче