diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /browser/base/content/test/tabs/browser_tabSwitchPrintPreview.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/tabs/browser_tabSwitchPrintPreview.js')
-rw-r--r-- | browser/base/content/test/tabs/browser_tabSwitchPrintPreview.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/browser/base/content/test/tabs/browser_tabSwitchPrintPreview.js b/browser/base/content/test/tabs/browser_tabSwitchPrintPreview.js new file mode 100644 index 0000000000..8b9e47461f --- /dev/null +++ b/browser/base/content/test/tabs/browser_tabSwitchPrintPreview.js @@ -0,0 +1,58 @@ +const kURL1 = "data:text/html,Should I stay or should I go?"; +const kURL2 = "data:text/html,I shouldn't be here!"; + +/** + * Verify that if we open a new tab and try to make it the selected tab while + * print preview is up, that doesn't happen. + * Also check that we switch back to the original tab on exiting Print Preview. + */ +add_task(async function() { + await SpecialPowers.pushPrefEnv({ + set: [["print.tab_modal.enabled", false]], + }); + await BrowserTestUtils.withNewTab(kURL1, async function(browser) { + let originalTab = gBrowser.selectedTab; + let tab = BrowserTestUtils.addTab(gBrowser, kURL2); + document.getElementById("cmd_printPreview").doCommand(); + gBrowser.selectedTab = tab; + await BrowserTestUtils.waitForCondition( + () => gInPrintPreviewMode, + "should be in print preview mode" + ); + isnot( + gBrowser.selectedTab, + tab, + "Selected tab should not be the tab we added" + ); + is( + gBrowser.selectedTab, + PrintPreviewListener._printPreviewTab, + "Selected tab should be the print preview tab" + ); + gBrowser.selectedTab = tab; + isnot( + gBrowser.selectedTab, + tab, + "Selected tab should still not be the tab we added" + ); + is( + gBrowser.selectedTab, + PrintPreviewListener._printPreviewTab, + "Selected tab should still be the print preview tab" + ); + let tabSwitched = BrowserTestUtils.switchTab(gBrowser, () => { + PrintUtils.exitPrintPreview(); + }); + await BrowserTestUtils.waitForCondition( + () => !gInPrintPreviewMode, + "should no longer be in print preview mode" + ); + await tabSwitched; + is( + gBrowser.selectedTab, + originalTab, + "Selected tab should be back to the original tab that we print previewed" + ); + BrowserTestUtils.removeTab(tab); + }); +}); |