Skip to content

Commit

Permalink
[PM-15943] - When filling a password, the extension flickers (#12900)
Browse files Browse the repository at this point in the history
* use requestAnimationFrame instead of arbitrary timeout

* fix failing test
  • Loading branch information
jaasen-livefront authored Jan 23, 2025
1 parent dbb1639 commit 362745a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ describe("VaultPopupAutofillService", () => {

it("should close popup after a timeout for chromium browsers", async () => {
mockPlatformUtilsService.isFirefox.mockReturnValue(false);
jest.spyOn(global, "setTimeout");
jest.spyOn(global, "requestAnimationFrame");
await service.doAutofill(mockCipher);
jest.advanceTimersByTime(50);
expect(setTimeout).toHaveBeenCalledTimes(1);
expect(requestAnimationFrame).toHaveBeenCalled();
expect(BrowserApi.closePopup).toHaveBeenCalled();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class VaultPopupAutofillService {
}

// Slight delay to fix bug in Chromium browsers where popup closes without copying totp to clipboard
setTimeout(() => BrowserApi.closePopup(window), 50);
requestAnimationFrame(() => BrowserApi.closePopup(window));
}

/**
Expand Down

0 comments on commit 362745a

Please sign in to comment.