зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1548381 - Password Generation Autocomplete Result. r=sfoster
Differential Revision: https://phabricator.services.mozilla.com/D31209 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
52ce0df40b
Коммит
1b820e86b4
|
@ -139,6 +139,17 @@ class LoginAutocompleteItem extends AutocompleteItem {
|
|||
}
|
||||
}
|
||||
|
||||
class GeneratedPasswordAutocompleteItem extends AutocompleteItem {
|
||||
constructor(generatedPassword) {
|
||||
super("generatedPassword");
|
||||
this.value = generatedPassword;
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "label", () => {
|
||||
return getLocalizedString("useGeneratedPassword");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class LoginsFooterAutocompleteItem extends AutocompleteItem {
|
||||
constructor(hostname) {
|
||||
super("loginsFooter");
|
||||
|
@ -153,6 +164,7 @@ class LoginsFooterAutocompleteItem extends AutocompleteItem {
|
|||
|
||||
// nsIAutoCompleteResult implementation
|
||||
function LoginAutoCompleteResult(aSearchString, matchingLogins, {
|
||||
generatedPassword,
|
||||
isSecure,
|
||||
messageManager,
|
||||
isPasswordField,
|
||||
|
@ -173,7 +185,8 @@ function LoginAutoCompleteResult(aSearchString, matchingLogins, {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!matchingLogins.length && isPasswordField && formFillController.passwordPopupAutomaticallyOpened) {
|
||||
if (!matchingLogins.length && !generatedPassword && isPasswordField
|
||||
&& formFillController.passwordPopupAutomaticallyOpened) {
|
||||
hidingFooterOnPWFieldAutoOpened = true;
|
||||
log.debug("Hiding footer: no logins and the popup was opened upon focus of the pw. field");
|
||||
return false;
|
||||
|
@ -205,6 +218,9 @@ function LoginAutoCompleteResult(aSearchString, matchingLogins, {
|
|||
|
||||
// The footer comes last if it's enabled
|
||||
if (isFooterEnabled()) {
|
||||
if (generatedPassword) {
|
||||
this._rows.push(new GeneratedPasswordAutocompleteItem(generatedPassword));
|
||||
}
|
||||
this._rows.push(new LoginsFooterAutocompleteItem(hostname));
|
||||
}
|
||||
|
||||
|
@ -342,7 +358,11 @@ LoginAutoComplete.prototype = {
|
|||
let isPasswordField = aElement.type == "password";
|
||||
let hostname = aElement.ownerDocument.documentURIObject.host;
|
||||
|
||||
let completeSearch = (autoCompleteLookupPromise, { logins, messageManager }) => {
|
||||
let completeSearch = (autoCompleteLookupPromise, {
|
||||
generatedPassword,
|
||||
logins,
|
||||
messageManager,
|
||||
}) => {
|
||||
// If the search was canceled before we got our
|
||||
// results, don't bother reporting them.
|
||||
if (this._autoCompleteLookupPromise !== autoCompleteLookupPromise) {
|
||||
|
@ -351,6 +371,7 @@ LoginAutoComplete.prototype = {
|
|||
|
||||
this._autoCompleteLookupPromise = null;
|
||||
let results = new LoginAutoCompleteResult(aSearchString, logins, {
|
||||
generatedPassword,
|
||||
messageManager,
|
||||
isSecure,
|
||||
isPasswordField,
|
||||
|
|
|
@ -293,7 +293,11 @@ var LoginManagerContent = {
|
|||
let loginsFound = LoginHelper.vanillaObjectsToLogins(msg.data.logins);
|
||||
let messageManager = msg.target;
|
||||
let request = this._takeRequest(msg);
|
||||
request.promise.resolve({ logins: loginsFound, messageManager });
|
||||
request.promise.resolve({
|
||||
generatedPassword: msg.data.generatedPassword,
|
||||
logins: loginsFound,
|
||||
messageManager,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ var nsLoginInfo = Components.Constructor("@mozilla.org/login-manager/loginInfo;1
|
|||
Ci.nsILoginInfo, "init");
|
||||
|
||||
const PREF_INSECURE_FIELD_WARNING_ENABLED = "security.insecure_field_warning.contextual.enabled";
|
||||
const PREF_INSECURE_AUTOFILLFORMS_ENABLED = "signon.autofillForms.http";
|
||||
|
||||
let matchingLogins = [];
|
||||
matchingLogins.push(new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
|
||||
|
@ -30,7 +29,6 @@ const LABEL_NO_USERNAME = "No username (" + time + ")";
|
|||
let expectedResults = [
|
||||
{
|
||||
insecureFieldWarningEnabled: true,
|
||||
insecureAutoFillFormsEnabled: true,
|
||||
isSecure: true,
|
||||
isPasswordField: false,
|
||||
matchingLogins,
|
||||
|
@ -62,7 +60,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: true,
|
||||
insecureAutoFillFormsEnabled: true,
|
||||
isSecure: false,
|
||||
isPasswordField: false,
|
||||
matchingLogins: [],
|
||||
|
@ -78,7 +75,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: true,
|
||||
insecureAutoFillFormsEnabled: true,
|
||||
isSecure: false,
|
||||
isPasswordField: false,
|
||||
matchingLogins,
|
||||
|
@ -114,7 +110,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: true,
|
||||
insecureAutoFillFormsEnabled: true,
|
||||
isSecure: true,
|
||||
isPasswordField: true,
|
||||
matchingLogins,
|
||||
|
@ -146,7 +141,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: true,
|
||||
insecureAutoFillFormsEnabled: true,
|
||||
isSecure: false,
|
||||
isPasswordField: true,
|
||||
matchingLogins,
|
||||
|
@ -182,7 +176,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: false,
|
||||
insecureAutoFillFormsEnabled: true,
|
||||
isSecure: true,
|
||||
isPasswordField: false,
|
||||
matchingLogins,
|
||||
|
@ -214,7 +207,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: false,
|
||||
insecureAutoFillFormsEnabled: true,
|
||||
isSecure: false,
|
||||
isPasswordField: false,
|
||||
matchingLogins,
|
||||
|
@ -246,7 +238,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: false,
|
||||
insecureAutoFillFormsEnabled: true,
|
||||
isSecure: true,
|
||||
isPasswordField: true,
|
||||
matchingLogins,
|
||||
|
@ -278,7 +269,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: false,
|
||||
insecureAutoFillFormsEnabled: true,
|
||||
isSecure: false,
|
||||
isPasswordField: true,
|
||||
matchingLogins,
|
||||
|
@ -310,7 +300,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: true,
|
||||
insecureAutoFillFormsEnabled: false,
|
||||
isSecure: true,
|
||||
isPasswordField: false,
|
||||
matchingLogins,
|
||||
|
@ -342,7 +331,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: true,
|
||||
insecureAutoFillFormsEnabled: false,
|
||||
isSecure: false,
|
||||
isPasswordField: false,
|
||||
matchingLogins,
|
||||
|
@ -378,7 +366,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: true,
|
||||
insecureAutoFillFormsEnabled: false,
|
||||
isSecure: true,
|
||||
isPasswordField: true,
|
||||
matchingLogins,
|
||||
|
@ -410,7 +397,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: true,
|
||||
insecureAutoFillFormsEnabled: false,
|
||||
isSecure: false,
|
||||
isPasswordField: true,
|
||||
matchingLogins,
|
||||
|
@ -446,7 +432,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: false,
|
||||
insecureAutoFillFormsEnabled: false,
|
||||
isSecure: true,
|
||||
isPasswordField: false,
|
||||
matchingLogins,
|
||||
|
@ -478,7 +463,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: false,
|
||||
insecureAutoFillFormsEnabled: false,
|
||||
isSecure: false,
|
||||
isPasswordField: false,
|
||||
matchingLogins: [],
|
||||
|
@ -490,7 +474,18 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: false,
|
||||
insecureAutoFillFormsEnabled: false,
|
||||
isSecure: false,
|
||||
isPasswordField: false,
|
||||
matchingLogins: [],
|
||||
searchString: "foo",
|
||||
items: [{
|
||||
value: "",
|
||||
label: "View Saved Logins",
|
||||
style: "loginsFooter",
|
||||
}],
|
||||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: false,
|
||||
isSecure: false,
|
||||
isPasswordField: false,
|
||||
matchingLogins,
|
||||
|
@ -522,7 +517,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: false,
|
||||
insecureAutoFillFormsEnabled: false,
|
||||
isSecure: true,
|
||||
isPasswordField: true,
|
||||
matchingLogins,
|
||||
|
@ -554,7 +548,6 @@ let expectedResults = [
|
|||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: false,
|
||||
insecureAutoFillFormsEnabled: false,
|
||||
isSecure: false,
|
||||
isPasswordField: true,
|
||||
matchingLogins,
|
||||
|
@ -584,6 +577,50 @@ let expectedResults = [
|
|||
style: "loginsFooter",
|
||||
}],
|
||||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: true,
|
||||
isSecure: true,
|
||||
isPasswordField: true,
|
||||
matchingLogins: [],
|
||||
items: [{
|
||||
value: "",
|
||||
label: "View Saved Logins",
|
||||
style: "loginsFooter",
|
||||
}],
|
||||
},
|
||||
{
|
||||
insecureFieldWarningEnabled: true,
|
||||
isSecure: true,
|
||||
isPasswordField: true,
|
||||
matchingLogins: [],
|
||||
searchString: "foo",
|
||||
items: [],
|
||||
},
|
||||
{
|
||||
generatedPassword: "9ljgfd4shyktb45",
|
||||
insecureFieldWarningEnabled: true,
|
||||
isSecure: true,
|
||||
isPasswordField: true,
|
||||
matchingLogins: [],
|
||||
items: [{
|
||||
value: "9ljgfd4shyktb45",
|
||||
label: "Use Generated Password",
|
||||
style: "generatedPassword",
|
||||
}, {
|
||||
value: "",
|
||||
label: "View Saved Logins",
|
||||
style: "loginsFooter",
|
||||
}],
|
||||
},
|
||||
{
|
||||
generatedPassword: "9ljgfd4shyktb45",
|
||||
insecureFieldWarningEnabled: true,
|
||||
isSecure: true,
|
||||
isPasswordField: true,
|
||||
matchingLogins: [],
|
||||
searchString: "9ljgfd4shyktb45",
|
||||
items: [],
|
||||
},
|
||||
];
|
||||
|
||||
add_task(async function test_all_patterns() {
|
||||
|
@ -595,9 +632,8 @@ add_task(async function test_all_patterns() {
|
|||
info(JSON.stringify(pattern, null, 2));
|
||||
Services.prefs.setBoolPref(PREF_INSECURE_FIELD_WARNING_ENABLED,
|
||||
pattern.insecureFieldWarningEnabled);
|
||||
Services.prefs.setBoolPref(PREF_INSECURE_AUTOFILLFORMS_ENABLED,
|
||||
pattern.insecureAutoFillFormsEnabled);
|
||||
let actual = new LoginAutoCompleteResult("", pattern.matchingLogins, {
|
||||
let actual = new LoginAutoCompleteResult(pattern.searchString || "", pattern.matchingLogins, {
|
||||
generatedPassword: pattern.generatedPassword,
|
||||
isSecure: pattern.isSecure,
|
||||
isPasswordField: pattern.isPasswordField,
|
||||
});
|
||||
|
|
|
@ -45,6 +45,10 @@ userSelectText2 = Select which login to update:
|
|||
removeLoginPrompt=Are you sure you wish to remove this login?
|
||||
removeLoginTitle=Remove login
|
||||
loginsDescriptionAll2=Logins for the following sites are stored on your computer
|
||||
|
||||
# LOCALIZATION NOTE (useGeneratedPassword):
|
||||
# Shown in the autocomplete popup to allow filling a generated password into a password field.
|
||||
useGeneratedPassword=Use Generated Password
|
||||
# LOCALIZATION NOTE (loginHostAge):
|
||||
# This is used to show the context menu login items with their age.
|
||||
# 1st string is the username for the login, 2nd is the login's age.
|
||||
|
@ -52,6 +56,7 @@ loginHostAge=%1$S (%2$S)
|
|||
# LOCALIZATION NOTE (noUsername):
|
||||
# String is used on the context menu when a login doesn't have a username.
|
||||
noUsername=No username
|
||||
|
||||
duplicateLoginTitle=Login already exists
|
||||
duplicateLogin=A duplicate login already exists.
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче