diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /toolkit/components/thumbnails/test/browser_thumbnails_bg_queueing.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/thumbnails/test/browser_thumbnails_bg_queueing.js')
-rw-r--r-- | toolkit/components/thumbnails/test/browser_thumbnails_bg_queueing.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/toolkit/components/thumbnails/test/browser_thumbnails_bg_queueing.js b/toolkit/components/thumbnails/test/browser_thumbnails_bg_queueing.js new file mode 100644 index 0000000000..4684c8b832 --- /dev/null +++ b/toolkit/components/thumbnails/test/browser_thumbnails_bg_queueing.js @@ -0,0 +1,49 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +add_task(async function thumbnails_bg_queueing() { + let urls = [ + "http://www.example.com/0", + "http://www.example.com/1", + // an item that will timeout to ensure timeouts work and we resume. + bgTestPageURL({ wait: 2002 }), + "http://www.example.com/2", + ]; + dontExpireThumbnailURLs(urls); + + let promises = []; + + for (let url of urls) { + ok(!thumbnailExists(url), "Thumbnail should not exist yet: " + url); + let isTimeoutTest = url.includes("wait"); + + let promise = bgCapture(url, { + timeout: isTimeoutTest ? 100 : 30000, + onDone: capturedURL => { + ok(!!urls.length, "onDone called, so URLs should still remain"); + is( + capturedURL, + urls.shift(), + "Captured URL should be currently expected URL (i.e., " + + "capture() callbacks should be called in the correct order)" + ); + if (isTimeoutTest) { + ok( + !thumbnailExists(capturedURL), + "Thumbnail shouldn't exist for timed out capture" + ); + } else { + ok( + thumbnailExists(capturedURL), + "Thumbnail should be cached after capture" + ); + removeThumbnail(url); + } + }, + }); + + promises.push(promise); + } + + await Promise.all(promises); +}); |