From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../places/tests/favicons/test_heavy_favicon.js | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 toolkit/components/places/tests/favicons/test_heavy_favicon.js (limited to 'toolkit/components/places/tests/favicons/test_heavy_favicon.js') diff --git a/toolkit/components/places/tests/favicons/test_heavy_favicon.js b/toolkit/components/places/tests/favicons/test_heavy_favicon.js new file mode 100644 index 0000000000..58282db2e3 --- /dev/null +++ b/toolkit/components/places/tests/favicons/test_heavy_favicon.js @@ -0,0 +1,36 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* + * Tests a png with a large file size that can't fit MAX_FAVICON_BUFFER_SIZE, + * it should be downsized until it can be stored, rather than thrown away. + */ + +add_task(async function() { + let file = do_get_file("noise.png"); + let icon = { + file, + uri: NetUtil.newURI(file), + data: readFileData(file), + mimetype: "image/png", + }; + + // If this should fail, it means MAX_FAVICON_BUFFER_SIZE has been made bigger + // than this icon. For this test to make sense the icon shoul always be + // bigger than MAX_FAVICON_BUFFER_SIZE. Please update the icon! + Assert.ok( + icon.data.length > Ci.nsIFaviconService.MAX_FAVICON_BUFFER_SIZE, + "The test icon file size must be larger than Ci.nsIFaviconService.MAX_FAVICON_BUFFER_SIZE" + ); + + let pageURI = uri("http://foo.bar/"); + await PlacesTestUtils.addVisits(pageURI); + + PlacesUtils.favicons.replaceFaviconData(icon.uri, icon.data, icon.mimetype); + await setFaviconForPage(pageURI, icon.uri); + Assert.equal( + await getFaviconUrlForPage(pageURI), + icon.uri.spec, + "A resampled version of the icon should be stored" + ); +}); -- cgit v1.2.3