summaryrefslogtreecommitdiffstats
path: root/toolkit/components/thumbnails/test/browser_thumbnails_expiration.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:55:19 +0200
commiteb70e6e3d0bff11c25f14b1196025791bf2308fb (patch)
tree5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/thumbnails/test/browser_thumbnails_expiration.js
parent32ead795290b3399d56b4708fc75b77d296f6a1a (diff)
downloadUXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/thumbnails/test/browser_thumbnails_expiration.js')
-rw-r--r--toolkit/components/thumbnails/test/browser_thumbnails_expiration.js97
1 files changed, 0 insertions, 97 deletions
diff --git a/toolkit/components/thumbnails/test/browser_thumbnails_expiration.js b/toolkit/components/thumbnails/test/browser_thumbnails_expiration.js
deleted file mode 100644
index 4c73e17be..000000000
--- a/toolkit/components/thumbnails/test/browser_thumbnails_expiration.js
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-const URL = "http://mochi.test:8888/?t=" + Date.now();
-const URL1 = URL + "#1";
-const URL2 = URL + "#2";
-const URL3 = URL + "#3";
-
-var tmp = {};
-Cc["@mozilla.org/moz/jssubscript-loader;1"]
- .getService(Ci.mozIJSSubScriptLoader)
- .loadSubScript("resource://gre/modules/PageThumbs.jsm", tmp);
-
-const EXPIRATION_MIN_CHUNK_SIZE = 50;
-const {PageThumbsExpiration} = tmp;
-
-function* runTests() {
- // Create dummy URLs.
- let dummyURLs = [];
- for (let i = 0; i < EXPIRATION_MIN_CHUNK_SIZE + 10; i++) {
- dummyURLs.push(URL + "#dummy" + i);
- }
-
- // Make sure our thumbnails aren't expired too early.
- dontExpireThumbnailURLs([URL1, URL2, URL3].concat(dummyURLs));
-
- // Create three thumbnails.
- yield createDummyThumbnail(URL1);
- ok(thumbnailExists(URL1), "first thumbnail created");
-
- yield createDummyThumbnail(URL2);
- ok(thumbnailExists(URL2), "second thumbnail created");
-
- yield createDummyThumbnail(URL3);
- ok(thumbnailExists(URL3), "third thumbnail created");
-
- // Remove the third thumbnail.
- yield expireThumbnails([URL1, URL2]);
- ok(thumbnailExists(URL1), "first thumbnail still exists");
- ok(thumbnailExists(URL2), "second thumbnail still exists");
- ok(!thumbnailExists(URL3), "third thumbnail has been removed");
-
- // Remove the second thumbnail.
- yield expireThumbnails([URL1]);
- ok(thumbnailExists(URL1), "first thumbnail still exists");
- ok(!thumbnailExists(URL2), "second thumbnail has been removed");
-
- // Remove all thumbnails.
- yield expireThumbnails([]);
- ok(!thumbnailExists(URL1), "all thumbnails have been removed");
-
- // Create some more files than the min chunk size.
- for (let url of dummyURLs) {
- yield createDummyThumbnail(url);
- }
-
- ok(dummyURLs.every(thumbnailExists), "all dummy thumbnails created");
-
- // Expire thumbnails and expect 10 remaining.
- yield expireThumbnails([]);
- let remainingURLs = dummyURLs.filter(thumbnailExists);
- is(remainingURLs.length, 10, "10 dummy thumbnails remaining");
-
- // Expire thumbnails again. All should be gone by now.
- yield expireThumbnails([]);
- remainingURLs = remainingURLs.filter(thumbnailExists);
- is(remainingURLs.length, 0, "no dummy thumbnails remaining");
-}
-
-function createDummyThumbnail(aURL) {
- info("Creating dummy thumbnail for " + aURL);
- let dummy = new Uint8Array(10);
- for (let i = 0; i < 10; ++i) {
- dummy[i] = i;
- }
- PageThumbsStorage.writeData(aURL, dummy).then(
- function onSuccess() {
- info("createDummyThumbnail succeeded");
- executeSoon(next);
- },
- function onFailure(error) {
- ok(false, "createDummyThumbnail failed " + error);
- }
- );
-}
-
-function expireThumbnails(aKeep) {
- PageThumbsExpiration.expireThumbnails(aKeep).then(
- function onSuccess() {
- info("expireThumbnails succeeded");
- executeSoon(next);
- },
- function onFailure(error) {
- ok(false, "expireThumbnails failed " + error);
- }
- );
-}