1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-22 11:45:59 +01:00
The browser extension vault (Chrome, Firefox, Opera, Edge, Safari, & more).
Go to file
Rafael Kraut 208be8dfbf
[PS-1918] Make autofill doc-scanner traverse into ShadowRoot (#4119)
* This commit implements the following main changes:

- Query elements by using a TreeWalker instead of `document.querySelector[All]`. The reason for this is that `querySelector[All]` doesn't traverse into elements with ShadowRoot.
- Recursively traverse into elements with `openOrClosedShadowRoot` or `Element.shadowRoot` (depending on browser support) inside TreeWalker loop.
- Use new query logic everywhere inside `autofill.js`. This also means we need to use filter functions to find elements with specific nodeNames and/or attributes instead of CSS selector strings.
- Add two new `instanceof Element` checks to prevent `Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'." errors`.

This change is fully backward compatible. If `openOrClosedShadowRoot` is not available it will always return undefined and we will never traverse into ShadowRoots just as the behavior was before this change.

* refactor: outsource recursive logic to accumulatingQueryDocAll

We don't want the `els` argument on the `queryDocAll` function because it's never used from outside the function itself. Thus the recursive logic is moved to `accumulatingQueryDocAll`.
Now `queryDocAll` creates an empty array and passes it to `accumulatingQueryDocAll` which recursively walks the document and all ShadowRoots and pushes all found nodes directly to the referenced array.

The decision to use a directly mutated array instead of `Array.concat(els)` or `Array.push(...els)` is for performance reasons. Pushing to the referenced array was 74% faster than using `Array.push` with spread operator and even 90% faster than using `Array.concat`.

Co-authored-by: Chad Miller <64046472+chadm-sq@users.noreply.github.com>

* refactor: extract input field relevance check into own function

Addresses CodeScene analysis violation "Bumpy Road Ahead" where conditional logic is checked for a nesting of 2 or deeper.

* refactor: use proper element attribute handling

- use el.type attribute instead of el.attribute.type on input elements. This makes sure we also get 'text' when type attribute is not explicitly specified
- use el.htmlFor attribute instead of el.attribute.for on label elements
- use `hasAttribute` and `getAttribute` methods instead of `attributes[]` which is discouraged by https://quirksmode.org/dom/core/#attributes
- improve readability of `isRelevantInputField`

---------

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
Co-authored-by: Chad Miller <64046472+chadm-sq@users.noreply.github.com>
Co-authored-by: Thomas Rittson <trittson@bitwarden.com>
2023-02-20 08:43:18 +10:00
.github Add temporary QA ACR (#4790) 2023-02-17 09:36:53 -06:00
.husky Make husky hook executable (#2900) 2022-06-14 07:26:50 +02:00
.storybook [SM-43] create product-switcher (#4189) 2022-12-21 16:50:41 -05:00
.vscode Add eslint-plugin-rxjs & rxjs-angular (#3373) 2022-08-26 18:09:28 +02:00
apps [PS-1918] Make autofill doc-scanner traverse into ShadowRoot (#4119) 2023-02-20 08:43:18 +10:00
bitwarden_license Defect/SG-1083 - Fix SSO Form Validation (#4791) 2023-02-17 16:55:57 -05:00
libs Defect/SG-1083 - Fix SSO Form Validation (#4791) 2023-02-17 16:55:57 -05:00
.editorconfig Add support for migrated jslib (#2826) 2022-06-03 18:01:07 +02:00
.eslintignore Auth/ps 2298 reorg auth (#4564) 2023-02-06 15:53:37 -06:00
.eslintrc.json [EC-1051] Add TailwindCSS linting rules (#4605) 2023-02-03 07:27:08 +10:00
.git-blame-ignore-revs Add support for migrated jslib (#2826) 2022-06-03 18:01:07 +02:00
.gitattributes Apply Prettier (#2238) 2021-12-21 15:43:35 +01:00
.gitignore Upload and process test results as an artifact and report (#4435) 2023-01-11 09:01:02 -05:00
.nvmrc [EC-184] Desktop cleanup (#2553) 2022-05-05 19:03:56 +02:00
.prettierignore Auth/ps 2298 reorg auth (#4564) 2023-02-06 15:53:37 -06:00
.prettierrc.json [EC-183] Move eslint and prettier to project root (#2536) 2022-05-03 21:45:37 +02:00
angular.json Disable Angular Usage Analytics & Storybook Telemetry (#3903) 2022-10-27 12:22:33 -04:00
clients.code-workspace Override eslint config for vscode workspace (#4566) 2023-01-26 14:26:21 +01:00
CONTRIBUTING.md Update README and CONTRIBUTING to point to contributing.bitwarden.com (#2771) 2022-06-13 17:34:07 +10:00
jest.config.js Upload and process test results as an artifact and report (#4435) 2023-01-11 09:01:02 -05:00
LICENSE_BITWARDEN.txt Update LICENSE_BITWARDEN.txt (#3505) 2022-09-13 09:04:36 -04:00
LICENSE_GPL.txt Prepare bitwarden_license directory (#2663) 2022-05-09 17:50:15 +02:00
LICENSE.txt Prepare bitwarden_license directory (#2663) 2022-05-09 17:50:15 +02:00
package-lock.json Bumped desktop version to 2023.2.1 (#4801) 2023-02-17 20:44:54 +00:00
package.json Add type check to npm scripts (#4631) 2023-02-06 13:40:00 -06:00
README.md Remove migration details from the readme (#4780) 2023-02-16 16:11:38 +01:00
SECURITY.md Revise language on SECURITY.md 2022-03-15 15:39:14 -04:00
tailwind.config.js SM-310 [] Secrets (#3355) 2022-12-09 11:21:07 +01:00
tsconfig.eslint.json [SM-329] Merge libs/electron into desktop (#3989) 2022-12-02 12:45:09 +01:00
tsconfig.json SM-310 [] Secrets (#3355) 2022-12-09 11:21:07 +01:00

Bitwarden

Github Workflow browser build on master Github Workflow CLI build on master Github Workflow desktop build on master Github Workflow web build on master gitter chat


Bitwarden Client Applications

This repository houses all Bitwarden client applications except the Mobile application.

Please refer to the Clients section of the Contributing Documentation for build instructions, recommended tooling, code style tips, and lots of other great information to get you started.

We're Hiring!

Interested in contributing in a big way? Consider joining our team! We're hiring for many positions. Please take a look at our Careers page to see what opportunities are currently open as well as what it's like to work at Bitwarden.

Contribute

Code contributions are welcome! Please commit any pull requests against the master branch. Learn more about how to contribute by reading the Contributing Guidelines. Check out the Contributing Documentation for how to get started with your first contribution.

Security audits and feedback are welcome. Please open an issue or email us privately if the report is sensitive in nature. You can read our security policy in the SECURITY.md file.