From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- layout/base/tests/chrome/chrome.toml | 6 + layout/base/tests/chrome/printpreview_helper.xhtml | 243 +++++++++++++++++++++ .../tests/chrome/printpreview_scale_test_001.html | 21 ++ .../chrome/printpreview_scale_test_001_ref.html | 20 ++ .../tests/chrome/printpreview_scale_test_002.html | 21 ++ .../chrome/printpreview_scale_test_002_ref.html | 26 +++ .../tests/chrome/printpreview_scale_test_003.html | 21 ++ .../chrome/printpreview_scale_test_003_ref.html | 21 ++ layout/base/tests/chrome/test_bug420499.xhtml | 2 +- 9 files changed, 380 insertions(+), 1 deletion(-) create mode 100644 layout/base/tests/chrome/printpreview_scale_test_001.html create mode 100644 layout/base/tests/chrome/printpreview_scale_test_001_ref.html create mode 100644 layout/base/tests/chrome/printpreview_scale_test_002.html create mode 100644 layout/base/tests/chrome/printpreview_scale_test_002_ref.html create mode 100644 layout/base/tests/chrome/printpreview_scale_test_003.html create mode 100644 layout/base/tests/chrome/printpreview_scale_test_003_ref.html (limited to 'layout/base/tests') 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 = '
'; + const style = ''; + // Add the name as a comment, to ensure every test has a unique source even + // if the parameters are identical. + const comment = ''; + 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(); } + ]]> 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 @@ + + + + + +
+ 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 @@ + + + + + +
+ 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 @@ + + + + + +
+ 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 @@ + + + + + +
+ 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 @@ + + + + + +
+ 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 @@ + + + + + +
+ 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; } -- cgit v1.2.3
Print preview canvas 1Print preview canvas 2