Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Commit 65e5321

Browse files
committed
Fix password autofill on pages that delay form load
Some pages like https://securebanking.ally.com/#/login take a while to load the actual password form. Also ignores password fields that have zero size, which are probably false positives. Fix #2017 Auditors: @bbondy
1 parent 048ab24 commit 65e5321

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

app/extensions/brave/brave-default.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,26 @@ if (typeof KeyEvent === 'undefined') {
434434
return true
435435
}
436436

437+
function autofillPasswordListenerInit () {
438+
if (autofillPasswordListener() !== true) {
439+
// Some pages insert the password form into the DOM after it's loaded
440+
var observer = new MutationObserver(function (mutations) {
441+
mutations.forEach(function (mutation) {
442+
if (mutation.addedNodes.length) {
443+
if (autofillPasswordListener() === true) {
444+
observer.disconnect()
445+
}
446+
}
447+
})
448+
})
449+
observer.observe(document.documentElement, {
450+
childList: true
451+
})
452+
}
453+
}
454+
437455
// Fires when the page is loaded and the default pw manager is enabled
438-
ipcRenderer.on('autofill-password', autofillPasswordListener)
456+
ipcRenderer.on('autofill-password', autofillPasswordListenerInit)
439457

440458
/**
441459
* Gets form fields.
@@ -537,6 +555,10 @@ if (typeof KeyEvent === 'undefined') {
537555
}
538556
}
539557
var passwordNodes = Array.from(form.querySelectorAll('input[type=password]'))
558+
// Skip nodes that are invisible
559+
passwordNodes = passwordNodes.filter((e) => {
560+
return (e instanceof HTMLInputElement && e.clientHeight > 0 && e.clientWidth > 0)
561+
})
540562
if (isSubmission) {
541563
// Skip empty fields
542564
passwordNodes = passwordNodes.filter((e) => { return (e instanceof HTMLInputElement && e.value) })

0 commit comments

Comments
 (0)