From 70c9524cd6d446e483ff2396be0a8b4b185dbb2b Mon Sep 17 00:00:00 2001 From: Amelia Magee Date: Wed, 11 Sep 2024 02:35:11 +0100 Subject: [PATCH] Revert Favicon change --- tests/js/web/Notifications/FaviconEditorTest.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/js/web/Notifications/FaviconEditorTest.js b/tests/js/web/Notifications/FaviconEditorTest.js index caac27f6b8..ead99ab76f 100644 --- a/tests/js/web/Notifications/FaviconEditorTest.js +++ b/tests/js/web/Notifications/FaviconEditorTest.js @@ -145,7 +145,21 @@ describe('FaviconEditor', () => { faviconEditor = new FaviconEditor($root[0]); faviconEditor.init(); - canvas.toDataURL('image/png'); + // Override serializer to return raw image data, we cannot use the default + // canvas.toDataURL(...) here as the png compression is different when + // in the browser / headless test environments + faviconEditor.setSerializer((canvas, ctx) => { + const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + const debugCvs = document.createElement('canvas'); + const debugCtx = debugCvs.getContext('2d'); + + debugCtx.width = canvas.width; + debugCtx.height = canvas.height; + debugCtx.putImageData(imageData, 0, 0); + actual = debugCvs.toDataURL('image/png'); + + return [...imageData.data]; + }); faviconEditor.addCircleNotification('red', 5) .then((data) => {