michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: const URL = "http://mochi.test:8888/browser/toolkit/components/thumbnails/" + michael@0: "test/background_red.html?" + Date.now(); michael@0: michael@0: // Test PageThumbs API function getThumbnailPath michael@0: function runTests() { michael@0: michael@0: let path = PageThumbs.getThumbnailPath(URL); michael@0: yield testIfExists(path, false, "Thumbnail file does not exist"); michael@0: michael@0: yield addVisitsAndRepopulateNewTabLinks(URL, next); michael@0: yield createThumbnail(URL); michael@0: michael@0: path = PageThumbs.getThumbnailPath(URL); michael@0: let expectedPath = PageThumbsStorage.getFilePathForURL(URL); michael@0: is(path, expectedPath, "Thumbnail file has correct path"); michael@0: michael@0: yield testIfExists(path, true, "Thumbnail file exists"); michael@0: michael@0: } michael@0: michael@0: function createThumbnail(aURL) { michael@0: addTab(aURL, function () { michael@0: whenFileExists(aURL, function () { michael@0: gBrowser.removeTab(gBrowser.selectedTab); michael@0: next(); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function testIfExists(aPath, aExpected, aMessage) { michael@0: return OS.File.exists(aPath).then( michael@0: function onSuccess(exists) { michael@0: is(exists, aExpected, aMessage); michael@0: }, michael@0: function onFailure(error) { michael@0: ok(false, "OS.File.exists() failed " + error); michael@0: } michael@0: ); michael@0: }