2013-08-08 00:48:07 +04:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
const URL = "http://mochi.test:8888/browser/toolkit/components/thumbnails/" +
|
|
|
|
"test/background_red.html?" + Date.now();
|
|
|
|
|
|
|
|
// Test PageThumbs API function getThumbnailPath
|
2015-12-03 20:59:44 +03:00
|
|
|
function* runTests() {
|
2013-08-08 00:48:07 +04:00
|
|
|
|
|
|
|
let path = PageThumbs.getThumbnailPath(URL);
|
|
|
|
yield testIfExists(path, false, "Thumbnail file does not exist");
|
|
|
|
|
2014-01-08 00:59:18 +04:00
|
|
|
yield addVisitsAndRepopulateNewTabLinks(URL, next);
|
2013-08-08 00:48:07 +04:00
|
|
|
yield createThumbnail(URL);
|
|
|
|
|
|
|
|
path = PageThumbs.getThumbnailPath(URL);
|
2017-06-05 17:04:06 +03:00
|
|
|
let expectedPath = PageThumbsStorageService.getFilePathForURL(URL);
|
2013-08-08 00:48:07 +04:00
|
|
|
is(path, expectedPath, "Thumbnail file has correct path");
|
|
|
|
|
|
|
|
yield testIfExists(path, true, "Thumbnail file exists");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function createThumbnail(aURL) {
|
2016-11-12 02:22:34 +03:00
|
|
|
addTab(aURL, function() {
|
2017-04-05 07:18:57 +03:00
|
|
|
gBrowserThumbnails.clearTopSiteURLCache();
|
2016-11-12 02:22:34 +03:00
|
|
|
whenFileExists(aURL, function() {
|
2013-08-08 00:48:07 +04:00
|
|
|
gBrowser.removeTab(gBrowser.selectedTab);
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function testIfExists(aPath, aExpected, aMessage) {
|
|
|
|
return OS.File.exists(aPath).then(
|
|
|
|
function onSuccess(exists) {
|
|
|
|
is(exists, aExpected, aMessage);
|
|
|
|
},
|
|
|
|
function onFailure(error) {
|
|
|
|
ok(false, "OS.File.exists() failed " + error);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|