Bug 1412890 - Enable ESLint rule mozilla/use-services for toolkit/components/passwordmgr. r=MattN

MozReview-Commit-ID: BNojtj1cAji

--HG--
extra : rebase_source : cfbe9b186e4be171674807a48d9e1accb67b34db
This commit is contained in:
Mark Banner 2017-10-30 16:28:39 +00:00
Родитель 0dd9f867bb
Коммит 7dcccb8252
24 изменённых файлов: 174 добавлений и 267 удалений

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

@ -9,5 +9,6 @@ module.exports = {
"no-unused-vars": ["error", {"args": "none", "vars": "local", "varsIgnorePattern": "^(ids|ignored|unused)$"}],
"semi": ["error", "always"],
"mozilla/use-services": "error",
}
};

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

@ -400,16 +400,13 @@ function DeleteSignon() {
}
function DeleteAllSignons() {
let prompter = Cc["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Ci.nsIPromptService);
// Confirm the user wants to remove all passwords
let dummy = { value: false };
if (prompter.confirmEx(window,
kSignonBundle.getString("removeAllPasswordsTitle"),
kSignonBundle.getString("removeAllPasswordsPrompt"),
prompter.STD_YES_NO_BUTTONS + prompter.BUTTON_POS_1_DEFAULT,
null, null, null, null, dummy) == 1) // 1 == "No" button
if (Services.prompt.confirmEx(window,
kSignonBundle.getString("removeAllPasswordsTitle"),
kSignonBundle.getString("removeAllPasswordsPrompt"),
Services.prompt.STD_YES_NO_BUTTONS + Services.prompt.BUTTON_POS_1_DEFAULT,
null, null, null, null, dummy) == 1) // 1 == "No" button
return;
let syncNeeded = signonsTreeView._filterSet.length != 0;
@ -455,13 +452,12 @@ function TogglePasswordVisible() {
}
function AskUserShowPasswords() {
let prompter = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService);
let dummy = { value: false };
// Confirm the user wants to display passwords
return prompter.confirmEx(window,
return Services.prompt.confirmEx(window,
null,
kSignonBundle.getString("noMasterPasswordPrompt"), prompter.STD_YES_NO_BUTTONS,
kSignonBundle.getString("noMasterPasswordPrompt"), Services.prompt.STD_YES_NO_BUTTONS,
null, null, null, null, dummy) == 0; // 0=="Yes" button
}

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

@ -87,12 +87,12 @@ LoginManagerPromptFactory.prototype = {
var prompt = this._asyncPrompts[hashKey];
var prompter = prompt.prompter;
var [hostname, httpRealm] = prompter._getAuthTarget(prompt.channel, prompt.authInfo);
var hasLogins = (prompter._pwmgr.countLogins(hostname, null, httpRealm) > 0);
var hasLogins = (Services.logins.countLogins(hostname, null, httpRealm) > 0);
if (!hasLogins && LoginHelper.schemeUpgrades && hostname.startsWith("https://")) {
let httpHostname = hostname.replace(/^https:\/\//, "http://");
hasLogins = (prompter._pwmgr.countLogins(httpHostname, null, httpRealm) > 0);
hasLogins = (Services.logins.countLogins(httpHostname, null, httpRealm) > 0);
}
if (hasLogins && prompter._pwmgr.uiBusy) {
if (hasLogins && Services.logins.uiBusy) {
this.log("_doAsyncPrompt:run bypassed, master password UI busy");
return;
}
@ -251,30 +251,10 @@ LoginManagerPrompter.prototype = {
_browser: null,
_opener: null,
__pwmgr: null, // Password Manager service
get _pwmgr() {
if (!this.__pwmgr)
this.__pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
return this.__pwmgr;
},
__promptService: null, // Prompt service for user interaction
get _promptService() {
if (!this.__promptService)
this.__promptService =
Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService);
return this.__promptService;
},
__strBundle: null, // String bundle for L10N
get _strBundle() {
if (!this.__strBundle) {
var bunService = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService);
this.__strBundle = bunService.createBundle(
this.__strBundle = Services.strings.createBundle(
"chrome://passwordmgr/locale/passwordmgr.properties");
if (!this.__strBundle)
throw new Error("String bundle for Login Manager not present!");
@ -333,7 +313,7 @@ LoginManagerPrompter.prototype = {
aResult.value = aDefaultText;
}
return this._promptService.prompt(this._chromeWindow,
return Services.prompt.prompt(this._chromeWindow,
aDialogTitle, aText, aResult, null, {});
},
@ -363,15 +343,15 @@ LoginManagerPrompter.prototype = {
else
canRememberLogin = (aSavePassword ==
Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY) &&
this._pwmgr.getLoginSavingEnabled(hostname);
Services.logins.getLoginSavingEnabled(hostname);
// if checkBoxLabel is null, the checkbox won't be shown at all.
if (canRememberLogin)
checkBoxLabel = this._getLocalizedString("rememberPassword");
// Look for existing logins.
var foundLogins = this._pwmgr.findLogins({}, hostname, null,
realm);
var foundLogins = Services.logins.findLogins({}, hostname, null,
realm);
// XXX Like the original code, we can't deal with multiple
// account selection. (bug 227632)
@ -395,7 +375,7 @@ LoginManagerPrompter.prototype = {
}
}
var ok = this._promptService.promptUsernameAndPassword(this._chromeWindow,
var ok = Services.prompt.promptUsernameAndPassword(this._chromeWindow,
aDialogTitle, aText, aUsername, aPassword,
checkBoxLabel, checkBox);
@ -421,7 +401,7 @@ LoginManagerPrompter.prototype = {
if (!selectedLogin) {
// add as new
this.log("New login seen for " + realm);
this._pwmgr.addLogin(newLogin);
Services.logins.addLogin(newLogin);
} else if (aPassword.value != selectedLogin.password) {
// update password
this.log("Updating password for " + realm);
@ -461,7 +441,7 @@ LoginManagerPrompter.prototype = {
if (hostname && !this._inPrivateBrowsing) {
var canRememberLogin = (aSavePassword ==
Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY) &&
this._pwmgr.getLoginSavingEnabled(hostname);
Services.logins.getLoginSavingEnabled(hostname);
// if checkBoxLabel is null, the checkbox won't be shown at all.
if (canRememberLogin)
@ -469,8 +449,8 @@ LoginManagerPrompter.prototype = {
if (!aPassword.value) {
// Look for existing logins.
var foundLogins = this._pwmgr.findLogins({}, hostname, null,
realm);
var foundLogins = Services.logins.findLogins({}, hostname, null,
realm);
// XXX Like the original code, we can't deal with multiple
// account selection (bug 227632). We can deal with finding the
@ -486,9 +466,9 @@ LoginManagerPrompter.prototype = {
}
}
var ok = this._promptService.promptPassword(this._chromeWindow, aDialogTitle,
aText, aPassword,
checkBoxLabel, checkBox);
var ok = Services.prompt.promptPassword(this._chromeWindow, aDialogTitle,
aText, aPassword,
checkBoxLabel, checkBox);
if (ok && checkBox.value && hostname && aPassword.value) {
var newLogin = Cc["@mozilla.org/login-manager/loginInfo;1"].
@ -498,7 +478,7 @@ LoginManagerPrompter.prototype = {
this.log("New login seen for " + realm);
this._pwmgr.addLogin(newLogin);
Services.logins.addLogin(newLogin);
}
return ok;
@ -599,7 +579,7 @@ LoginManagerPrompter.prototype = {
checkbox.value = true;
}
var canRememberLogin = this._pwmgr.getLoginSavingEnabled(hostname);
var canRememberLogin = Services.logins.getLoginSavingEnabled(hostname);
if (this._inPrivateBrowsing)
canRememberLogin = false;
@ -618,9 +598,9 @@ LoginManagerPrompter.prototype = {
if (!ok) {
if (this._chromeWindow)
PromptUtils.fireDialogEvent(this._chromeWindow, "DOMWillOpenModalDialog", this._browser);
ok = this._promptService.promptAuth(this._chromeWindow,
aChannel, aLevel, aAuthInfo,
checkboxLabel, checkbox);
ok = Services.prompt.promptAuth(this._chromeWindow,
aChannel, aLevel, aAuthInfo,
checkboxLabel, checkbox);
}
// If there's a notification box, use it to allow the user to
@ -657,7 +637,7 @@ LoginManagerPrompter.prototype = {
if (notifyObj)
this._showSaveLoginNotification(notifyObj, newLogin);
else
this._pwmgr.addLogin(newLogin);
Services.logins.addLogin(newLogin);
} else if (password != selectedLogin.password) {
this.log("Updating password for " + username +
" @ " + hostname + " (" + httpRealm + ")");
@ -1094,11 +1074,6 @@ LoginManagerPrompter.prototype = {
"rememberPasswordMsgNoUsername",
[displayHost]);
// The callbacks in |buttons| have a closure to access the variables
// in scope here; set one to |this._pwmgr| so we can get back to pwmgr
// without a getService() call.
var pwmgr = this._pwmgr;
// Notification is a PopupNotification
if (aNotifyObj == this._getPopupNote()) {
this._showLoginCaptureDoorhanger(aLogin, "password-save");
@ -1114,7 +1089,7 @@ LoginManagerPrompter.prototype = {
accessKey: rememberButtonAccessKey,
popup: null,
callback(aNotifyObj, aButton) {
pwmgr.addLogin(aLogin);
Services.logins.addLogin(aLogin);
}
},
@ -1124,7 +1099,7 @@ LoginManagerPrompter.prototype = {
accessKey: neverButtonAccessKey,
popup: null,
callback(aNotifyObj, aButton) {
pwmgr.setLoginSavingEnabled(aLogin.hostname, false);
Services.logins.setLoginSavingEnabled(aLogin.hostname, false);
}
},
@ -1202,21 +1177,21 @@ LoginManagerPrompter.prototype = {
"notNowButtonText");
this.log("Prompting user to save/ignore login");
var userChoice = this._promptService.confirmEx(this._chromeWindow,
dialogTitle, dialogText,
buttonFlags, rememberButtonText,
notNowButtonText, neverButtonText,
null, {});
var userChoice = Services.prompt.confirmEx(this._chromeWindow,
dialogTitle, dialogText,
buttonFlags, rememberButtonText,
notNowButtonText, neverButtonText,
null, {});
// Returns:
// 0 - Save the login
// 1 - Ignore the login this time
// 2 - Never save logins for this site
if (userChoice == 2) {
this.log("Disabling " + aLogin.hostname + " logins by request.");
this._pwmgr.setLoginSavingEnabled(aLogin.hostname, false);
Services.logins.setLoginSavingEnabled(aLogin.hostname, false);
} else if (userChoice == 0) {
this.log("Saving login for " + aLogin.hostname);
this._pwmgr.addLogin(aLogin);
Services.logins.addLogin(aLogin);
} else {
// userChoice == 1 --> just ignore the login.
this.log("Ignoring login.");
@ -1272,11 +1247,6 @@ LoginManagerPrompter.prototype = {
var notificationText = this._getLocalizedString("updatePasswordMsg",
[displayHost]);
// The callbacks in |buttons| have a closure to access the variables
// in scope here; set one to |this._pwmgr| so we can get back to pwmgr
// without a getService() call.
var self = this;
// Notification is a PopupNotification
if (aNotifyObj == this._getPopupNote()) {
aOldLogin.hostname = aNewLogin.hostname;
@ -1296,7 +1266,7 @@ LoginManagerPrompter.prototype = {
accessKey: changeButtonAccessKey,
popup: null,
callback(aNotifyObj, aButton) {
self._updateLogin(aOldLogin, aNewLogin);
Services.logins._updateLogin(aOldLogin, aNewLogin);
}
},
@ -1339,10 +1309,10 @@ LoginManagerPrompter.prototype = {
"passwordChangeTitle");
// returns 0 for yes, 1 for no.
var ok = !this._promptService.confirmEx(this._chromeWindow,
dialogTitle, dialogText, buttonFlags,
null, null, null,
null, {});
var ok = !Services.prompt.confirmEx(this._chromeWindow,
dialogTitle, dialogText, buttonFlags,
null, null, null,
null, {});
if (ok) {
this.log("Updating password for user " + aOldLogin.username);
this._updateLogin(aOldLogin, aNewLogin);
@ -1374,10 +1344,10 @@ LoginManagerPrompter.prototype = {
// If user selects ok, outparam.value is set to the index
// of the selected username.
var ok = this._promptService.select(this._chromeWindow,
dialogTitle, dialogText,
usernames.length, usernames,
selectedIndex);
var ok = Services.prompt.select(this._chromeWindow,
dialogTitle, dialogText,
usernames.length, usernames,
selectedIndex);
if (ok) {
// Now that we know which login to use, modify its password.
var selectedLogin = logins[selectedIndex.value];
@ -1416,7 +1386,7 @@ LoginManagerPrompter.prototype = {
}
propBag.setProperty("timeLastUsed", now);
propBag.setProperty("timesUsedIncrement", 1);
this._pwmgr.modifyLogin(login, propBag);
Services.logins.modifyLogin(login, propBag);
},
/**
@ -1590,13 +1560,11 @@ LoginManagerPrompter.prototype = {
_getShortDisplayHost(aURIString) {
var displayHost;
var eTLDService = Cc["@mozilla.org/network/effective-tld-service;1"].
getService(Ci.nsIEffectiveTLDService);
var idnService = Cc["@mozilla.org/network/idn-service;1"].
getService(Ci.nsIIDNService);
try {
var uri = Services.io.newURI(aURIString);
var baseDomain = eTLDService.getBaseDomain(uri);
var baseDomain = Services.eTLD.getBaseDomain(uri);
displayHost = idnService.convertToDisplayIDN(baseDomain, {});
} catch (e) {
this.log("_getShortDisplayHost couldn't process " + aURIString);

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

@ -77,14 +77,6 @@ LoginManagerStorage_mozStorage.prototype = {
return this.__profileDir;
},
__storageService: null, // Storage service for using mozStorage
get _storageService() {
if (!this.__storageService)
this.__storageService = Cc["@mozilla.org/storage/service;1"].
getService(Ci.mozIStorageService);
return this.__storageService;
},
__uuidService: null,
get _uuidService() {
if (!this.__uuidService)
@ -832,7 +824,7 @@ LoginManagerStorage_mozStorage.prototype = {
this.log("Initializing Database");
let isFirstRun = false;
try {
this._dbConnection = this._storageService.openDatabase(this._signonsFile);
this._dbConnection = Services.storage.openDatabase(this._signonsFile);
// Get the version of the schema in the file. It will be 0 if the
// database has not been created yet.
let version = this._dbConnection.schemaVersion;
@ -1243,7 +1235,7 @@ LoginManagerStorage_mozStorage.prototype = {
// Create backup file
if (backup) {
let backupFile = this._signonsFile.leafName + ".corrupt";
this._storageService.backupDatabaseFile(this._signonsFile, backupFile);
Services.storage.backupDatabaseFile(this._signonsFile, backupFile);
}
this._dbClose();

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

@ -5,16 +5,14 @@
add_task(async function test() {
await new Promise(resolve => {
let pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
pwmgr.removeAllLogins();
Services.logins.removeAllLogins();
// add login data
let nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1",
Ci.nsILoginInfo, "init");
let login = new nsLoginInfo("http://example.com/", "http://example.com/", null,
"user", "password", "u1", "p1");
pwmgr.addLogin(login);
Services.logins.addLogin(login);
// Open the password manager dialog
const PWMGR_DLG = "chrome://passwordmgr/content/passwordManager.xul";
@ -54,7 +52,7 @@ add_task(async function test() {
// unregister ourself
Services.ww.unregisterNotification(notification);
pwmgr.removeAllLogins();
Services.logins.removeAllLogins();
resolve();
}

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

@ -4,10 +4,7 @@
add_task(async function test() {
await new Promise(resolve => {
let pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
pwmgr.removeAllLogins();
Services.logins.removeAllLogins();
// Add some initial logins
let urls = [
@ -49,8 +46,8 @@ add_task(async function test() {
let nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1",
Ci.nsILoginInfo, "init");
for (let i = 0; i < 10; i++)
pwmgr.addLogin(new nsLoginInfo(urls[i], urls[i], null, users[i], pwds[i],
"u" + (i + 1), "p" + (i + 1)));
Services.logins.addLogin(new nsLoginInfo(urls[i], urls[i], null, users[i], pwds[i],
"u" + (i + 1), "p" + (i + 1)));
// Open the password manager dialog
const PWMGR_DLG = "chrome://passwordmgr/content/passwordManager.xul";
@ -195,7 +192,7 @@ add_task(async function test() {
// unregister ourself
Services.ww.unregisterNotification(notification);
pwmgr.removeAllLogins();
Services.logins.removeAllLogins();
resolve();
});
pwmgrdlg.close();

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

@ -4,10 +4,7 @@
add_task(async function test() {
await new Promise(resolve => {
let pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
pwmgr.removeAllLogins();
Services.logins.removeAllLogins();
// Add some initial logins
let urls = [
@ -36,7 +33,7 @@ add_task(async function test() {
new nsLoginInfo(urls[8], urls[8], null, "my user name", "mozilla", "u9", "p9"),
new nsLoginInfo(urls[9], urls[9], null, "my username", "mozilla.com", "u10", "p10"),
];
logins.forEach(login => pwmgr.addLogin(login));
logins.forEach(login => Services.logins.addLogin(login));
// Open the password manager dialog
const PWMGR_DLG = "chrome://passwordmgr/content/passwordManager.xul";
@ -181,7 +178,7 @@ add_task(async function test() {
// unregister ourself
Services.ww.unregisterNotification(notification);
pwmgr.removeAllLogins();
Services.logins.removeAllLogins();
finish();
});
pwmgrdlg.close();

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

@ -7,10 +7,8 @@
function getSelectDialogDoc() {
// Trudge through all the open windows, until we find the one
// that has selectDialog.xul loaded.
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
// var enumerator = wm.getEnumerator("navigator:browser");
var enumerator = wm.getXULWindowEnumerator(null);
// var enumerator = Services.wm.getEnumerator("navigator:browser");
var enumerator = Services.wm.getXULWindowEnumerator(null);
while (enumerator.hasMoreElements()) {
var win = enumerator.getNext();

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

@ -63,7 +63,7 @@ function loadNextTest() {
break;
case 4:
pwmgr.addLogin(login);
Services.logins.addLogin(login);
break;
case 5:
@ -77,7 +77,7 @@ function loadNextTest() {
break;
case 7:
pwmgr.addLogin(login);
Services.logins.addLogin(login);
break;
case 8:
@ -152,7 +152,7 @@ function checkTest() {
popup = getPopup(popupNotifications, "password-change");
ok(popup, "got popup notification");
popup.remove();
pwmgr.removeLogin(login);
Services.logins.removeLogin(login);
break;
case 7:
@ -185,7 +185,7 @@ function checkTest() {
gotPass = iframe.contentDocument.getElementById("pass").textContent;
is(gotUser, "notifyu1", "Checking submitted username");
is(gotPass, "notifyp1", "Checking submitted password");
pwmgr.removeLogin(login);
Services.logins.removeLogin(login);
break;
default:
@ -262,15 +262,11 @@ function handleLoad(aEvent) {
}
}
var pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
ok(pwmgr != null, "Access pwmgr");
// We need to make sure no logins have been stored by previous tests
// for forms in |url|, otherwise the change password notification
// would turn into a prompt, and the test will fail.
var url = "http://test2.example.com";
is(pwmgr.countLogins(url, "", null), 0, "No logins should be stored for " + url);
is(Services.logins.countLogins(url, "", null), 0, "No logins should be stored for " + url);
var nsLoginInfo = new SpecialPowers.wrap(SpecialPowers.Components).Constructor("@mozilla.org/login-manager/loginInfo;1",
Ci.nsILoginInfo, "init");
@ -318,4 +314,3 @@ SimpleTest.waitForExplicitFinish();
</pre>
</body>
</html>

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

@ -17,7 +17,7 @@ SimpleTest.waitForExplicitFinish();
let chromeScript = runInParent(function chromeSetup() {
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
let pwmgr = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
let login1A = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
@ -42,18 +42,18 @@ let chromeScript = runInParent(function chromeSetup() {
login2C.init("http://mochi.test:8888", "http://bug444968-2", null,
"testuser2C", "testpass2C", "", "");
pwmgr.addLogin(login1A);
pwmgr.addLogin(login1B);
pwmgr.addLogin(login2A);
pwmgr.addLogin(login2B);
pwmgr.addLogin(login2C);
Services.logins.addLogin(login1A);
Services.logins.addLogin(login1B);
Services.logins.addLogin(login2A);
Services.logins.addLogin(login2B);
Services.logins.addLogin(login2C);
addMessageListener("removeLogins", function removeLogins() {
pwmgr.removeLogin(login1A);
pwmgr.removeLogin(login1B);
pwmgr.removeLogin(login2A);
pwmgr.removeLogin(login2B);
pwmgr.removeLogin(login2C);
Services.logins.removeLogin(login1A);
Services.logins.removeLogin(login1B);
Services.logins.removeLogin(login2A);
Services.logins.removeLogin(login2B);
Services.logins.removeLogin(login2C);
});
});

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

@ -14,9 +14,7 @@ runChecksAfterCommonInit(() => startTest());
runInParent(function setup() {
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
let pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
login1 = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login2 = Cc["@mozilla.org/login-manager/loginInfo;1"].
@ -35,10 +33,10 @@ runInParent(function setup() {
login4.init("http://mochi.test:8888", "http://bug600551-4", null,
"123456789", "testpass4", "", "");
pwmgr.addLogin(login1);
pwmgr.addLogin(login2);
pwmgr.addLogin(login3);
pwmgr.addLogin(login4);
Services.logins.addLogin(login1);
Services.logins.addLogin(login2);
Services.logins.addLogin(login3);
Services.logins.addLogin(login4);
});
</script>

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

@ -13,9 +13,7 @@ Login Manager test: forms and logins without a username.
runChecksAfterCommonInit(() => startTest());
runInParent(() => {
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
var pwmgr = Cc["@mozilla.org/login-manager;1"]
.getService(Ci.nsILoginManager);
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
var nsLoginInfo = Components.Constructor("@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo);
// pwlogin1 uses a unique formSubmitURL, to check forms where no other logins
@ -34,8 +32,8 @@ runInParent(() => {
"", "1234", "uname", "pword");
pwmgr.addLogin(pwlogin1);
pwmgr.addLogin(pwlogin2);
Services.logins.addLogin(pwlogin1);
Services.logins.addLogin(pwlogin2);
});
</script>
<p id="display"></p>
@ -210,4 +208,3 @@ function startTest() {
</pre>
</body>
</html>

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

@ -31,7 +31,7 @@ let prompterParent = runInParent(() => {
const promptFac = Cc["@mozilla.org/passwordmanager/authpromptfactory;1"].
getService(Ci.nsIPromptFactory);
Cu.import("resource://gre/modules/Services.jsm");
let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
let prompter1 = promptFac.getPrompt(chromeWin, Ci.nsIAuthPrompt);
@ -52,10 +52,8 @@ const defaultMsg = "the message";
function initLogins() {
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
var login1, login2A, login2B, login2C, login2D, login2E;
var pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
login1 = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login2A = Cc["@mozilla.org/login-manager/loginInfo;1"].
@ -82,12 +80,12 @@ function initLogins() {
login2E.init("http://example2.com", null, "http://example2.com",
"100%beef", "user3pass", "", "");
pwmgr.addLogin(login1);
pwmgr.addLogin(login2A);
pwmgr.addLogin(login2B);
pwmgr.addLogin(login2C);
pwmgr.addLogin(login2D);
pwmgr.addLogin(login2E);
Services.logins.addLogin(login1);
Services.logins.addLogin(login2A);
Services.logins.addLogin(login2B);
Services.logins.addLogin(login2C);
Services.logins.addLogin(login2D);
Services.logins.addLogin(login2E);
}
add_task(async function setup() {

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

@ -29,10 +29,7 @@ let chromeScript = runInParent(SimpleTest.getTestFileURL("pwmgr_common.js"));
runInParent(() => {
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm");
let pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
let login3A, login3B, login4;
login3A = Cc["@mozilla.org/login-manager/loginInfo;1"].
@ -69,13 +66,13 @@ runInParent(() => {
"dedupeUser", "httpsPass", "", "");
pwmgr.addLogin(login3A);
pwmgr.addLogin(login3B);
pwmgr.addLogin(login4);
pwmgr.addLogin(httpUpgradeLogin);
pwmgr.addLogin(httpsDowngradeLogin);
pwmgr.addLogin(dedupeHttpUpgradeLogin);
pwmgr.addLogin(dedupeHttpsUpgradeLogin);
Services.logins.addLogin(login3A);
Services.logins.addLogin(login3B);
Services.logins.addLogin(login4);
Services.logins.addLogin(httpUpgradeLogin);
Services.logins.addLogin(httpsDowngradeLogin);
Services.logins.addLogin(dedupeHttpUpgradeLogin);
Services.logins.addLogin(dedupeHttpsUpgradeLogin);
});
add_task(async function test_iframe() {

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

@ -45,27 +45,26 @@ let prompterParent = runInParent(() => {
let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
let prompter2 = promptFac.getPrompt(chromeWin, Ci.nsIAuthPrompt2);
let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let channels = {};
channels.channel1 = ioService.newChannel2("http://example.com",
null,
null,
null, // aLoadingNode
Services.
scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
channels.channel1 = Services.io.newChannel2("http://example.com",
null,
null,
null, // aLoadingNode
Services.
scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
channels.channel2 = ioService.newChannel2("http://example2.com",
null,
null,
null, // aLoadingNode
Services.
scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
channels.channel2 = Services.io.newChannel2("http://example2.com",
null,
null,
null, // aLoadingNode
Services.
scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
addMessageListener("proxyPrompter", function onMessage(msg) {
let args = [...msg.args];
@ -81,11 +80,6 @@ let prompterParent = runInParent(() => {
};
});
Cu.import("resource://gre/modules/Services.jsm");
let pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
let login1, login2A, login2B, login2C, login2D, login2E;
login1 = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
@ -113,12 +107,12 @@ let prompterParent = runInParent(() => {
login2E.init("http://example2.com", null, "http://example2.com",
"100%beef", "user3pass", "", "");
pwmgr.addLogin(login1);
pwmgr.addLogin(login2A);
pwmgr.addLogin(login2B);
pwmgr.addLogin(login2C);
pwmgr.addLogin(login2D);
pwmgr.addLogin(login2E);
Services.logins.addLogin(login1);
Services.logins.addLogin(login2A);
Services.logins.addLogin(login2B);
Services.logins.addLogin(login2C);
Services.logins.addLogin(login2D);
Services.logins.addLogin(login2E);
});
let prompter2 = new PrompterProxy(prompterParent);

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

@ -25,9 +25,6 @@ var isOk;
var mozproxy, proxiedHost = "http://mochi.test:8888";
var proxyChannel;
var systemPrincipal = SpecialPowers.Services.scriptSecurityManager.getSystemPrincipal();
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
var level = Ci.nsIAuthPrompt2.LEVEL_NONE;
@ -56,8 +53,7 @@ ok(promptFac != null, "promptFac getService()");
var prompter2 = promptFac.getPrompt(window, Ci.nsIAuthPrompt2);
function initLogins(pi) {
pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
pwmgr = SpecialPowers.Services.logins;
mozproxy = "moz-proxy://" + SpecialPowers.wrap(pi).host + ":" +
SpecialPowers.wrap(pi).port;
@ -102,33 +98,30 @@ var resolveCallback = SpecialPowers.wrapCallbackObject({
// The proxyChannel needs to move to at least on-modify-request to
// have valid ProxyInfo, but we use OnStartRequest during startup()
// for simplicity.
proxyChannel = ioService.newChannel2(proxiedHost,
null,
null,
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
proxyChannel = SpecialPowers.Services.io.newChannel2(proxiedHost,
null,
null,
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
proxyChannel.asyncOpen2(SpecialPowers.wrapCallbackObject(new proxyChannelListener()));
}
});
function startup() {
// Need to allow for arbitrary network servers defined in PAC instead of a hardcoded moz-proxy.
var ios = SpecialPowers.Cc["@mozilla.org/network/io-service;1"].
getService(SpecialPowers.Ci.nsIIOService);
var pps = SpecialPowers.Cc["@mozilla.org/network/protocol-proxy-service;1"].getService();
var channel = ios.newChannel2("http://example.com",
null,
null,
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = SpecialPowers.Services.io.newChannel2("http://example.com",
null,
null,
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
pps.asyncResolve(channel, 0, resolveCallback);
}
@ -180,7 +173,7 @@ add_task(async function test_autologin() {
// test proxy login (with autologin)
// Enable the autologin pref.
prefs.setBoolPref("signon.autologin.proxy", true);
SpecialPowers.Services.prefs.setBoolPref("signon.autologin.proxy", true);
proxyAuthinfo.username = "";
proxyAuthinfo.password = "";
@ -252,7 +245,7 @@ add_task(async function test_autologin_private() {
proxyAuthinfo.realm = "Proxy Realm";
proxyAuthinfo.flags = Ci.nsIAuthInformation.AUTH_PROXY;
prefs.clearUserPref("signon.autologin.proxy");
SpecialPowers.Services.prefs.clearUserPref("signon.autologin.proxy");
// XXX check for and kill popup notification??
// XXX check for checkbox / checkstate on old prompts?

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

@ -18,8 +18,7 @@ let pwmgrCommonScript = runInParent(SimpleTest.getTestFileURL("pwmgr_common.js")
let readyPromise = registerRunTests();
let chromeScript = runInParent(function chromeSetup() {
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
let pwmgr = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
let login1A = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
let login1B = Cc["@mozilla.org/login-manager/loginInfo;1"].
@ -39,9 +38,9 @@ let chromeScript = runInParent(function chromeSetup() {
login2B.init("http://mochi.test:8888", "http://username-focus-2", null,
"testuser2B", "testpass2B", "", "");
pwmgr.addLogin(login1A);
pwmgr.addLogin(login2A);
pwmgr.addLogin(login2B);
Services.logins.addLogin(login1A);
Services.logins.addLogin(login2A);
Services.logins.addLogin(login2B);
});
</script>

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

@ -47,10 +47,8 @@ var observer = SpecialPowers.wrapCallbackObject({
function getDialogDoc() {
// Find the <browser> which contains notifyWindow, by looking
// through all the open windows and all the <browsers> in each.
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
// var enumerator = wm.getEnumerator("navigator:browser");
var enumerator = wm.getXULWindowEnumerator(null);
// var enumerator = Services.wm.getEnumerator("navigator:browser");
var enumerator = Services.wm.getXULWindowEnumerator(null);
while (enumerator.hasMoreElements()) {
var win = enumerator.getNext();

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

@ -128,18 +128,14 @@ function doKey(aKey, modifier) {
* notifications might be confused by this.
*/
function commonInit(selfFilling) {
var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"].
getService(SpecialPowers.Ci.nsILoginManager);
ok(pwmgr != null, "Access LoginManager");
// Check that initial state has no logins
var logins = pwmgr.getAllLogins();
var logins = Services.logins.getAllLogins();
is(logins.length, 0, "Not expecting logins to be present");
var disabledHosts = pwmgr.getAllDisabledHosts();
var disabledHosts = Services.logins.getAllDisabledHosts();
if (disabledHosts.length) {
ok(false, "Warning: wasn't expecting disabled hosts to be present.");
for (var host of disabledHosts)
pwmgr.setLoginSavingEnabled(host, true);
Services.logins.setLoginSavingEnabled(host, true);
}
// Add a login that's used in multiple tests
@ -147,12 +143,12 @@ function commonInit(selfFilling) {
createInstance(SpecialPowers.Ci.nsILoginInfo);
login.init("http://mochi.test:8888", "http://mochi.test:8888", null,
"testuser", "testpass", "uname", "pword");
pwmgr.addLogin(login);
Services.logins.addLogin(login);
// Last sanity check
logins = pwmgr.getAllLogins();
logins = Services.logins.getAllLogins();
is(logins.length, 1, "Checking for successful init login");
disabledHosts = pwmgr.getAllDisabledHosts();
disabledHosts = Services.logins.getAllDisabledHosts();
is(disabledHosts.length, 0, "Checking for no disabled hosts");
if (selfFilling)

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

@ -17,6 +17,7 @@ commonInit();
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
// eslint-disable-next-line mozilla/use-services
var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
.getService(SpecialPowers.Ci.nsILoginManager);
var pwcrypt = SpecialPowers.Cc["@mozilla.org/login-manager/crypto/SDR;1"]
@ -305,4 +306,3 @@ window.addEventListener("runTests", startTest1);
</pre>
</body>
</html>

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

@ -14,12 +14,11 @@
const { NetUtil } = SpecialPowers.Cu.import("resource://gre/modules/NetUtil.jsm");
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
prefs.setIntPref("network.auth.subresource-http-auth-allow", 2);
Services.prefs.setIntPref("network.auth.subresource-http-auth-allow", 2);
// Class monitoring number of open dialog windows
// It checks there is always open just a single dialog per application
function dialogMonitor() {
// eslint-disable-next-line mozilla/use-services
var observerService = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
observerService.addObserver(this, "domwindowopened");
@ -57,6 +56,7 @@
},
shutdown() {
// eslint-disable-next-line mozilla/use-services
var observerService = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
observerService.removeObserver(this, "domwindowopened");
@ -74,6 +74,7 @@
var pwmgr, logins = [];
function initLogins(pi) {
// eslint-disable-next-line mozilla/use-services
pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
.getService(Ci.nsILoginManager);

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

@ -20,12 +20,9 @@ Login Manager test: XHR prompt
<script class="testbody" type="text/javascript">
/** Test for Login Manager: XHR prompts. **/
var pwmgr, login1, login2;
var login1, login2;
function initLogins() {
pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
login1 = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login2 = Cc["@mozilla.org/login-manager/loginInfo;1"].
@ -36,14 +33,14 @@ function initLogins() {
login2.init("http://mochi.test:8888", null, "xhr2",
"xhruser2", "xhrpass2", "", "");
pwmgr.addLogin(login1);
pwmgr.addLogin(login2);
Services.logins.addLogin(login1);
Services.logins.addLogin(login2);
}
function finishTest() {
ok(true, "finishTest removing testing logins...");
pwmgr.removeLogin(login1);
pwmgr.removeLogin(login2);
Services.logins.removeLogin(login1);
Services.logins.removeLogin(login2);
SimpleTest.finish();
}

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

@ -20,12 +20,9 @@ Login Manager test: XML prompt
<script class="testbody" type="text/javascript">
/** Test for Login Manager: XML prompts. **/
var pwmgr, login1, login2;
var login1, login2;
function initLogins() {
pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
.getService(Ci.nsILoginManager);
login1 = SpecialPowers.Cc["@mozilla.org/login-manager/loginInfo;1"]
.createInstance(Ci.nsILoginInfo);
login2 = SpecialPowers.Cc["@mozilla.org/login-manager/loginInfo;1"]
@ -36,8 +33,8 @@ function initLogins() {
login2.init("http://mochi.test:8888", null, "xml2",
"xmluser2", "xmlpass2", "", "");
pwmgr.addLogin(login1);
pwmgr.addLogin(login2);
Services.logins.addLogin(login1);
Services.logins.addLogin(login2);
}
function handleDialog(doc, testNum) {

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

@ -24,8 +24,8 @@ var servicesASTParser = {
result: {
"nsIPrefBranch": "prefs",
"nsIPrefService": "prefs",
"nsIXULRuntime": "appInfo",
"nsIXULAppInfo": "appInfo",
"nsIXULRuntime": "appinfo",
"nsIXULAppInfo": "appinfo",
"nsIDirectoryService": "dirsvc",
"nsIProperties": "dirsvc",
"nsIFrameScriptLoader": "mm",