michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function runTests() { michael@0: let url = "http://example.com/1"; michael@0: ok(!thumbnailExists(url), "Thumbnail file should not already exist."); michael@0: let numCallbacks = 0; michael@0: let doneCallback = function(doneUrl) { michael@0: is(doneUrl, url, "called back with correct url"); michael@0: numCallbacks += 1; michael@0: // We will delete the file after the first callback, then check it michael@0: // still doesn't exist on the second callback, which should give us michael@0: // confidence that we didn't end up with 2 different captures happening michael@0: // for the same url... michael@0: if (numCallbacks == 1) { michael@0: ok(thumbnailExists(url), "Thumbnail file should now exist."); michael@0: removeThumbnail(url); michael@0: return; michael@0: } michael@0: if (numCallbacks == 2) { michael@0: ok(!thumbnailExists(url), "Thumbnail file should still be deleted."); michael@0: // and that's all we expect, so we are done... michael@0: next(); michael@0: return; michael@0: } michael@0: ok(false, "only expecting 2 callbacks"); michael@0: } michael@0: BackgroundPageThumbs.capture(url, {onDone: doneCallback}); michael@0: BackgroundPageThumbs.capture(url, {onDone: doneCallback}); michael@0: yield true; michael@0: }