|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function runTests() { |
|
5 let urls = [ |
|
6 "http://www.example.com/0", |
|
7 "http://www.example.com/1", |
|
8 // an item that will timeout to ensure timeouts work and we resume. |
|
9 bgTestPageURL({ wait: 2002 }), |
|
10 "http://www.example.com/2", |
|
11 ]; |
|
12 dontExpireThumbnailURLs(urls); |
|
13 urls.forEach(url => { |
|
14 ok(!thumbnailExists(url), "Thumbnail should not exist yet: " + url); |
|
15 let isTimeoutTest = url.indexOf("wait") >= 0; |
|
16 BackgroundPageThumbs.capture(url, { |
|
17 timeout: isTimeoutTest ? 100 : 30000, |
|
18 onDone: function onDone(capturedURL) { |
|
19 ok(urls.length > 0, "onDone called, so URLs should still remain"); |
|
20 is(capturedURL, urls.shift(), |
|
21 "Captured URL should be currently expected URL (i.e., " + |
|
22 "capture() callbacks should be called in the correct order)"); |
|
23 if (isTimeoutTest) { |
|
24 ok(!thumbnailExists(capturedURL), |
|
25 "Thumbnail shouldn't exist for timed out capture"); |
|
26 } else { |
|
27 ok(thumbnailExists(capturedURL), |
|
28 "Thumbnail should be cached after capture"); |
|
29 removeThumbnail(url); |
|
30 } |
|
31 if (!urls.length) |
|
32 // Test done. |
|
33 next(); |
|
34 }, |
|
35 }); |
|
36 }); |
|
37 yield true; |
|
38 } |