mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1134850 - Move password manager recipes to its own file. r=MattN
This commit is contained in:
parent
b654859375
commit
8ac8e0da38
@ -3962,6 +3962,7 @@ pref("signon.autologin.proxy", false);
|
||||
pref("signon.storeWhenAutocompleteOff", true);
|
||||
pref("signon.ui.experimental", false);
|
||||
pref("signon.debug", false);
|
||||
pref("signon.recipes.path", "chrome://passwordmgr/content/recipes.json");
|
||||
|
||||
// Satchel (Form Manager) prefs
|
||||
pref("browser.formfill.debug", false);
|
||||
|
@ -152,7 +152,9 @@ var LoginManagerParent = {
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "recipeParentPromise", () => {
|
||||
const { LoginRecipesParent } = Cu.import("resource://gre/modules/LoginRecipes.jsm", {});
|
||||
this._recipeManager = new LoginRecipesParent();
|
||||
this._recipeManager = new LoginRecipesParent({
|
||||
defaults: Services.prefs.getComplexValue("signon.recipes.path", Ci.nsISupportsString).data,
|
||||
});
|
||||
return this._recipeManager.initializationPromise;
|
||||
});
|
||||
|
||||
@ -274,22 +276,30 @@ var LoginManagerParent = {
|
||||
}
|
||||
|
||||
if (!showMasterPassword && !Services.logins.isLoggedIn) {
|
||||
target.sendAsyncMessage("RemoteLogins:loginsFound", {
|
||||
requestId: requestId,
|
||||
logins: [],
|
||||
recipes,
|
||||
});
|
||||
try {
|
||||
target.sendAsyncMessage("RemoteLogins:loginsFound", {
|
||||
requestId: requestId,
|
||||
logins: [],
|
||||
recipes,
|
||||
});
|
||||
} catch (e) {
|
||||
log("error sending message to target", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let allLoginsCount = Services.logins.countLogins(formOrigin, "", null);
|
||||
// If there are no logins for this site, bail out now.
|
||||
if (!allLoginsCount) {
|
||||
target.sendAsyncMessage("RemoteLogins:loginsFound", {
|
||||
requestId: requestId,
|
||||
logins: [],
|
||||
recipes,
|
||||
});
|
||||
try {
|
||||
target.sendAsyncMessage("RemoteLogins:loginsFound", {
|
||||
requestId: requestId,
|
||||
logins: [],
|
||||
recipes,
|
||||
});
|
||||
} catch (e) {
|
||||
log("error sending message to target", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ const SUPPORTED_KEYS = REQUIRED_KEYS.concat(OPTIONAL_KEYS);
|
||||
|
||||
Cu.importGlobalProperties(["URL"]);
|
||||
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
@ -27,9 +28,11 @@ XPCOMUtils.defineLazyGetter(this, "log", () => LoginHelper.createLogger("LoginRe
|
||||
* calling methods on the object.
|
||||
*
|
||||
* @constructor
|
||||
* @param {boolean} [aOptions.defaults=true] whether to load default application recipes.
|
||||
*/
|
||||
function LoginRecipesParent(aOptions = { defaults: true }) {
|
||||
* @param {String} [aOptions.defaults=null] the URI to load the recipes from.
|
||||
* If it's null, nothing is loaded.
|
||||
*
|
||||
*/
|
||||
function LoginRecipesParent(aOptions = { defaults: null }) {
|
||||
if (Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
|
||||
throw new Error("LoginRecipesParent should only be used from the main process");
|
||||
}
|
||||
@ -88,10 +91,29 @@ LoginRecipesParent.prototype = {
|
||||
this._recipesByHost = new Map();
|
||||
|
||||
if (this._defaults) {
|
||||
// XXX: Bug 1134850 will handle reading recipes from a file.
|
||||
this.initializationPromise = this.load(DEFAULT_RECIPES).then(resolve => {
|
||||
return this;
|
||||
});
|
||||
let channel = NetUtil.newChannel({uri: NetUtil.newURI(this._defaults, "UTF-8"),
|
||||
loadUsingSystemPrincipal: true});
|
||||
channel.contentType = "application/json";
|
||||
|
||||
try {
|
||||
this.initializationPromise = new Promise(function(resolve) {
|
||||
NetUtil.asyncFetch(channel, function (stream, result) {
|
||||
if (!Components.isSuccessCode(result)) {
|
||||
throw new Error("Error fetching recipe file:" + result);
|
||||
return;
|
||||
}
|
||||
let count = stream.available();
|
||||
let data = NetUtil.readInputStreamToString(stream, count, { charset: "UTF-8" });
|
||||
resolve(JSON.parse(data));
|
||||
});
|
||||
}).then(recipes => {
|
||||
return this.load(recipes);
|
||||
}).then(resolve => {
|
||||
return this;
|
||||
});
|
||||
} catch (e) {
|
||||
throw new Error("Error reading recipe file:" + e);
|
||||
}
|
||||
} else {
|
||||
this.initializationPromise = Promise.resolve(this);
|
||||
}
|
||||
@ -237,23 +259,3 @@ let LoginRecipesContent = {
|
||||
return field;
|
||||
},
|
||||
};
|
||||
|
||||
const DEFAULT_RECIPES = {
|
||||
"siteRecipes": [
|
||||
{
|
||||
"description": "okta uses a hidden password field to disable filling",
|
||||
"hosts": ["mozilla.okta.com"],
|
||||
"passwordSelector": "#pass-signin"
|
||||
},
|
||||
{
|
||||
"description": "anthem uses a hidden password and username field to disable filling",
|
||||
"hosts": ["www.anthem.com"],
|
||||
"passwordSelector": "#LoginContent_txtLoginPass"
|
||||
},
|
||||
{
|
||||
"description": "An ephemeral password-shim field is incorrectly selected as the username field.",
|
||||
"hosts": ["www.discover.com"],
|
||||
"usernameSelector": "#login-account"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
19
toolkit/components/passwordmgr/content/recipes.json
Normal file
19
toolkit/components/passwordmgr/content/recipes.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"siteRecipes": [
|
||||
{
|
||||
"description": "okta uses a hidden password field to disable filling",
|
||||
"hosts": ["mozilla.okta.com"],
|
||||
"passwordSelector": "#pass-signin"
|
||||
},
|
||||
{
|
||||
"description": "anthem uses a hidden password and username field to disable filling",
|
||||
"hosts": ["www.anthem.com"],
|
||||
"passwordSelector": "#LoginContent_txtLoginPass"
|
||||
},
|
||||
{
|
||||
"description": "An ephemeral password-shim field is incorrectly selected as the username field.",
|
||||
"hosts": ["www.discover.com"],
|
||||
"usernameSelector": "#login-account"
|
||||
}
|
||||
]
|
||||
}
|
@ -10,3 +10,4 @@ toolkit.jar:
|
||||
* content/passwordmgr/passwordManagerExceptions.js (content/passwordManagerExceptions.js)
|
||||
content/passwordmgr/passwordManagerExceptions.xul (content/passwordManagerExceptions.xul)
|
||||
content/passwordmgr/passwordManagerCommon.js (content/passwordManagerCommon.js)
|
||||
content/passwordmgr/recipes.json (content/recipes.json)
|
||||
|
@ -120,7 +120,7 @@ function newPropertyBag(aProperties)
|
||||
|
||||
const RecipeHelpers = {
|
||||
initNewParent() {
|
||||
return (new LoginRecipesParent({ defaults: false })).initializationPromise;
|
||||
return (new LoginRecipesParent({ defaults: null })).initializationPromise;
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
"use strict";
|
||||
|
||||
add_task(function* test_init() {
|
||||
let parent = new LoginRecipesParent({ defaults: false });
|
||||
let parent = new LoginRecipesParent({ defaults: null });
|
||||
let initPromise1 = parent.initializationPromise;
|
||||
let initPromise2 = parent.initializationPromise;
|
||||
Assert.strictEqual(initPromise1, initPromise2, "Check that the same promise is returned");
|
||||
|
Loading…
Reference in New Issue
Block a user