summaryrefslogtreecommitdiffstats
path: root/toolkit/components/thumbnails/test/browser_thumbnails_bg_timeout.js
blob: da05b43553ba45c174a95d17e89d78e3057543b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

function* runTests() {
  let url = bgTestPageURL({ wait: 30000 });
  ok(!thumbnailExists(url), "Thumbnail should not be cached already.");
  let numCalls = 0;
  BackgroundPageThumbs.capture(url, {
    timeout: 0,
    onDone: function onDone(capturedURL) {
      is(capturedURL, url, "Captured URL should be URL passed to capture");
      is(numCalls++, 0, "onDone should be called only once");
      ok(!thumbnailExists(url),
         "Capture timed out so thumbnail should not be cached");
      next();
    },
  });
  yield new Promise(resolve => {
    bgAddPageThumbObserver(url).catch(function(err) {
      ok(true, `page-thumbnail error thrown for ${url}`);
      resolve();
    });
  });
}