|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * This file tests that favicons are correctly expired by expireAllFavicons. |
|
6 */ |
|
7 |
|
8 //////////////////////////////////////////////////////////////////////////////// |
|
9 /// Globals |
|
10 |
|
11 const TEST_PAGE_URI = NetUtil.newURI("http://example.com/"); |
|
12 const BOOKMARKED_PAGE_URI = NetUtil.newURI("http://example.com/bookmarked"); |
|
13 |
|
14 //////////////////////////////////////////////////////////////////////////////// |
|
15 /// Tests |
|
16 |
|
17 function run_test() { |
|
18 run_next_test(); |
|
19 } |
|
20 |
|
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); |
|
25 |
|
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); |
|
33 |
|
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); |
|
40 |
|
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 }); |