Skip to content

Commit 2f9b8fd

Browse files
authored
[Autofill password import] animate export password only once (#1400)
* fix: tap export password only once * test: remove only * fix: allow both highlight and tapping * Revert "fix: allow both highlight and tapping" This reverts commit c22b05d. * style: use weaksets
1 parent a418217 commit 2f9b8fd

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

injected/integration-test/test-pages/autofill-password-import/config/config.json

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"value": {
1818
"settingsButton": {
1919
"shouldAutotap": false,
20+
"tapOnce": false,
2021
"path": "/",
2122
"selectors": [
2223
"a[href*='options']"
@@ -27,6 +28,7 @@
2728
},
2829
"exportButton": {
2930
"shouldAutotap": false,
31+
"tapOnce": false,
3032
"path": "/options",
3133
"selectors": [
3234
"c-wiz[data-node-index*='2;0'][data-p*='options']",
@@ -38,6 +40,7 @@
3840
},
3941
"signInButton": {
4042
"shouldAutotap": false,
43+
"tapOnce": false,
4144
"path": "/intro",
4245
"selectors": [
4346
"a[href*='ServiceLogin']:not([target='_top'])",

injected/src/features/autofill-password-import.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const DELAY_BEFORE_ANIMATION = 300;
2323
* @property {ButtonAnimationStyle} animationStyle
2424
* @property {boolean} shouldTap
2525
* @property {boolean} shouldWatchForRemoval
26+
* @property {boolean} tapOnce
2627
*/
2728

2829
/**
@@ -50,6 +51,9 @@ export default class AutofillPasswordImport extends ContentFeature {
5051

5152
#domLoaded;
5253

54+
/** @type {WeakSet<Element>} */
55+
#tappedElements = new WeakSet();
56+
5357
/**
5458
* @returns {ButtonAnimationStyle}
5559
*/
@@ -140,6 +144,7 @@ export default class AutofillPasswordImport extends ContentFeature {
140144
element,
141145
shouldTap: this.#settingsButtonSettings?.shouldAutotap ?? false,
142146
shouldWatchForRemoval: false,
147+
tapOnce: false,
143148
}
144149
: null;
145150
} else if (path === '/options') {
@@ -150,6 +155,7 @@ export default class AutofillPasswordImport extends ContentFeature {
150155
element,
151156
shouldTap: this.#exportButtonSettings?.shouldAutotap ?? false,
152157
shouldWatchForRemoval: true,
158+
tapOnce: true,
153159
}
154160
: null;
155161
} else if (path === '/intro') {
@@ -160,6 +166,7 @@ export default class AutofillPasswordImport extends ContentFeature {
160166
element,
161167
shouldTap: this.#signInButtonSettings?.shouldAutotap ?? false,
162168
shouldWatchForRemoval: false,
169+
tapOnce: false,
163170
}
164171
: null;
165172
} else {
@@ -176,6 +183,9 @@ export default class AutofillPasswordImport extends ContentFeature {
176183
this.currentOverlay.remove();
177184
this.currentOverlay = null;
178185
document.removeEventListener('scroll', this);
186+
if (this.currentElementConfig?.element) {
187+
this.#tappedElements.delete(this.currentElementConfig?.element);
188+
}
179189
}
180190
}
181191

@@ -398,7 +408,12 @@ export default class AutofillPasswordImport extends ContentFeature {
398408
if (this.isSupportedPath(path)) {
399409
try {
400410
this.setCurrentElementConfig(await this.getElementAndStyleFromPath(path));
401-
await this.animateOrTapElement();
411+
if (this.currentElementConfig?.element && !this.#tappedElements.has(this.currentElementConfig?.element)) {
412+
await this.animateOrTapElement();
413+
if (this.currentElementConfig?.shouldTap && this.currentElementConfig?.tapOnce) {
414+
this.#tappedElements.add(this.currentElementConfig.element);
415+
}
416+
}
402417
} catch {
403418
console.error('password-import: failed for path:', path);
404419
}

0 commit comments

Comments
 (0)