mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-24 16:49:26 +01:00
autofill fixes
This commit is contained in:
parent
1fa96620a7
commit
8dbb2ece42
@ -345,9 +345,9 @@
|
||||
el.dispatchEvent(doEventOnElement(el, 'keyup'));
|
||||
event2.initEvent('input', true, true);
|
||||
el.dispatchEvent(event2);
|
||||
event.initEvent('change', true, true);
|
||||
event1.initEvent('change', true, true);
|
||||
el.dispatchEvent(event1);
|
||||
|
||||
el.dispatchEvent(event);
|
||||
el.blur();
|
||||
el.value !== elValue && (el.value = elValue);
|
||||
});
|
||||
|
@ -42,11 +42,11 @@ function initAutofill() {
|
||||
passwords.push(pf);
|
||||
|
||||
if (fillUsername) {
|
||||
username = findUsernameField(pageDetails, pf, false);
|
||||
username = findUsernameField(pageDetails, pf, false, false);
|
||||
|
||||
if (!username) {
|
||||
// not able to find any viewable username fields. maybe there are some "hidden" ones?
|
||||
username = findUsernameField(pageDetails, pf, true);
|
||||
username = findUsernameField(pageDetails, pf, true, false);
|
||||
}
|
||||
|
||||
if (username) {
|
||||
@ -64,11 +64,11 @@ function initAutofill() {
|
||||
passwords.push(pf);
|
||||
|
||||
if (fillUsername && pf.elementNumber > 0) {
|
||||
username = findUsernameFieldWithoutForm(pageDetails, pf, false);
|
||||
username = findUsernameField(pageDetails, pf, false, true);
|
||||
|
||||
if (!username) {
|
||||
// not able to find any viewable username fields. maybe there are some "hidden" ones?
|
||||
username = findUsernameFieldWithoutForm(pageDetails, pf, true);
|
||||
username = findUsernameField(pageDetails, pf, true, true);
|
||||
}
|
||||
|
||||
if (username) {
|
||||
@ -109,10 +109,10 @@ function initAutofill() {
|
||||
for (var i = 0; i < passwordFields.length; i++) {
|
||||
var pf = passwordFields[i];
|
||||
if (formKey === pf.form) {
|
||||
var uf = findUsernameField(pageDetails, pf, false);
|
||||
var uf = findUsernameField(pageDetails, pf, false, false);
|
||||
if (!uf) {
|
||||
// not able to find any viewable username fields. maybe there are some "hidden" ones?
|
||||
uf = findUsernameField(pageDetails, pf, true);
|
||||
uf = findUsernameField(pageDetails, pf, true, false);
|
||||
}
|
||||
|
||||
formData.push({
|
||||
@ -140,28 +140,16 @@ function initAutofill() {
|
||||
return arr;
|
||||
}
|
||||
|
||||
function findUsernameField(pageDetails, passwordField, canBeHidden) {
|
||||
for (var i = 0; i < pageDetails.fields.length; i++) {
|
||||
var f = pageDetails.fields[i];
|
||||
if (f.form === passwordField.form && (canBeHidden || f.viewable)
|
||||
&& (f.type === 'text' || f.type === 'email' || f.type === 'tel')
|
||||
&& f.elementNumber < passwordField.elementNumber) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function findUsernameFieldWithoutForm(pageDetails, passwordField, canBeHidden) {
|
||||
function findUsernameField(pageDetails, passwordField, canBeHidden, withoutForm) {
|
||||
var usernameField = null;
|
||||
for (var i = 0; i < pageDetails.fields.length; i++) {
|
||||
var f = pageDetails.fields[i];
|
||||
if (f.elementNumber > passwordField.elementNumber) {
|
||||
if (f.elementNumber >= passwordField.elementNumber) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((canBeHidden || f.viewable) && (f.type === 'text' || f.type === 'email' || f.type === 'tel')) {
|
||||
if ((withoutForm || f.form === passwordField.form) && (canBeHidden || f.viewable) &&
|
||||
(f.type === 'text' || f.type === 'email' || f.type === 'tel')) {
|
||||
usernameField = f;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user