Skip to content

Commit 591dcc0

Browse files
committed
fix: tap export password only once
1 parent 399ce49 commit 591dcc0

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

injected/integration-test/autofill-password-import.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ResultsCollector } from './page-objects/results-collector.js';
55
const HTML = '/autofill-password-import/index.html';
66
const CONFIG = './integration-test/test-pages/autofill-password-import/config/config.json';
77

8-
test('Password import feature', async ({ page }, testInfo) => {
8+
test.only('Password import feature', async ({ page }, testInfo) => {
99
const collector = ResultsCollector.create(page, testInfo.project.use);
1010
await collector.load(HTML, CONFIG);
1111

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

+28-16
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 {Set<string>} */
55+
#animatedPaths = new Set();
56+
5357
/**
5458
* @returns {ButtonAnimationStyle}
5559
*/
@@ -136,31 +140,34 @@ export default class AutofillPasswordImport extends ContentFeature {
136140
const element = await this.findSettingsElement();
137141
return element != null
138142
? {
139-
animationStyle: this.settingsButtonAnimationStyle,
140-
element,
141-
shouldTap: this.#settingsButtonSettings?.shouldAutotap ?? false,
142-
shouldWatchForRemoval: false,
143-
}
143+
animationStyle: this.settingsButtonAnimationStyle,
144+
element,
145+
shouldTap: this.#settingsButtonSettings?.shouldAutotap ?? false,
146+
shouldWatchForRemoval: false,
147+
tapOnce: false,
148+
}
144149
: null;
145150
} else if (path === '/options') {
146151
const element = await this.findExportElement();
147152
return element != null
148153
? {
149-
animationStyle: this.exportButtonAnimationStyle,
150-
element,
151-
shouldTap: this.#exportButtonSettings?.shouldAutotap ?? false,
152-
shouldWatchForRemoval: true,
153-
}
154+
animationStyle: this.exportButtonAnimationStyle,
155+
element,
156+
shouldTap: this.#exportButtonSettings?.shouldAutotap ?? false,
157+
shouldWatchForRemoval: true,
158+
tapOnce: true,
159+
}
154160
: null;
155161
} else if (path === '/intro') {
156162
const element = await this.findSignInButton();
157163
return element != null
158164
? {
159-
animationStyle: this.signInButtonAnimationStyle,
160-
element,
161-
shouldTap: this.#signInButtonSettings?.shouldAutotap ?? false,
162-
shouldWatchForRemoval: false,
163-
}
165+
animationStyle: this.signInButtonAnimationStyle,
166+
element,
167+
shouldTap: this.#signInButtonSettings?.shouldAutotap ?? false,
168+
shouldWatchForRemoval: false,
169+
tapOnce: false,
170+
}
164171
: null;
165172
} else {
166173
return null;
@@ -398,7 +405,12 @@ export default class AutofillPasswordImport extends ContentFeature {
398405
if (this.isSupportedPath(path)) {
399406
try {
400407
this.setCurrentElementConfig(await this.getElementAndStyleFromPath(path));
401-
await this.animateOrTapElement();
408+
if (!this.#animatedPaths.has(path)) {
409+
await this.animateOrTapElement();
410+
if (this.currentElementConfig?.shouldTap && this.currentElementConfig?.tapOnce) {
411+
this.#animatedPaths.add(path);
412+
}
413+
}
402414
} catch {
403415
console.error('password-import: failed for path:', path);
404416
}

0 commit comments

Comments
 (0)