toolkit/components/thumbnails/test/browser_thumbnails_bg_queueing.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/thumbnails/test/browser_thumbnails_bg_queueing.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,38 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +function runTests() {
     1.8 +  let urls = [
     1.9 +    "http://www.example.com/0",
    1.10 +    "http://www.example.com/1",
    1.11 +    // an item that will timeout to ensure timeouts work and we resume.
    1.12 +    bgTestPageURL({ wait: 2002 }),
    1.13 +    "http://www.example.com/2",
    1.14 +  ];
    1.15 +  dontExpireThumbnailURLs(urls);
    1.16 +  urls.forEach(url => {
    1.17 +    ok(!thumbnailExists(url), "Thumbnail should not exist yet: " + url);
    1.18 +    let isTimeoutTest = url.indexOf("wait") >= 0;
    1.19 +    BackgroundPageThumbs.capture(url, {
    1.20 +      timeout: isTimeoutTest ? 100 : 30000,
    1.21 +      onDone: function onDone(capturedURL) {
    1.22 +        ok(urls.length > 0, "onDone called, so URLs should still remain");
    1.23 +        is(capturedURL, urls.shift(),
    1.24 +           "Captured URL should be currently expected URL (i.e., " +
    1.25 +           "capture() callbacks should be called in the correct order)");
    1.26 +        if (isTimeoutTest) {
    1.27 +          ok(!thumbnailExists(capturedURL),
    1.28 +             "Thumbnail shouldn't exist for timed out capture");
    1.29 +        } else {
    1.30 +          ok(thumbnailExists(capturedURL),
    1.31 +             "Thumbnail should be cached after capture");
    1.32 +          removeThumbnail(url);
    1.33 +        }
    1.34 +        if (!urls.length)
    1.35 +          // Test done.
    1.36 +          next();
    1.37 +      },
    1.38 +    });
    1.39 +  });
    1.40 +  yield true;
    1.41 +}

mercurial