michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function runTests() { michael@0: let urls = [ michael@0: "http://www.example.com/0", michael@0: "http://www.example.com/1", michael@0: // an item that will timeout to ensure timeouts work and we resume. michael@0: bgTestPageURL({ wait: 2002 }), michael@0: "http://www.example.com/2", michael@0: ]; michael@0: dontExpireThumbnailURLs(urls); michael@0: urls.forEach(url => { michael@0: ok(!thumbnailExists(url), "Thumbnail should not exist yet: " + url); michael@0: let isTimeoutTest = url.indexOf("wait") >= 0; michael@0: BackgroundPageThumbs.capture(url, { michael@0: timeout: isTimeoutTest ? 100 : 30000, michael@0: onDone: function onDone(capturedURL) { michael@0: ok(urls.length > 0, "onDone called, so URLs should still remain"); michael@0: is(capturedURL, urls.shift(), michael@0: "Captured URL should be currently expected URL (i.e., " + michael@0: "capture() callbacks should be called in the correct order)"); michael@0: if (isTimeoutTest) { michael@0: ok(!thumbnailExists(capturedURL), michael@0: "Thumbnail shouldn't exist for timed out capture"); michael@0: } else { michael@0: ok(thumbnailExists(capturedURL), michael@0: "Thumbnail should be cached after capture"); michael@0: removeThumbnail(url); michael@0: } michael@0: if (!urls.length) michael@0: // Test done. michael@0: next(); michael@0: }, michael@0: }); michael@0: }); michael@0: yield true; michael@0: }