summaryrefslogtreecommitdiffstats
path: root/toolkit/components/passwordmgr/test/browser/browser_doorhanger_replace_dismissed_with_visible_while_opening.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/components/passwordmgr/test/browser/browser_doorhanger_replace_dismissed_with_visible_while_opening.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/passwordmgr/test/browser/browser_doorhanger_replace_dismissed_with_visible_while_opening.js')
-rw-r--r--toolkit/components/passwordmgr/test/browser/browser_doorhanger_replace_dismissed_with_visible_while_opening.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/toolkit/components/passwordmgr/test/browser/browser_doorhanger_replace_dismissed_with_visible_while_opening.js b/toolkit/components/passwordmgr/test/browser/browser_doorhanger_replace_dismissed_with_visible_while_opening.js
new file mode 100644
index 0000000000..401e0add1b
--- /dev/null
+++ b/toolkit/components/passwordmgr/test/browser/browser_doorhanger_replace_dismissed_with_visible_while_opening.js
@@ -0,0 +1,65 @@
+/**
+ * Replacing a dismissed doorhanger with a visible one while it's opening.
+ *
+ * There are various races between popup notification callbacks to catch with this.
+ * This can happen in the real world by blurring an edited login field by clicking on the login doorhanger.
+ */
+
+XPCOMUtils.defineLazyServiceGetter(
+ this,
+ "prompterSvc",
+ "@mozilla.org/login-manager/prompter;1",
+ Ci.nsILoginManagerPrompter
+);
+
+add_task(async function test_replaceDismissedWithVisibleWhileOpening() {
+ await BrowserTestUtils.withNewTab(
+ {
+ gBrowser,
+ url: "https://example.com",
+ },
+ async function load(browser) {
+ info("Show a dismissed save doorhanger");
+ prompterSvc.promptToSavePassword(
+ browser,
+ LoginTestUtils.testData.formLogin({}),
+ true,
+ false,
+ null
+ );
+ let doorhanger = await waitForDoorhanger(browser, "password-save");
+ Assert.ok(doorhanger, "Got doorhanger");
+ EventUtils.synthesizeMouseAtCenter(doorhanger.anchorElement, {});
+ await BrowserTestUtils.waitForEvent(
+ PopupNotifications.panel,
+ "popupshowing"
+ );
+ await checkDoorhangerUsernamePassword("the username", "the password");
+ info(
+ "Replace the doorhanger with a non-dismissed one immediately after clicking to open"
+ );
+ prompterSvc.promptToSavePassword(
+ browser,
+ LoginTestUtils.testData.formLogin({}),
+ true,
+ false,
+ null
+ );
+ await Promise.race([
+ BrowserTestUtils.waitForCondition(() => {
+ if (
+ document.getElementById("password-notification-username").value !=
+ "the username" ||
+ document.getElementById("password-notification-password").value !=
+ "the password"
+ ) {
+ return Promise.reject("Field changed to incorrect values");
+ }
+ return false;
+ }, "See if username/password values change to incorrect values"),
+ // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
+ new Promise(resolve => setTimeout(resolve, 1000)),
+ ]);
+ }
+ );
+});