-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Credentials] Autofill when elements are in shadow #592
Conversation
16b8730
to
751dde1
Compare
751dde1
to
91c4a8f
Compare
eb1ad44
to
d2e4907
Compare
77ef0e3
to
366baaa
Compare
366baaa
to
6f2363e
Compare
eef0b68
to
99799e4
Compare
99799e4
to
2401665
Compare
c79a3ee
to
6c30306
Compare
6c30306
to
b321a1f
Compare
5fb9d91
to
6c543b6
Compare
My apologies, the slowdown was introduced in #574, not in this PR. It's good that we've worked through these improvements, but they were not the root cause. It's my bad, I'm sorry 😿. I haven't reviewed the updates, I'll leave that to @shakyShane or maybe I will have some time tomorrow. While I don't think we should address the slowdown in this PR, I think we should address it before cutting a new autofill release, otherwise we risk introducing performance issues to the clients. |
bd8d639
to
2ec91b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbajpeyi just a couple of tiny things, otherwise this is looking really good now.
@shakyShane All fixed here 2f8488c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work 💪 . Just a few minor things.
// If there are not form elements, we try to look for all | ||
// enclosed elements within the form. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comments should be moved 1 line below.
src/autofill-utils.js
Outdated
@@ -566,6 +566,34 @@ function getActiveElement (root = document) { | |||
return innerActiveElement | |||
} | |||
|
|||
/** | |||
* Takes a root element, creates a treewalker and finds all shadow elements that match the selector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be updated now to reflect the fact that we use querySelectorAll
first.
while (traversalLayerCount <= 5 && element.parentElement && element.parentElement !== document.documentElement) { | ||
while (traversalLayerCount <= 5 && element.parentElement !== document.documentElement) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite recall why we put this here, but I do think it had a purpose. Maybe both the parentElement
and the documentElement
can be null in certain weird cases. I would leave it alone unless we have reason to do otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GioSensation I've moved the condition under instead, that's why it's removed from here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right. My bad.
1d9e4e7
to
a01ca2f
Compare
Task/Issue URL: https://app.asana.com/0/1207920271697429/1207920271697429 Autofill Release: https://github.com/duckduckgo/duckduckgo-autofill/releases/tag/12.1.0 ## Description Updates Autofill to version [12.1.0](https://github.com/duckduckgo/duckduckgo-autofill/releases/tag/12.1.0). ### Autofill 12.1.0 release notes ## What's Changed * [Form] Skip autofilling select input if it was changed already by @dbajpeyi in duckduckgo/duckduckgo-autofill#580 * scanner: discard Form instances with no classified inputs by @sjbarag in duckduckgo/duckduckgo-autofill#574 * [Credentials] Autofill when elements are in shadow by @dbajpeyi in duckduckgo/duckduckgo-autofill#592 * Update password-related json files (2024-07-19) by @daxmobile in duckduckgo/duckduckgo-autofill#607 * [Scanner] Don't stop scanner fully on max forms by @dbajpeyi in duckduckgo/duckduckgo-autofill#617 * tests: remove spurious logging from unit tests by @sjbarag in duckduckgo/duckduckgo-autofill#575 * Add credit card test form failure by @GioSensation in duckduckgo/duckduckgo-autofill#588 ## New Contributors * @dbajpeyi made their first contribution in duckduckgo/duckduckgo-autofill#580 **Full Changelog**: duckduckgo/duckduckgo-autofill@12.0.1...12.1.0 ## Steps to test This release has been tested during autofill development. For smoke test steps see [this task](https://app.asana.com/0/1198964220583541/1200583647142330/f). Co-authored-by: GioSensation <1828326+GioSensation@users.noreply.github.com>
Reviewer: @shakyShane
Asana: https://app.asana.com/0/1200930669568058/1207793442006227/f
Description
Currently if a form contains elements that are within shadow root, the auto scanner misses out on all the elements of the form, and fails to categorize the inputs, although it does pierce through the shadow and find the hidden input element that was clicked on. This PR expands that a bit more:
getParentForm
),getParentForm
code was modified to traverse through the shadow boundary, and find the enclosing form element,findEligibleInputs
, which was also modified to find other related inputs in the form that are hidden.TLDR; This way essentially we do a two way scan - identify the clicked input which is in the shadow, traverse up the form and find the closest form and then build out the rest of the form from there.
Steps to test