summaryrefslogtreecommitdiffstats
path: root/toolkit/components/printing/tests
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/components/printing/tests
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/printing/tests')
-rw-r--r--toolkit/components/printing/tests/browser.ini2
-rw-r--r--toolkit/components/printing/tests/browser_page_change_print_original.js57
2 files changed, 59 insertions, 0 deletions
diff --git a/toolkit/components/printing/tests/browser.ini b/toolkit/components/printing/tests/browser.ini
new file mode 100644
index 000000000..88d6bb454
--- /dev/null
+++ b/toolkit/components/printing/tests/browser.ini
@@ -0,0 +1,2 @@
+[browser_page_change_print_original.js]
+skip-if = os == "mac"
diff --git a/toolkit/components/printing/tests/browser_page_change_print_original.js b/toolkit/components/printing/tests/browser_page_change_print_original.js
new file mode 100644
index 000000000..5990a486b
--- /dev/null
+++ b/toolkit/components/printing/tests/browser_page_change_print_original.js
@@ -0,0 +1,57 @@
+/**
+ * Verify that if the page contents change after print preview is initialized,
+ * and we re-initialize print preview (e.g. by changing page orientation),
+ * we still show (and will therefore print) the original contents.
+ */
+add_task(function* pp_after_orientation_change() {
+ const DATA_URI = `data:text/html,<script>window.onafterprint = function() { setTimeout("window.location = 'data:text/plain,REPLACED PAGE!'", 0); }</script><pre>INITIAL PAGE</pre>`;
+ // Can only do something if we have a print preview UI:
+ if (AppConstants.platform != "win" && AppConstants.platform != "linux") {
+ ok(true, "Can't test if there's no print preview.");
+ return;
+ }
+
+ // Ensure we get a browserStopped for this browser
+ let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, DATA_URI, false, true);
+ let browserToPrint = tab.linkedBrowser;
+ let ppBrowser = PrintPreviewListener.getPrintPreviewBrowser();
+
+ // Get a promise now that resolves when the original tab's location changes.
+ let originalTabNavigated = BrowserTestUtils.browserStopped(browserToPrint);
+
+ // Enter print preview:
+ let printPreviewEntered = BrowserTestUtils.waitForMessage(ppBrowser.messageManager, "Printing:Preview:Entered");
+ document.getElementById("cmd_printPreview").doCommand();
+ yield printPreviewEntered;
+
+ // Assert that we are showing the original page
+ yield ContentTask.spawn(ppBrowser, null, function* () {
+ is(content.document.body.textContent, "INITIAL PAGE", "Should have initial page print previewed.");
+ });
+
+ yield originalTabNavigated;
+
+ // Change orientation and wait for print preview to re-enter:
+ let orient = PrintUtils.getPrintSettings().orientation;
+ let orientToSwitchTo = orient != Ci.nsIPrintSettings.kPortraitOrientation ?
+ "portrait" : "landscape";
+ let printPreviewToolbar = document.querySelector("toolbar[printpreview=true]");
+
+ printPreviewEntered = BrowserTestUtils.waitForMessage(ppBrowser.messageManager, "Printing:Preview:Entered");
+ printPreviewToolbar.orient(orientToSwitchTo);
+ yield printPreviewEntered;
+
+ // Check that we're still showing the original page.
+ yield ContentTask.spawn(ppBrowser, null, function* () {
+ is(content.document.body.textContent, "INITIAL PAGE", "Should still have initial page print previewed.");
+ });
+
+ // Check that the other tab is definitely showing the new page:
+ yield ContentTask.spawn(browserToPrint, null, function* () {
+ is(content.document.body.textContent, "REPLACED PAGE!", "Original page should have changed.");
+ });
+
+ PrintUtils.exitPrintPreview();
+
+ yield BrowserTestUtils.removeTab(tab);
+});