toolkit/components/thumbnails/test/browser_thumbnails_bg_no_duplicates.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial