summaryrefslogtreecommitdiffstats
path: root/browser/components/screenshots/tests/browser/browser_screenshots_test_visible.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/screenshots/tests/browser/browser_screenshots_test_visible.js')
-rw-r--r--browser/components/screenshots/tests/browser/browser_screenshots_test_visible.js206
1 files changed, 127 insertions, 79 deletions
diff --git a/browser/components/screenshots/tests/browser/browser_screenshots_test_visible.js b/browser/components/screenshots/tests/browser/browser_screenshots_test_visible.js
index 7b7a46f73d..c53b44d5ea 100644
--- a/browser/components/screenshots/tests/browser/browser_screenshots_test_visible.js
+++ b/browser/components/screenshots/tests/browser/browser_screenshots_test_visible.js
@@ -3,6 +3,13 @@
"use strict";
+function assertPixel(actual, expected, message) {
+ info(message);
+ isfuzzy(actual[0], expected[0], 1, "R color value");
+ isfuzzy(actual[1], expected[1], 1, "G color value");
+ isfuzzy(actual[2], expected[2], 1, "B color value");
+}
+
add_task(async function test_visibleScreenshot() {
await BrowserTestUtils.withNewTab(
{
@@ -65,25 +72,36 @@ add_task(async function test_visibleScreenshot() {
Assert.equal(result.width, expectedWidth, "Widths should be equal");
Assert.equal(result.height, expectedHeight, "Heights should be equal");
- // top left
- Assert.equal(111, result.color.topLeft[0], "R color value");
- Assert.equal(111, result.color.topLeft[1], "G color value");
- Assert.equal(111, result.color.topLeft[2], "B color value");
-
- // top right
- Assert.equal(111, result.color.topRight[0], "R color value");
- Assert.equal(111, result.color.topRight[1], "G color value");
- Assert.equal(111, result.color.topRight[2], "B color value");
-
- // bottom left
- Assert.equal(111, result.color.bottomLeft[0], "R color value");
- Assert.equal(111, result.color.bottomLeft[1], "G color value");
- Assert.equal(111, result.color.bottomLeft[2], "B color value");
-
- // bottom right
- Assert.equal(111, result.color.bottomRight[0], "R color value");
- Assert.equal(111, result.color.bottomRight[1], "G color value");
- Assert.equal(111, result.color.bottomRight[2], "B color value");
+ // Due to https://bugzil.la/1396587, the pasted image colors differ from
+ // the original image on macOS. Once that bug is fixed, we can remove the
+ // special check for macOS.
+ if (AppConstants.platform === "macosx") {
+ assertPixel(result.color.topLeft, [130, 130, 130], "Top left pixel");
+ assertPixel(result.color.topRight, [130, 130, 130], "Top right pixel");
+ assertPixel(
+ result.color.bottomLeft,
+ [130, 130, 130],
+ "Bottom left pixel"
+ );
+ assertPixel(
+ result.color.bottomRight,
+ [130, 130, 130],
+ "Bottom right pixel"
+ );
+ } else {
+ assertPixel(result.color.topLeft, [111, 111, 111], "Top left pixel");
+ assertPixel(result.color.topRight, [111, 111, 111], "Top right pixel");
+ assertPixel(
+ result.color.bottomLeft,
+ [111, 111, 111],
+ "Bottom left pixel"
+ );
+ assertPixel(
+ result.color.bottomRight,
+ [111, 111, 111],
+ "Bottom right pixel"
+ );
+ }
}
);
});
@@ -147,34 +165,42 @@ add_task(async function test_visibleScreenshotScrolledY() {
info("Waiting for clipboard change");
let result = await clipboardChanged;
- // let result = await helper.getImageSizeAndColorFromClipboard();
- // debugger;
-
info("result: " + JSON.stringify(result, null, 2));
info("contentInfo: " + JSON.stringify(contentInfo, null, 2));
Assert.equal(result.width, expectedWidth, "Widths should be equal");
Assert.equal(result.height, expectedHeight, "Heights should be equal");
- // top left
- Assert.equal(105, result.color.topLeft[0], "R color value");
- Assert.equal(55, result.color.topLeft[1], "G color value");
- Assert.equal(105, result.color.topLeft[2], "B color value");
-
- // top right
- Assert.equal(105, result.color.topRight[0], "R color value");
- Assert.equal(55, result.color.topRight[1], "G color value");
- Assert.equal(105, result.color.topRight[2], "B color value");
-
- // bottom left
- Assert.equal(105, result.color.bottomLeft[0], "R color value");
- Assert.equal(55, result.color.bottomLeft[1], "G color value");
- Assert.equal(105, result.color.bottomLeft[2], "B color value");
-
- // bottom right
- Assert.equal(105, result.color.bottomRight[0], "R color value");
- Assert.equal(55, result.color.bottomRight[1], "G color value");
- Assert.equal(105, result.color.bottomRight[2], "B color value");
+ // Due to https://bugzil.la/1396587, the pasted image colors differ from
+ // the original image on macOS. Once that bug is fixed, we can remove the
+ // special check for macOS.
+ if (AppConstants.platform === "macosx") {
+ assertPixel(result.color.topLeft, [125, 75, 125], "Top left pixel");
+ assertPixel(result.color.topRight, [125, 75, 125], "Top right pixel");
+ assertPixel(
+ result.color.bottomLeft,
+ [125, 75, 125],
+ "Bottom left pixel"
+ );
+ assertPixel(
+ result.color.bottomRight,
+ [125, 75, 125],
+ "Bottom right pixel"
+ );
+ } else {
+ assertPixel(result.color.topLeft, [105, 55, 105], "Top left pixel");
+ assertPixel(result.color.topRight, [105, 55, 105], "Top right pixel");
+ assertPixel(
+ result.color.bottomLeft,
+ [105, 55, 105],
+ "Bottom left pixel"
+ );
+ assertPixel(
+ result.color.bottomRight,
+ [105, 55, 105],
+ "Bottom right pixel"
+ );
+ }
}
);
});
@@ -244,25 +270,36 @@ add_task(async function test_visibleScreenshotScrolledX() {
Assert.equal(result.width, expectedWidth, "Widths should be equal");
Assert.equal(result.height, expectedHeight, "Heights should be equal");
- // top left
- Assert.equal(55, result.color.topLeft[0], "R color value");
- Assert.equal(155, result.color.topLeft[1], "G color value");
- Assert.equal(155, result.color.topLeft[2], "B color value");
-
- // top right
- Assert.equal(55, result.color.topRight[0], "R color value");
- Assert.equal(155, result.color.topRight[1], "G color value");
- Assert.equal(155, result.color.topRight[2], "B color value");
-
- // bottom left
- Assert.equal(55, result.color.bottomLeft[0], "R color value");
- Assert.equal(155, result.color.bottomLeft[1], "G color value");
- Assert.equal(155, result.color.bottomLeft[2], "B color value");
-
- // bottom right
- Assert.equal(55, result.color.bottomRight[0], "R color value");
- Assert.equal(155, result.color.bottomRight[1], "G color value");
- Assert.equal(155, result.color.bottomRight[2], "B color value");
+ // Due to https://bugzil.la/1396587, the pasted image colors differ from
+ // the original image on macOS. Once that bug is fixed, we can remove the
+ // special check for macOS.
+ if (AppConstants.platform === "macosx") {
+ assertPixel(result.color.topLeft, [66, 170, 171], "Top left pixel");
+ assertPixel(result.color.topRight, [66, 170, 171], "Top right pixel");
+ assertPixel(
+ result.color.bottomLeft,
+ [66, 170, 171],
+ "Bottom left pixel"
+ );
+ assertPixel(
+ result.color.bottomRight,
+ [66, 170, 171],
+ "Bottom right pixel"
+ );
+ } else {
+ assertPixel(result.color.topLeft, [55, 155, 155], "Top left pixel");
+ assertPixel(result.color.topRight, [55, 155, 155], "Top right pixel");
+ assertPixel(
+ result.color.bottomLeft,
+ [55, 155, 155],
+ "Bottom left pixel"
+ );
+ assertPixel(
+ result.color.bottomRight,
+ [55, 155, 155],
+ "Bottom right pixel"
+ );
+ }
}
);
});
@@ -332,25 +369,36 @@ add_task(async function test_visibleScreenshotScrolledXAndY() {
Assert.equal(result.width, expectedWidth, "Widths should be equal");
Assert.equal(result.height, expectedHeight, "Heights should be equal");
- // top left
- Assert.equal(52, result.color.topLeft[0], "R color value");
- Assert.equal(127, result.color.topLeft[1], "G color value");
- Assert.equal(152, result.color.topLeft[2], "B color value");
-
- // top right
- Assert.equal(52, result.color.topRight[0], "R color value");
- Assert.equal(127, result.color.topRight[1], "G color value");
- Assert.equal(152, result.color.topRight[2], "B color value");
-
- // bottom left
- Assert.equal(52, result.color.bottomLeft[0], "R color value");
- Assert.equal(127, result.color.bottomLeft[1], "G color value");
- Assert.equal(152, result.color.bottomLeft[2], "B color value");
-
- // bottom right
- Assert.equal(52, result.color.bottomRight[0], "R color value");
- Assert.equal(127, result.color.bottomRight[1], "G color value");
- Assert.equal(152, result.color.bottomRight[2], "B color value");
+ // Due to https://bugzil.la/1396587, the pasted image colors differ from
+ // the original image on macOS. Once that bug is fixed, we can remove the
+ // special check for macOS.
+ if (AppConstants.platform === "macosx") {
+ assertPixel(result.color.topLeft, [64, 145, 169], "Top left pixel");
+ assertPixel(result.color.topRight, [64, 145, 169], "Top right pixel");
+ assertPixel(
+ result.color.bottomLeft,
+ [64, 145, 169],
+ "Bottom left pixel"
+ );
+ assertPixel(
+ result.color.bottomRight,
+ [64, 145, 169],
+ "Bottom right pixel"
+ );
+ } else {
+ assertPixel(result.color.topLeft, [52, 127, 152], "Top left pixel");
+ assertPixel(result.color.topRight, [52, 127, 152], "Top right pixel");
+ assertPixel(
+ result.color.bottomLeft,
+ [52, 127, 152],
+ "Bottom left pixel"
+ );
+ assertPixel(
+ result.color.bottomRight,
+ [52, 127, 152],
+ "Bottom right pixel"
+ );
+ }
}
);
});