tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit c650ba3ca5944be470bbf84054dbbe8185982889
parent 6da8bb3379fe0cd214fb7a1f68e0dc5b00f5a678
Author: David P. <daparks@mozilla.com>
Date:   Wed, 29 Oct 2025 18:10:33 +0000

Bug 1942939: Fix browser_empty_name_beforeunload_test r=profiles-reviewers,cdupuis,mossop

* Sets dom.require_user_interaction_for_beforeunload" to false.
* Waits for profile card init (which adds the beforeunload event handler)
  before unloading.
* dialogMgr.dialogs is actually dialogMgr._dialogs.

Differential Revision: https://phabricator.services.mozilla.com/D270428

Diffstat:
Mbrowser/components/profiles/tests/browser/browser.toml | 5-----
Mbrowser/components/profiles/tests/browser/browser_empty_name_beforeunload_test.js | 26+++++++++++++++++++++++---
2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/browser/components/profiles/tests/browser/browser.toml b/browser/components/profiles/tests/browser/browser.toml @@ -41,11 +41,6 @@ skip-if = [ ] ["browser_empty_name_beforeunload_test.js"] -skip-if = [ - "os == 'linux' && os_version == '24.04' && processor == 'x86_64'", # Bug 1942939 - "os == 'win' && os_version == '11.26100' && processor == 'x86_64' && debug", # Bug 1942939 - "os == 'win' && os_version == '11.26100' && processor == 'x86' && debug", # Bug 1942939 -] ["browser_menubar_profiles.js"] head = "../unit/head.js head.js" diff --git a/browser/components/profiles/tests/browser/browser_empty_name_beforeunload_test.js b/browser/components/profiles/tests/browser/browser_empty_name_beforeunload_test.js @@ -5,7 +5,10 @@ add_setup(async () => { await SpecialPowers.pushPrefEnv({ - set: [["test.wait300msAfterTabSwitch", true]], + set: [ + ["dom.require_user_interaction_for_beforeunload", false], + ["test.wait300msAfterTabSwitch", true], + ], }); await initGroupDatabase(); @@ -34,17 +37,34 @@ const resetGlean = async () => { }; const launchDialog = async tab => { + // Wait for the profile card to be displayed before unloading so that + // the beforeunload listener is already attached. + info("Awaiting profile card initialization"); + await SpecialPowers.spawn(tab.linkedBrowser, [], async () => { + let profileCard = + content.document.querySelector("new-profile-card") || + content.document.querySelector("edit-profile-card"); + let profileCardObject = profileCard.wrappedJSObject; + + await ContentTaskUtils.waitForCondition( + () => profileCardObject.initialized, + "Waiting for new-profile-card to be initialized" + ); + }); + // Note: we manually trigger the dialog, rather than using PromptTestUtils, // because we want to assert on the contents of the dialog. tab.linkedBrowser.asyncPermitUnload(); + info("Issued asyncPermitUnload"); + let dialogMgr = gBrowser .getTabDialogBox(tab.linkedBrowser) .getContentDialogManager(); await BrowserTestUtils.waitForCondition( - () => dialogMgr.dialogs.length, + () => dialogMgr._dialogs.length, "Waiting for the beforeunload dialog to be displayed" ); - let dialog = dialogMgr.dialogs[0]; + let dialog = dialogMgr._dialogs[0]; await dialog._dialogReady; return dialog; };