toolkit/components/thumbnails/test/browser_thumbnails_bg_no_duplicates.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:2e7e68aef06f
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 function runTests() {
5 let url = "http://example.com/1";
6 ok(!thumbnailExists(url), "Thumbnail file should not already exist.");
7 let numCallbacks = 0;
8 let doneCallback = function(doneUrl) {
9 is(doneUrl, url, "called back with correct url");
10 numCallbacks += 1;
11 // We will delete the file after the first callback, then check it
12 // still doesn't exist on the second callback, which should give us
13 // confidence that we didn't end up with 2 different captures happening
14 // for the same url...
15 if (numCallbacks == 1) {
16 ok(thumbnailExists(url), "Thumbnail file should now exist.");
17 removeThumbnail(url);
18 return;
19 }
20 if (numCallbacks == 2) {
21 ok(!thumbnailExists(url), "Thumbnail file should still be deleted.");
22 // and that's all we expect, so we are done...
23 next();
24 return;
25 }
26 ok(false, "only expecting 2 callbacks");
27 }
28 BackgroundPageThumbs.capture(url, {onDone: doneCallback});
29 BackgroundPageThumbs.capture(url, {onDone: doneCallback});
30 yield true;
31 }

mercurial