forked from mirrors/gecko-dev
Bug 1754759 - remove modal state from tab when moving to new window a=diannaS
Original Revision: https://phabricator.services.mozilla.com/D213156 Differential Revision: https://phabricator.services.mozilla.com/D221145
This commit is contained in:
parent
2e8adc0829
commit
e4920fdb82
4 changed files with 64 additions and 3 deletions
|
|
@ -158,9 +158,22 @@ export class PromptParent extends JSWindowActorParent {
|
|||
throw new Error("Cannot open a prompt in a hidden window");
|
||||
}
|
||||
|
||||
let swappedBrowser;
|
||||
let cancelEventController = new AbortController();
|
||||
let cancelEventSignal = cancelEventController.signal;
|
||||
try {
|
||||
if (browser) {
|
||||
browser.enterModalState();
|
||||
// If this tab gets moved to a new window, we will need
|
||||
// to leave the modal state on the new browser, so
|
||||
// keep track of the new browser.
|
||||
browser.addEventListener(
|
||||
"EndSwapDocShells",
|
||||
event => {
|
||||
swappedBrowser = event.detail;
|
||||
},
|
||||
{ signal: cancelEventSignal }
|
||||
);
|
||||
lazy.PromptUtils.fireDialogEvent(
|
||||
win,
|
||||
"DOMWillOpenModalDialog",
|
||||
|
|
@ -261,12 +274,16 @@ export class PromptParent extends JSWindowActorParent {
|
|||
|
||||
lazy.PromptUtils.propBagToObject(bag, args);
|
||||
} finally {
|
||||
if (browser) {
|
||||
browser.maybeLeaveModalState();
|
||||
cancelEventController.abort();
|
||||
// If this tab has been moved to a new window, make sure
|
||||
// to leave the modal state on the new browser.
|
||||
let currentBrowser = swappedBrowser ?? browser;
|
||||
if (currentBrowser) {
|
||||
currentBrowser.maybeLeaveModalState();
|
||||
lazy.PromptUtils.fireDialogEvent(
|
||||
win,
|
||||
"DOMModalDialogClosed",
|
||||
browser,
|
||||
currentBrowser,
|
||||
this.getClosingEventDetail(args)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -291,6 +291,9 @@ skip-if = [
|
|||
|
||||
["browser_replacewithwindow_commands.js"]
|
||||
|
||||
["browser_replacewithwindow_dialog.js"]
|
||||
support-files = ["tab_that_opens_dialog.html"]
|
||||
|
||||
["browser_switch_by_scrolling.js"]
|
||||
|
||||
["browser_tabCloseProbes.js"]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// This test verifies that when a tab is dragged out to a
|
||||
// new window, the tab is not in a modal state (bug 1754759)
|
||||
add_task(async function () {
|
||||
let tab1 = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
"https://www.example.com"
|
||||
);
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
"https://example.com/browser/browser/components/tabbrowser/test/browser/tabs/tab_that_opens_dialog.html"
|
||||
);
|
||||
|
||||
let delayedStartupPromise = BrowserTestUtils.waitForNewWindow();
|
||||
let win = gBrowser.replaceTabWithWindow(tab2);
|
||||
await delayedStartupPromise;
|
||||
|
||||
await SpecialPowers.spawn(win.gBrowser.selectedBrowser, [], () => {
|
||||
ok(
|
||||
!content.windowUtils.isInModalState(),
|
||||
"content should not be in modal state"
|
||||
);
|
||||
});
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
BrowserTestUtils.removeTab(tab1);
|
||||
});
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Dummy test page</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"></meta>
|
||||
</head>
|
||||
<body>
|
||||
<h1>This has an alert dialog</h2>
|
||||
<script>
|
||||
setTimeout(() => alert("An alert dialog"), 0);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue