From 12323d993640612b08e70b01643c92e074886891 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Mon, 30 Sep 2019 18:15:23 +0000 Subject: [PATCH] Bug 1306266 - test for print preview using the right tab, r=mconley MozReview-Commit-ID: LLFmpPWwc5d UltraBlame original commit: 38485e7430ba0a2107ddbb617e027ac00a688813 --- browser/base/content/test/tabs/browser.ini | 2 ++ .../tabs/browser_tabSwitchPrintPreview.js | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 browser/base/content/test/tabs/browser_tabSwitchPrintPreview.js diff --git a/browser/base/content/test/tabs/browser.ini b/browser/base/content/test/tabs/browser.ini index dbe4997a49e0e..7771e0a6efb3f 100644 --- a/browser/base/content/test/tabs/browser.ini +++ b/browser/base/content/test/tabs/browser.ini @@ -1,2 +1,4 @@ [browser_tabSpinnerProbe.js] skip-if = !e10s # Tab spinner is e10s only. +[browser_tabSwitchPrintPreview.js] +skip-if = os == 'mac' 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 0000000000000..4565433979346 --- /dev/null +++ b/browser/base/content/test/tabs/browser_tabSwitchPrintPreview.js @@ -0,0 +1,23 @@ +const kURL1 = "data:text/html,Should I stay or should I go?"; +const kURL2 = "data:text/html,I shouldn't be here!"; + + + + + +add_task(function* () { + yield BrowserTestUtils.withNewTab(kURL1, function* (browser) { + let tab = gBrowser.addTab(kURL2); + document.getElementById("cmd_printPreview").doCommand(); + gBrowser.selectedTab = tab; + yield 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"); + PrintUtils.exitPrintPreview(); + yield BrowserTestUtils.waitForCondition(() => !gInPrintPreviewMode, "should be in print preview mode"); + yield BrowserTestUtils.removeTab(tab); + }); +});