summaryrefslogtreecommitdiffstats
path: root/layout/base/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /layout/base/tests
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/base/tests')
-rw-r--r--layout/base/tests/chrome/chrome.toml6
-rw-r--r--layout/base/tests/chrome/printpreview_helper.xhtml243
-rw-r--r--layout/base/tests/chrome/printpreview_scale_test_001.html21
-rw-r--r--layout/base/tests/chrome/printpreview_scale_test_001_ref.html20
-rw-r--r--layout/base/tests/chrome/printpreview_scale_test_002.html21
-rw-r--r--layout/base/tests/chrome/printpreview_scale_test_002_ref.html26
-rw-r--r--layout/base/tests/chrome/printpreview_scale_test_003.html21
-rw-r--r--layout/base/tests/chrome/printpreview_scale_test_003_ref.html21
-rw-r--r--layout/base/tests/chrome/test_bug420499.xhtml2
9 files changed, 380 insertions, 1 deletions
diff --git a/layout/base/tests/chrome/chrome.toml b/layout/base/tests/chrome/chrome.toml
index 6636b224e6..63e3da9609 100644
--- a/layout/base/tests/chrome/chrome.toml
+++ b/layout/base/tests/chrome/chrome.toml
@@ -66,6 +66,12 @@ support-files = [
"printpreview_pps16_ref.html",
"printpreview_prettyprint.xml",
"printpreview_prettyprint_ref.xhtml",
+ "printpreview_scale_test_001.html",
+ "printpreview_scale_test_001_ref.html",
+ "printpreview_scale_test_002.html",
+ "printpreview_scale_test_002_ref.html",
+ "printpreview_scale_test_003.html",
+ "printpreview_scale_test_003_ref.html",
"printpreview_mask.html",
"print_page_size1.html",
"print_page_size1_ref.html",
diff --git a/layout/base/tests/chrome/printpreview_helper.xhtml b/layout/base/tests/chrome/printpreview_helper.xhtml
index e40d2e4d5b..119c55d777 100644
--- a/layout/base/tests/chrome/printpreview_helper.xhtml
+++ b/layout/base/tests/chrome/printpreview_helper.xhtml
@@ -1708,9 +1708,252 @@ async function runTest58() {
let test = "printpreview_mixed_page_size_002.html";
// The params are just to give the file unique URLs.
await compareFiles(test + "?test", test + "?ref");
+ requestAnimationFrame(() => setTimeout(runTest59));
+}
+
+// Creates a data URL that has a single div of |divSize| em square, on a page
+// of size |pageSize| inches square.
+// |center| determines if the div should be centered horizontally.
+function createScalingTestSource(pageSize, center, name) {
+ // Styling always used.
+ let baseStyle = 'background: blue;';
+ if (center) {
+ baseStyle += 'margin: auto;';
+ }
+ const div = '<div style="width: 100px; height: 100px;' + baseStyle + '"></div>';
+ const style = '<style>@page{size:' + pageSize + 'in}body{margin:0}</style>';
+ // Add the name as a comment, to ensure every test has a unique source even
+ // if the parameters are identical.
+ const comment = '<!-- ' + name + ' -->';
+ return 'data:text/html,' + style + div + comment;
+}
+
+async function runScalingCenteredTest(refPageSize, testPageSize, paperSize,
+ name, center = true, fuzz = null) {
+ const printSettings = {
+ settings: {
+ paperWidth: paperSize,
+ paperHeight: paperSize,
+ paperSizeUnit: Ci.nsIPrintSettings.kPaperSizeInches,
+ marginTop: 0,
+ marginRight: 0,
+ marginBottom: 0,
+ marginLeft: 0,
+ unwriteableMarginTop: 0,
+ unwriteableMarginRight: 0,
+ unwriteableMarginBottom: 0,
+ unwriteableMarginLeft: 0,
+ }
+ };
+ let settings = Object.create(fuzz, {
+ ref: {value: printSettings},
+ test: {value: printSettings}
+ });
+ const testSrc = createScalingTestSource(testPageSize, center, name);
+ const refSrc = createScalingTestSource(refPageSize, center, name);
+ return compareFiles(testSrc, refSrc, settings);
+}
+
+// Tests that auto-detection and use of page centering.
+// Has a smaller page on a larger sheet, where the difference is within the
+// tolerance for auto-detection.
+async function runTest59() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["print.center_page_on_sheet", 2]]
+ });
+ // See bug 1680838
+ const fuzz = navigator.platform.includes("Win") ?
+ { maxDifferent: 180, maxDifference: 255 } :
+ null;
+ await runScalingCenteredTest(10, 9.5, 10, "runTest59", true, fuzz);
+ await SpecialPowers.popPrefEnv();
+ requestAnimationFrame(() => setTimeout(runTest60));
+}
+
+// Tests that centering won't occur when the pref disables it, using the same
+// values as runTest59.
+async function runTest60() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["print.center_page_on_sheet", 0]]
+ });
+ // See bug 1680838
+ const fuzz = navigator.platform.includes("Win") ?
+ { maxDifferent: 180, maxDifference: 255 } :
+ null;
+ await runScalingCenteredTest(10, 9.5, 10, "runTest60", false, fuzz);
+ await SpecialPowers.popPrefEnv();
+ requestAnimationFrame(() => setTimeout(runTest61));
+}
+
+// Tests that auto-detection will reject too big a difference for page
+// centering. Has a much smaller page on a larger sheet, where the difference
+// is outside the threshold for auto-detection.
+async function runTest61() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["print.center_page_on_sheet", 2]]
+ });
+ // See bug 1680838
+ const fuzz = navigator.platform.includes("Win") ?
+ { maxDifferent: 450, maxDifference: 255 } :
+ null;
+ await runScalingCenteredTest(10, 8.9, 10, "runTest61", false, fuzz);
+ await SpecialPowers.popPrefEnv();
+ requestAnimationFrame(() => setTimeout(runTest62));
+}
+
+// Tests that we can force page centering with the pref, using the same values
+// as runTest61.
+async function runTest62() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["print.center_page_on_sheet", 1]]
+ });
+ // See bug 1680838
+ const fuzz = navigator.platform.includes("Win") ?
+ { maxDifferent: 450, maxDifference: 255 } :
+ null;
+ await runScalingCenteredTest(10, 8.9, 10, "runTest62", true, fuzz);
+ await SpecialPowers.popPrefEnv();
+ requestAnimationFrame(() => setTimeout(runTest63));
+}
+
+// Tests that centering will always happen if the pref forces it.
+// The sizes used in these files are very large and the scale factor very high
+// here to ensure that any errors in the calculation for centering will be
+// magnified.
+async function runTest63() {
+ let test = "printpreview_scale_test_001.html";
+ let ref = "printpreview_scale_test_001_ref.html";
+
+ await SpecialPowers.pushPrefEnv({
+ set: [["print.center_page_on_sheet", 1]]
+ });
+ await compareFiles(test, ref, {
+ test: {
+ settings: {
+ paperWidth: 8.5,
+ paperHeight: 11,
+ paperSizeUnit: Ci.nsIPrintSettings.kPaperSizeInches,
+ marginTop: 0,
+ marginRight: 0,
+ marginBottom: 0,
+ marginLeft: 0,
+ unwriteableMarginTop: 0,
+ unwriteableMarginRight: 0,
+ unwriteableMarginBottom: 0,
+ unwriteableMarginLeft: 0,
+ },
+ },
+ ref: {
+ settings: {
+ paperWidth: 8.5,
+ paperHeight: 11,
+ paperSizeUnit: Ci.nsIPrintSettings.kPaperSizeInches,
+ marginTop: 0,
+ marginRight: 0,
+ marginBottom: 0,
+ marginLeft: 0,
+ unwriteableMarginTop: 0,
+ unwriteableMarginRight: 0,
+ unwriteableMarginBottom: 0,
+ unwriteableMarginLeft: 0,
+ },
+ },
+ });
+ await SpecialPowers.popPrefEnv();
+ requestAnimationFrame(() => setTimeout(runTest64));
+}
+
+// Tests that printing A4 pages on US Letter will be a close enough fit
+// that we will automatically center the page.
+async function runTest64() {
+ let test = "printpreview_scale_test_002.html";
+ let ref = "printpreview_scale_test_002_ref.html";
+
+ await SpecialPowers.pushPrefEnv({
+ set: [["print.center_page_on_sheet", 2]]
+ });
+ await compareFiles(test, ref, {
+ test: {
+ settings: {
+ paperWidth: 8.5,
+ paperHeight: 11,
+ paperSizeUnit: Ci.nsIPrintSettings.kPaperSizeInches,
+ marginTop: 0,
+ marginRight: 0,
+ marginBottom: 0,
+ marginLeft: 0,
+ unwriteableMarginTop: 0,
+ unwriteableMarginRight: 0,
+ unwriteableMarginBottom: 0,
+ unwriteableMarginLeft: 0,
+ },
+ },
+ ref: {
+ settings: {
+ paperWidth: 8.5,
+ paperHeight: 11,
+ paperSizeUnit: Ci.nsIPrintSettings.kPaperSizeInches,
+ marginTop: 0,
+ marginRight: 0,
+ marginBottom: 0,
+ marginLeft: 0,
+ unwriteableMarginTop: 0,
+ unwriteableMarginRight: 0,
+ unwriteableMarginBottom: 0,
+ unwriteableMarginLeft: 0,
+ },
+ },
+ });
+ await SpecialPowers.popPrefEnv();
+ requestAnimationFrame(() => setTimeout(runTest65));
+}
+
+// Tests that auto-detection will reject a large enough difference in width
+// when downscaling is used to make the page fit on the paper.
+async function runTest65() {
+ let test = "printpreview_scale_test_003.html";
+ let ref = "printpreview_scale_test_003_ref.html";
+
+ await SpecialPowers.pushPrefEnv({
+ set: [["print.center_page_on_sheet", 2]]
+ });
+ await compareFiles(test, ref, {
+ test: {
+ settings: {
+ paperWidth: 8.5,
+ paperHeight: 11,
+ paperSizeUnit: Ci.nsIPrintSettings.kPaperSizeInches,
+ marginTop: 0,
+ marginRight: 0,
+ marginBottom: 0,
+ marginLeft: 0,
+ unwriteableMarginTop: 0,
+ unwriteableMarginRight: 0,
+ unwriteableMarginBottom: 0,
+ unwriteableMarginLeft: 0,
+ },
+ },
+ ref: {
+ settings: {
+ paperWidth: 8.5,
+ paperHeight: 11,
+ paperSizeUnit: Ci.nsIPrintSettings.kPaperSizeInches,
+ marginTop: 0,
+ marginRight: 0,
+ marginBottom: 0,
+ marginLeft: 0,
+ unwriteableMarginTop: 0,
+ unwriteableMarginRight: 0,
+ unwriteableMarginBottom: 0,
+ unwriteableMarginLeft: 0,
+ },
+ },
+ });
+ await SpecialPowers.popPrefEnv();
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>
diff --git a/layout/base/tests/chrome/printpreview_scale_test_001.html b/layout/base/tests/chrome/printpreview_scale_test_001.html
new file mode 100644
index 0000000000..e9d3122b6b
--- /dev/null
+++ b/layout/base/tests/chrome/printpreview_scale_test_001.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<head>
+ <style>
+@page {
+ size: 10in 22in;
+ margin: 0;
+}
+body{
+ margin:0;
+}
+div{
+ width: 2in;
+ height: 2in;
+ background: blue;
+ margin-left: 4in;
+}
+ </style>
+</head>
+<body>
+ <div></div>
+</body>
diff --git a/layout/base/tests/chrome/printpreview_scale_test_001_ref.html b/layout/base/tests/chrome/printpreview_scale_test_001_ref.html
new file mode 100644
index 0000000000..2ed4571ef1
--- /dev/null
+++ b/layout/base/tests/chrome/printpreview_scale_test_001_ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<head>
+ <style>
+@page {
+ size: 4in 44in;
+ margin: 0;
+}
+body{
+ margin:0;
+}
+div{
+ height: 4in;
+ width: 4in;
+ background: blue;
+}
+ </style>
+</head>
+<body>
+ <div></div>
+</body>
diff --git a/layout/base/tests/chrome/printpreview_scale_test_002.html b/layout/base/tests/chrome/printpreview_scale_test_002.html
new file mode 100644
index 0000000000..94c35ab3c3
--- /dev/null
+++ b/layout/base/tests/chrome/printpreview_scale_test_002.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<head>
+ <style>
+@page {
+ size: A4;
+ margin: 0;
+}
+body{
+ margin:0;
+}
+div{
+ height: 200px;
+ width: 200px;
+ background: blue;
+ margin: auto;
+}
+ </style>
+</head>
+<body>
+ <div></div>
+</body>
diff --git a/layout/base/tests/chrome/printpreview_scale_test_002_ref.html b/layout/base/tests/chrome/printpreview_scale_test_002_ref.html
new file mode 100644
index 0000000000..d73de86fe5
--- /dev/null
+++ b/layout/base/tests/chrome/printpreview_scale_test_002_ref.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<head>
+ <style>
+@page {
+ size: letter;
+ margin: 0;
+}
+body{
+ margin:0;
+}
+div{
+ /* A4-on-letter requires a 0.9407 downscale. 11in = 279.4mm, and
+ * 279.4mm / 297mm = 0.9407407407..
+ * The unscaled reference case has a 200px square div, so reverse the scale
+ * to match that (rounding to 0.940741)
+ */
+ height: calc(0.940741 * 200px);
+ width: calc(0.940741 * 200px);
+ background: blue;
+ margin: auto;
+}
+ </style>
+</head>
+<body>
+ <div></div>
+</body>
diff --git a/layout/base/tests/chrome/printpreview_scale_test_003.html b/layout/base/tests/chrome/printpreview_scale_test_003.html
new file mode 100644
index 0000000000..2b1d68ff60
--- /dev/null
+++ b/layout/base/tests/chrome/printpreview_scale_test_003.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<head>
+ <style>
+@page {
+ size: 8.5in 13in;
+ margin: 0;
+}
+body{
+ margin:0;
+}
+div{
+ /* 13in / 11in = 1.1818181... */
+ height: calc(1.1818182 * 200px);
+ width: calc(1.1818182 * 200px);
+ background: blue;
+}
+ </style>
+</head>
+<body>
+ <div></div>
+</body>
diff --git a/layout/base/tests/chrome/printpreview_scale_test_003_ref.html b/layout/base/tests/chrome/printpreview_scale_test_003_ref.html
new file mode 100644
index 0000000000..41a3f87889
--- /dev/null
+++ b/layout/base/tests/chrome/printpreview_scale_test_003_ref.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<head>
+ <style>
+@page {
+ size: 8.5in 11in;
+ margin: 0;
+}
+body{
+ margin:0;
+}
+div{
+ /* 11in / 13in = 0.8461538 */
+ height: 200px;
+ width: 200px;
+ background: blue;
+}
+ </style>
+</head>
+<body>
+ <div></div>
+</body>
diff --git a/layout/base/tests/chrome/test_bug420499.xhtml b/layout/base/tests/chrome/test_bug420499.xhtml
index 22fefd7987..8db69ff6c1 100644
--- a/layout/base/tests/chrome/test_bug420499.xhtml
+++ b/layout/base/tests/chrome/test_bug420499.xhtml
@@ -84,7 +84,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=420499
function popupMenuShownHandler() {
window.removeEventListener("popupshown", popupMenuShownHandler);
- ok(!isCaretVisible(), "Caret shouldn't be visible when menu open");
+ ok(isCaretVisible(), "Caret shouldn't be visible when menu open");
window.addEventListener("popuphidden", ensureParagraphFocused);
$("menu").open = false;
}