1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-06 09:20:43 +01:00

autofill fixes

This commit is contained in:
Kyle Spearrin 2017-09-22 15:11:30 -04:00
parent 19621accaa
commit 5089cbded6
2 changed files with 20 additions and 14 deletions

View File

@ -682,7 +682,7 @@ var bg_isBackground = true,
return; return;
} }
chrome.tabs.sendMessage(tab.id, { command: 'collectPageDetails', tab: tab }, function () { chrome.tabs.sendMessage(tab.id, { command: 'collectPageDetails', tab: tab, sender: 'contextMenu' }, function () {
}); });
}); });
} }

View File

@ -129,7 +129,8 @@ function initAutofill() {
// No password fields on this page. Let's try to just fuzzy fill the username. // No password fields on this page. Let's try to just fuzzy fill the username.
for (i = 0; i < pageDetails.fields.length; i++) { for (i = 0; i < pageDetails.fields.length; i++) {
var f = pageDetails.fields[i]; var f = pageDetails.fields[i];
if (f.type === 'text' || f.type === 'email' || f.type === 'tel' && fieldIsFuzzyMatch(f, usernameFieldNames)) { if ((f.type === 'text' || f.type === 'email' || f.type === 'tel') &&
fieldIsFuzzyMatch(f, usernameFieldNames)) {
usernames.push(f); usernames.push(f);
} }
} }
@ -199,7 +200,8 @@ function initAutofill() {
AutofillService.prototype.doAutoFill = function (login, pageDetails, fromBackground, skipTotp, skipLastUsed) { AutofillService.prototype.doAutoFill = function (login, pageDetails, fromBackground, skipTotp, skipLastUsed) {
var deferred = Q.defer(); var deferred = Q.defer();
var self = this; var self = this,
totpPromise = null;
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var tab = null; var tab = null;
@ -228,6 +230,7 @@ function initAutofill() {
password: login.password, password: login.password,
fields: login.fields fields: login.fields
}); });
if (!fillScript || !fillScript.script || !fillScript.script.length) { if (!fillScript || !fillScript.script || !fillScript.script.length) {
continue; continue;
} }
@ -242,13 +245,12 @@ function initAutofill() {
fillScript: fillScript fillScript: fillScript
}, { frameId: pageDetails[i].frameId }); }, { frameId: pageDetails[i].frameId });
if ((fromBackground && self.utilsService.isFirefox()) || if (totpPromise || (fromBackground && self.utilsService.isFirefox()) ||
skipTotp || !login.totp || !self.tokenService.getPremium()) { skipTotp || !login.totp || !self.tokenService.getPremium()) {
deferred.resolve(); continue;
return;
} }
self.totpService.isAutoCopyEnabled().then(function (enabled) { totpPromise = self.totpService.isAutoCopyEnabled().then(function (enabled) {
if (enabled) { if (enabled) {
return self.totpService.getCode(login.totp); return self.totpService.getCode(login.totp);
} }
@ -258,17 +260,21 @@ function initAutofill() {
if (code) { if (code) {
self.utilsService.copyToClipboard(code); self.utilsService.copyToClipboard(code);
} }
deferred.resolve();
return;
}); });
break;
} }
if (!didAutofill) { if (didAutofill) {
if (totpPromise) {
totpPromise.then(function () {
deferred.resolve();
});
}
else {
deferred.resolve();
}
}
else {
deferred.reject(); deferred.reject();
return;
} }
}); });