Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 | const URL = "http://mochi.test:8888/browser/toolkit/components/thumbnails/" + |
michael@0 | 5 | "test/background_red.html?" + Date.now(); |
michael@0 | 6 | |
michael@0 | 7 | // Test PageThumbs API function getThumbnailPath |
michael@0 | 8 | function runTests() { |
michael@0 | 9 | |
michael@0 | 10 | let path = PageThumbs.getThumbnailPath(URL); |
michael@0 | 11 | yield testIfExists(path, false, "Thumbnail file does not exist"); |
michael@0 | 12 | |
michael@0 | 13 | yield addVisitsAndRepopulateNewTabLinks(URL, next); |
michael@0 | 14 | yield createThumbnail(URL); |
michael@0 | 15 | |
michael@0 | 16 | path = PageThumbs.getThumbnailPath(URL); |
michael@0 | 17 | let expectedPath = PageThumbsStorage.getFilePathForURL(URL); |
michael@0 | 18 | is(path, expectedPath, "Thumbnail file has correct path"); |
michael@0 | 19 | |
michael@0 | 20 | yield testIfExists(path, true, "Thumbnail file exists"); |
michael@0 | 21 | |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | function createThumbnail(aURL) { |
michael@0 | 25 | addTab(aURL, function () { |
michael@0 | 26 | whenFileExists(aURL, function () { |
michael@0 | 27 | gBrowser.removeTab(gBrowser.selectedTab); |
michael@0 | 28 | next(); |
michael@0 | 29 | }); |
michael@0 | 30 | }); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | function testIfExists(aPath, aExpected, aMessage) { |
michael@0 | 34 | return OS.File.exists(aPath).then( |
michael@0 | 35 | function onSuccess(exists) { |
michael@0 | 36 | is(exists, aExpected, aMessage); |
michael@0 | 37 | }, |
michael@0 | 38 | function onFailure(error) { |
michael@0 | 39 | ok(false, "OS.File.exists() failed " + error); |
michael@0 | 40 | } |
michael@0 | 41 | ); |
michael@0 | 42 | } |