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
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 const URL = "http://mochi.test:8888/browser/toolkit/components/thumbnails/" +
5 "test/background_red.html?" + Date.now();
7 // Test PageThumbs API function getThumbnailPath
8 function runTests() {
10 let path = PageThumbs.getThumbnailPath(URL);
11 yield testIfExists(path, false, "Thumbnail file does not exist");
13 yield addVisitsAndRepopulateNewTabLinks(URL, next);
14 yield createThumbnail(URL);
16 path = PageThumbs.getThumbnailPath(URL);
17 let expectedPath = PageThumbsStorage.getFilePathForURL(URL);
18 is(path, expectedPath, "Thumbnail file has correct path");
20 yield testIfExists(path, true, "Thumbnail file exists");
22 }
24 function createThumbnail(aURL) {
25 addTab(aURL, function () {
26 whenFileExists(aURL, function () {
27 gBrowser.removeTab(gBrowser.selectedTab);
28 next();
29 });
30 });
31 }
33 function testIfExists(aPath, aExpected, aMessage) {
34 return OS.File.exists(aPath).then(
35 function onSuccess(exists) {
36 is(exists, aExpected, aMessage);
37 },
38 function onFailure(error) {
39 ok(false, "OS.File.exists() failed " + error);
40 }
41 );
42 }