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.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * This file tests that favicons are correctly expired by expireAllFavicons.
6 */
8 ////////////////////////////////////////////////////////////////////////////////
9 /// Globals
11 const TEST_PAGE_URI = NetUtil.newURI("http://example.com/");
12 const BOOKMARKED_PAGE_URI = NetUtil.newURI("http://example.com/bookmarked");
14 ////////////////////////////////////////////////////////////////////////////////
15 /// Tests
17 function run_test() {
18 run_next_test();
19 }
21 add_test(function test_expireAllFavicons() {
22 // Set up an observer to wait for favicons expiration to finish.
23 Services.obs.addObserver(function EAF_observer(aSubject, aTopic, aData) {
24 Services.obs.removeObserver(EAF_observer, aTopic);
26 // Check that the favicons for the pages we added were removed.
27 checkFaviconMissingForPage(TEST_PAGE_URI, function () {
28 checkFaviconMissingForPage(BOOKMARKED_PAGE_URI, function () {
29 run_next_test();
30 });
31 });
32 }, PlacesUtils.TOPIC_FAVICONS_EXPIRED, false);
34 // Add a visited page.
35 promiseAddVisits({ uri: TEST_PAGE_URI, transition: TRANSITION_TYPED }).then(
36 function () {
37 PlacesUtils.favicons.setAndFetchFaviconForPage(TEST_PAGE_URI,
38 SMALLPNG_DATA_URI, true,
39 PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE);
41 // Add a page with a bookmark.
42 PlacesUtils.bookmarks.insertBookmark(
43 PlacesUtils.toolbarFolderId, BOOKMARKED_PAGE_URI,
44 PlacesUtils.bookmarks.DEFAULT_INDEX,
45 "Test bookmark");
46 PlacesUtils.favicons.setAndFetchFaviconForPage(
47 BOOKMARKED_PAGE_URI, SMALLPNG_DATA_URI, true,
48 PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
49 function () {
50 // Start expiration only after data has been saved in the database.
51 PlacesUtils.favicons.expireAllFavicons();
52 });
53 });
54 });