Bug 1374997 Part 2: Add check to ensure we switch back to original tab after print preview. r=Gijs

This commit is contained in:
Bob Owen 2017-06-21 15:03:31 +01:00
Родитель 82095a15a7
Коммит 1e2e90c347
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -4,9 +4,11 @@ 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 BrowserTestUtils.withNewTab(kURL1, async function(browser) {
let originalTab = gBrowser.selectedTab;
let tab = BrowserTestUtils.addTab(gBrowser, kURL2);
document.getElementById("cmd_printPreview").doCommand();
gBrowser.selectedTab = tab;
@ -16,8 +18,10 @@ add_task(async function() {
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");
PrintUtils.exitPrintPreview();
await BrowserTestUtils.waitForCondition(() => !gInPrintPreviewMode, "should be in print preview mode");
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");
await BrowserTestUtils.removeTab(tab);
});
});