scanner: discard Form instances with no classified inputs #574
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reviewer: @GioSensation (while @shakyShane is unavailable)
Asana: https://app.asana.com/0/1206682621538333/1207230997693280/f
Description
When encountering
<form/>
s with no fillable inputs, the Scanner and Form classes previously maintained MutationObservers for each<form/>
. This allowed the global MutationObserver to detect newly-added<input/>
s and attribute them to existing Form instances without having to create a new Form, but also meant we maintained observers and listeners that often went unused. For performance reasons, we stop processing<form/>
elements once 30 Form instances have been created. This allowed a large number of unfillable<form/>
s could consume the entire Form pool before an actually-fillable<form/>
is encountered.Immediately
destroy()
a Form instance that contains no fillable<input/>
s, and avoid adding that instance to a Scanner's set of known Form instances. This ensures form-scoped listeners and observers are only maintained when a fillable field is present. When a new<input/>
is added the global MutationObserver and Scanner create a new Form instance to manage it, enabling slightly lazier listener/observer initialization.Steps to test
npm run test
<form/>
elements).data-ddg-inputtype="credentials.username"
anddata-ddg-inputtype="credentials.password.current"
attributes