Closed Bug 2085050 Opened 1 month ago Closed 27 days ago

Fire button: the "Leave page?" prompt is hidden behind the clear browsing data dialog when deleting history

Categories

(Toolkit :: Data Sanitization, defect)

defect

Tracking

()

RESOLVED FIXED
161 Branch
Tracking Status
firefox161 --- fixed

People

(Reporter: jleritte, Assigned: jleritte)

References

Details

Attachments

(1 external file)

Found by QA on Nightly 160.0a1 (2026-10-22), Windows 11 and macOS 26.

Prerequisites:

  • browser.fireButton.enabled = true
  • browser.fireButton.flow = "direct" (for ease of testing)

Steps to reproduce:

  1. Open a page that asks for confirmation before leaving, e.g. a form with unsaved input. QA used: MDN
  2. Type something in the field.
  3. Click the fire button. In the dialog, make sure "Browsing & download history" is checked, so the browser has to close and reopen its windows.
  4. Click "Delete".

Expected result:
The page asks for confirmation to leave, and the prompt is visible and usable, either above the dialog or after it closes.

Actual result:
The "Leave page?" prompt is hidden behind the clear browsing data dialog. The dialog shows "Clearing…" with its buttons disabled, so it can't be used either. Only Esc closes it.

Cause:
The fire button opens the dialog as a window-modal dialog, which covers the page. When history is checked, the clear includes openWindows, which calls CanCloseWindow() and so permitUnload() for each tab before closing the windows. The page's beforeunload prompt is tab-modal, so it opens inside the page area, under the window-modal dialog. Meanwhile sanitize() in sanitizeDialog.js keeps the dialog open with its buttons disabled until the clear finishes.

The "Choose…" path of the panel flow uses the same dialog and should be affected too. "Delete all" in the panel is not, because the panel closes before the windows are closed.

Proposed fix:
When the clear includes openWindows, close the dialog before closing the windows, so the prompt shows over the page as it does for "Delete all". If the user stays on the page, nothing is deleted and the flow records the existing aborted outcome.

The cause in comment 0 checks out, and the fix needs one more step than proposed. sanitize() in sanitizeDialog.js calls Sanitizer.sanitize() from inside the dialogaccept handler. Nothing in Sanitizer.sys.mjs awaits before openWindows.clear calls CanCloseWindow(), so permitUnload runs while the window-modal dialog is still up, and just letting the dialog close on accept would not fix it.

Fix: When openWindows is included, have the dialog write its items and options into its args and close without calling preventDefault(). Sanitizer.showUI then awaits gDialogBox.open() and runs Sanitizer.sanitize() itself, catching the rejection when a page refuses to close. This is how ResetProfile.sys.mjs runs its reset, and the existing sanitizer-sanitization-complete observer in CustomizableWidgets.sys.mjs still records aborted. testCloseWindowsWithHistory in browser_sanitizeDialog_v2.js should then wait on the stubbed sanitize call rather than the dialog's unload, and should assert that the dialog is closed when the call happens.

Suggested severity: S3. The prompt is unreachable only for fire-button users with history checked on a page that has a beforeunload handler, the feature is still behind a pref, and Esc gets out of it.


If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
If you want to categorize your feedback you can add one of the following tags: ai-triage-{wrong-file, wrong-cause, hallucination, out-of-scope, not-a-bug, wrong-fix, shallow-fix, wrong-severity}.

Needinfo hackbot@mozilla.tld to have a patch generated for this bug, include any questions or directions as needed in your comment.

Closing the windows asks each page whether it can be unloaded. A page's beforeunload prompt is tab-modal, so it opened behind the window-modal dialog, which sat disabled in its clearing state until Esc dismissed it. When the clear closes the windows, the dialog now closes first and Sanitizer.showUI starts the clear once it is gone, so the prompt shows over the page.

Severity: -- → S3
Attachment #9666803 - Attachment description: Bug 2085050 - Close the clear browsing data dialog before the fire button closes the windows. r?#anti-tracking → Bug 2085050 - Keep the windows open when deleting browsing data from the fire button's dialog. r?#anti-tracking
Pushed by jleritte@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/fcfcac40a41c https://hg.mozilla.org/integration/autoland/rev/8892c2498672 Keep the windows open when deleting browsing data from the fire button's dialog. r=bvandersloot
Status: ASSIGNED → RESOLVED
Closed: 27 days ago
Resolution: --- → FIXED
Target Milestone: --- → 161 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: