Backed out changeset 1e8ffb360c27 (bug 1884172) for causing OSX mochitests failures in browser_screenshots_test_visible.js. CLOSED TREE

This commit is contained in:
Stanca Serban
2024-03-12 19:10:04 +02:00
parent 5b1a9a8c0b
commit fe83932e94
3 changed files with 44 additions and 86 deletions

View File

@@ -97,16 +97,14 @@ export class ScreenshotsComponentChild extends JSWindowActorChild {
case "Screenshots:Download":
this.requestDownloadScreenshot(event.detail.region);
break;
case "Screenshots:OverlaySelection": {
case "Screenshots:OverlaySelection":
let { hasSelection } = event.detail;
this.sendOverlaySelection({ hasSelection });
break;
}
case "Screenshots:RecordEvent": {
case "Screenshots:RecordEvent":
let { eventName, reason, args } = event.detail;
this.recordTelemetryEvent(eventName, reason, args);
break;
}
case "Screenshots:ShowPanel":
this.showPanel();
break;

View File

@@ -980,23 +980,8 @@ export var ScreenshotsUtils = {
"@mozilla.org/widget/transferable;1"
].createInstance(Ci.nsITransferable);
transferable.init(null);
// Internal consumers expect the image data to be stored as a
// nsIInputStream. On Linux and Windows, pasted data is directly
// retrieved from the system's native clipboard, and made available
// as a nsIInputStream.
//
// On macOS, nsClipboard::GetNativeClipboardData (nsClipboard.mm) uses
// a cached copy of nsITransferable if available, e.g. when the copy
// was initiated by the same browser instance. To make sure that a
// nsIInputStream is returned instead of the cached imgIContainer,
// the image is exported as as `kNativeImageMime`. Data associated
// with this type is converted to a platform-specific image format
// when written to the clipboard. The type is not used when images
// are read from the clipboard (on all platforms, not just macOS).
// This forces nsClipboard::GetNativeClipboardData to fall back to
// the native clipboard, and return the image as a nsITransferable.
transferable.addDataFlavor("application/x-moz-nativeimage");
transferable.setTransferData("application/x-moz-nativeimage", imgDecoded);
transferable.addDataFlavor("image/png");
transferable.setTransferData("image/png", imgDecoded);
Services.clipboard.setData(
transferable,

View File

@@ -3,11 +3,8 @@
"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");
function assertRange(lhs, rhsMin, rhsMax, msg) {
Assert.ok(lhs >= rhsMin && lhs <= rhsMax, msg);
}
add_task(async function test_fullpageScreenshot() {
@@ -68,36 +65,25 @@ add_task(async function test_fullpageScreenshot() {
Assert.equal(result.width, expectedWidth, "Widths should be equal");
Assert.equal(result.height, expectedHeight, "Heights should be equal");
// 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, [66, 170, 171], "Top right pixel");
assertPixel(
result.color.bottomLeft,
[125, 75, 125],
"Bottom left pixel"
);
assertPixel(
result.color.bottomRight,
[64, 145, 169],
"Bottom right pixel"
);
} else {
assertPixel(result.color.topLeft, [111, 111, 111], "Top left pixel");
assertPixel(result.color.topRight, [55, 155, 155], "Top right pixel");
assertPixel(
result.color.bottomLeft,
[105, 55, 105],
"Bottom left pixel"
);
assertPixel(
result.color.bottomRight,
[52, 127, 152],
"Bottom right pixel"
);
}
// top left
assertRange(result.color.topLeft[0], 110, 111, "R color value");
assertRange(result.color.topLeft[1], 110, 111, "G color value");
assertRange(result.color.topLeft[2], 110, 111, "B color value");
// top right
assertRange(result.color.topRight[0], 55, 56, "R color value");
assertRange(result.color.topRight[1], 155, 156, "G color value");
assertRange(result.color.topRight[2], 155, 156, "B color value");
// bottom left
assertRange(result.color.bottomLeft[0], 105, 106, "R color value");
assertRange(result.color.bottomLeft[1], 55, 56, "G color value");
assertRange(result.color.bottomLeft[2], 105, 106, "B color value");
// bottom right
assertRange(result.color.bottomRight[0], 52, 53, "R color value");
assertRange(result.color.bottomRight[1], 127, 128, "G color value");
assertRange(result.color.bottomRight[2], 152, 153, "B color value");
}
);
});
@@ -165,36 +151,25 @@ add_task(async function test_fullpageScreenshotScrolled() {
Assert.equal(result.width, expectedWidth, "Widths should be equal");
Assert.equal(result.height, expectedHeight, "Heights should be equal");
// 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, [66, 170, 171], "Top right pixel");
assertPixel(
result.color.bottomLeft,
[125, 75, 125],
"Bottom left pixel"
);
assertPixel(
result.color.bottomRight,
[64, 145, 169],
"Bottom right pixel"
);
} else {
assertPixel(result.color.topLeft, [111, 111, 111], "Top left pixel");
assertPixel(result.color.topRight, [55, 155, 155], "Top right pixel");
assertPixel(
result.color.bottomLeft,
[105, 55, 105],
"Bottom left pixel"
);
assertPixel(
result.color.bottomRight,
[52, 127, 152],
"Bottom right pixel"
);
}
// top left
assertRange(result.color.topLeft[0], 110, 111, "R color value");
assertRange(result.color.topLeft[1], 110, 111, "G color value");
assertRange(result.color.topLeft[2], 110, 111, "B color value");
// top right
assertRange(result.color.topRight[0], 55, 56, "R color value");
assertRange(result.color.topRight[1], 155, 156, "G color value");
assertRange(result.color.topRight[2], 155, 156, "B color value");
// bottom left
assertRange(result.color.bottomLeft[0], 105, 106, "R color value");
assertRange(result.color.bottomLeft[1], 55, 56, "G color value");
assertRange(result.color.bottomLeft[2], 105, 106, "B color value");
// bottom right
assertRange(result.color.bottomRight[0], 52, 53, "R color value");
assertRange(result.color.bottomRight[1], 127, 128, "G color value");
assertRange(result.color.bottomRight[2], 152, 153, "B color value");
}
);
});