Bug 1571555 - Mock the prompt service for the master password prompt in test_sdr.js. r=keeler

Differential Revision: https://phabricator.services.mozilla.com/D42383

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matthew Noorenberghe 2019-08-16 22:33:45 +00:00
Родитель 06cba876c4
Коммит 1af788f2cb
1 изменённых файлов: 26 добавлений и 0 удалений

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

@ -21,6 +21,32 @@ const gTokenPasswordDialogs = {
QueryInterface: ChromeUtils.generateQI([Ci.nsITokenPasswordDialogs]),
};
let gMockPrompter = {
promptPassword(dialogTitle, text, password, checkMsg, checkValue) {
// Returning false simulates the user canceling the password prompt.
return false;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIPrompt]),
};
// Mock nsIWindowWatcher. PSM calls getNewPrompter on this to get an nsIPrompt
// to call promptPassword. We return the mock one, above.
let gWindowWatcher = {
getNewPrompter: () => gMockPrompter,
QueryInterface: ChromeUtils.generateQI([Ci.nsIWindowWatcher]),
};
add_task(function setup() {
let windowWatcherCID = MockRegistrar.register(
"@mozilla.org/embedcomp/window-watcher;1",
gWindowWatcher
);
registerCleanupFunction(() => {
MockRegistrar.unregister(windowWatcherCID);
});
});
add_task(function testEncryptString() {
let sdr = Cc["@mozilla.org/security/sdr;1"].getService(
Ci.nsISecretDecoderRing