toolkit/components/thumbnails/test/browser_thumbnails_bg_captureIfMissing.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_captureIfMissing.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,24 @@
     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 url = "http://example.com/";
     1.9 +  let file = thumbnailFile(url);
    1.10 +  ok(!file.exists(), "Thumbnail file should not already exist.");
    1.11 +
    1.12 +  let capturedURL = yield bgCaptureIfMissing(url);
    1.13 +  is(capturedURL, url, "Captured URL should be URL passed to capture");
    1.14 +  ok(file.exists(url), "Thumbnail should be cached after capture");
    1.15 +
    1.16 +  let past = Date.now() - 1000000000;
    1.17 +  let pastFudge = past + 30000;
    1.18 +  file.lastModifiedTime = past;
    1.19 +  ok(file.lastModifiedTime < pastFudge, "Last modified time should stick!");
    1.20 +  capturedURL = yield bgCaptureIfMissing(url);
    1.21 +  is(capturedURL, url, "Captured URL should be URL passed to second capture");
    1.22 +  ok(file.exists(), "Thumbnail should remain cached after second capture");
    1.23 +  ok(file.lastModifiedTime < pastFudge,
    1.24 +     "File should not have been overwritten");
    1.25 +
    1.26 +  file.remove(false);
    1.27 +}

mercurial