Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 urls = [ |
michael@0 | 6 | "http://www.example.com/0", |
michael@0 | 7 | "http://www.example.com/1", |
michael@0 | 8 | // an item that will timeout to ensure timeouts work and we resume. |
michael@0 | 9 | bgTestPageURL({ wait: 2002 }), |
michael@0 | 10 | "http://www.example.com/2", |
michael@0 | 11 | ]; |
michael@0 | 12 | dontExpireThumbnailURLs(urls); |
michael@0 | 13 | urls.forEach(url => { |
michael@0 | 14 | ok(!thumbnailExists(url), "Thumbnail should not exist yet: " + url); |
michael@0 | 15 | let isTimeoutTest = url.indexOf("wait") >= 0; |
michael@0 | 16 | BackgroundPageThumbs.capture(url, { |
michael@0 | 17 | timeout: isTimeoutTest ? 100 : 30000, |
michael@0 | 18 | onDone: function onDone(capturedURL) { |
michael@0 | 19 | ok(urls.length > 0, "onDone called, so URLs should still remain"); |
michael@0 | 20 | is(capturedURL, urls.shift(), |
michael@0 | 21 | "Captured URL should be currently expected URL (i.e., " + |
michael@0 | 22 | "capture() callbacks should be called in the correct order)"); |
michael@0 | 23 | if (isTimeoutTest) { |
michael@0 | 24 | ok(!thumbnailExists(capturedURL), |
michael@0 | 25 | "Thumbnail shouldn't exist for timed out capture"); |
michael@0 | 26 | } else { |
michael@0 | 27 | ok(thumbnailExists(capturedURL), |
michael@0 | 28 | "Thumbnail should be cached after capture"); |
michael@0 | 29 | removeThumbnail(url); |
michael@0 | 30 | } |
michael@0 | 31 | if (!urls.length) |
michael@0 | 32 | // Test done. |
michael@0 | 33 | next(); |
michael@0 | 34 | }, |
michael@0 | 35 | }); |
michael@0 | 36 | }); |
michael@0 | 37 | yield true; |
michael@0 | 38 | } |