1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/thumbnails/test/browser_thumbnails_bg_no_duplicates.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,31 @@ 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"; 1.9 + ok(!thumbnailExists(url), "Thumbnail file should not already exist."); 1.10 + let numCallbacks = 0; 1.11 + let doneCallback = function(doneUrl) { 1.12 + is(doneUrl, url, "called back with correct url"); 1.13 + numCallbacks += 1; 1.14 + // We will delete the file after the first callback, then check it 1.15 + // still doesn't exist on the second callback, which should give us 1.16 + // confidence that we didn't end up with 2 different captures happening 1.17 + // for the same url... 1.18 + if (numCallbacks == 1) { 1.19 + ok(thumbnailExists(url), "Thumbnail file should now exist."); 1.20 + removeThumbnail(url); 1.21 + return; 1.22 + } 1.23 + if (numCallbacks == 2) { 1.24 + ok(!thumbnailExists(url), "Thumbnail file should still be deleted."); 1.25 + // and that's all we expect, so we are done... 1.26 + next(); 1.27 + return; 1.28 + } 1.29 + ok(false, "only expecting 2 callbacks"); 1.30 + } 1.31 + BackgroundPageThumbs.capture(url, {onDone: doneCallback}); 1.32 + BackgroundPageThumbs.capture(url, {onDone: doneCallback}); 1.33 + yield true; 1.34 +}