toolkit/components/thumbnails/test/browser_thumbnails_bug818225.js

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:2a20b317560e
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 const URL = "http://mochi.test:8888/browser/toolkit/components/thumbnails/" +
5 "test/background_red.html?" + Date.now();
6
7 // Test PageThumbs API function getThumbnailPath
8 function runTests() {
9
10 let path = PageThumbs.getThumbnailPath(URL);
11 yield testIfExists(path, false, "Thumbnail file does not exist");
12
13 yield addVisitsAndRepopulateNewTabLinks(URL, next);
14 yield createThumbnail(URL);
15
16 path = PageThumbs.getThumbnailPath(URL);
17 let expectedPath = PageThumbsStorage.getFilePathForURL(URL);
18 is(path, expectedPath, "Thumbnail file has correct path");
19
20 yield testIfExists(path, true, "Thumbnail file exists");
21
22 }
23
24 function createThumbnail(aURL) {
25 addTab(aURL, function () {
26 whenFileExists(aURL, function () {
27 gBrowser.removeTab(gBrowser.selectedTab);
28 next();
29 });
30 });
31 }
32
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 }

mercurial