Bug 1717703 Part 2 - Add test for printing with down-scaled page-size. r=dholbert
authorEmily McDonough <emcdonough@mozilla.com>
Fri, 16 Jul 2021 19:47:49 +0000
changeset 585751 f46839a3cf869168e295850f9fea9f854f2122c8
parent 585750 1a2bbe2775867a382f6c155c4a50e831e7cd039e
child 585752 b9eaa3a8709da4bd7e7f85ed971c1252fad9743f
push id38619
push usersmolnar@mozilla.com
push dateSat, 17 Jul 2021 09:36:16 +0000
treeherdermozilla-central@b02183638a54 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1717703
milestone92.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1717703 Part 2 - Add test for printing with down-scaled page-size. r=dholbert This test couldn't succeed without the fix for the clipping issue. Differential Revision: https://phabricator.services.mozilla.com/D119460
layout/base/tests/chrome/chrome.ini
layout/base/tests/chrome/print_page_size4.html
layout/base/tests/chrome/print_page_size4_ref.html
layout/base/tests/chrome/printpreview_helper.xhtml
--- a/layout/base/tests/chrome/chrome.ini
+++ b/layout/base/tests/chrome/chrome.ini
@@ -53,16 +53,18 @@ support-files =
   printpreview_prettyprint_ref.xhtml
   printpreview_mask.html
   print_page_size1.html
   print_page_size1_ref.html
   print_page_size2.html
   print_page_size2_ref.html
   print_page_size3.html
   print_page_size3_ref.html
+  print_page_size4.html
+  print_page_size4_ref.html
   color_adjust.html
   color_adjust_ref.html
   test_document_adopted_styles.html
   test_document_adopted_styles_ref.html
   test_shadow_root_adopted_styles.html
   test_shadow_root_adopted_styles_ref.html
   test_shared_adopted_styles.html
   test_shared_adopted_styles_ref.html
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/chrome/print_page_size4.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<style>
+@page {
+    size: 10in;
+    margin: 0;
+}
+div {
+    position: absolute;
+    background: blue;
+    width: 1in;
+    height: 1in;
+}
+.upper {
+    top: 0;
+}
+.lower{
+    bottom: 0;
+}
+.left{
+    left: 0;
+}
+.right{
+    right: 0;
+}
+</style>
+<body>
+<div class="upper left"></div>
+<div class="upper right"></div>
+<div class="lower left"></div>
+<div class="lower right"></div>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/chrome/print_page_size4_ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<style>
+@page {
+    size: 20in;
+    margin: 0;
+}
+div {
+    position: absolute;
+    background: blue;
+    width: 2in;
+    height: 2in;
+}
+.upper {
+    top: 0;
+}
+.lower{
+    bottom: 0;
+}
+.left{
+    left: 0;
+}
+.right{
+    right: 0;
+}
+</style>
+<body>
+<div class="upper left"></div>
+<div class="upper right"></div>
+<div class="lower left"></div>
+<div class="lower right"></div>
+</body>
--- a/layout/base/tests/chrome/printpreview_helper.xhtml
+++ b/layout/base/tests/chrome/printpreview_helper.xhtml
@@ -1250,16 +1250,30 @@ async function runTest43() {
 // the upper left corner, rather than scaling or centering the page.
 async function runTest44() {
   if (navigator.platform.includes("Mac")) {
     var fuzz = { maxDifferent: 15, maxDifference: 8 };
   }
   let test = "print_page_size3.html";
   let ref = "print_page_size3_ref.html";
   await compareFiles(test, ref, fuzz);
+  requestAnimationFrame(() => setTimeout(runTest45));
+}
+
+// Test that @page{ size: ... } results in scaling down the contents to fit on
+// a smaller paper size.
+// This depends on Firefox's current behavior of scaling oversized pages down
+// to fit onto the paper size.
+async function runTest45() {
+  if (navigator.platform.includes("Mac")) {
+    var fuzz = { maxDifferent: 15, maxDifference: 8 };
+  }
+  let test = "print_page_size4.html";
+  let ref = "print_page_size4_ref.html";
+  await compareFiles(test, ref, fuzz);
   finish();
 }
 
 ]]></script>
 <table style="border: 1px solid black;" xmlns="http://www.w3.org/1999/xhtml">
 <tr><th>Print preview canvas 1</th><th>Print preview canvas 2</th></tr>
 <tr>
 <td><canvas height="800" width="800"></canvas></td>