michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * This file tests that favicons are correctly expired by expireAllFavicons. michael@0: */ michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: /// Globals michael@0: michael@0: const TEST_PAGE_URI = NetUtil.newURI("http://example.com/"); michael@0: const BOOKMARKED_PAGE_URI = NetUtil.newURI("http://example.com/bookmarked"); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: /// Tests michael@0: michael@0: function run_test() { michael@0: run_next_test(); michael@0: } michael@0: michael@0: add_test(function test_expireAllFavicons() { michael@0: // Set up an observer to wait for favicons expiration to finish. michael@0: Services.obs.addObserver(function EAF_observer(aSubject, aTopic, aData) { michael@0: Services.obs.removeObserver(EAF_observer, aTopic); michael@0: michael@0: // Check that the favicons for the pages we added were removed. michael@0: checkFaviconMissingForPage(TEST_PAGE_URI, function () { michael@0: checkFaviconMissingForPage(BOOKMARKED_PAGE_URI, function () { michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }, PlacesUtils.TOPIC_FAVICONS_EXPIRED, false); michael@0: michael@0: // Add a visited page. michael@0: promiseAddVisits({ uri: TEST_PAGE_URI, transition: TRANSITION_TYPED }).then( michael@0: function () { michael@0: PlacesUtils.favicons.setAndFetchFaviconForPage(TEST_PAGE_URI, michael@0: SMALLPNG_DATA_URI, true, michael@0: PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE); michael@0: michael@0: // Add a page with a bookmark. michael@0: PlacesUtils.bookmarks.insertBookmark( michael@0: PlacesUtils.toolbarFolderId, BOOKMARKED_PAGE_URI, michael@0: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: "Test bookmark"); michael@0: PlacesUtils.favicons.setAndFetchFaviconForPage( michael@0: BOOKMARKED_PAGE_URI, SMALLPNG_DATA_URI, true, michael@0: PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE, michael@0: function () { michael@0: // Start expiration only after data has been saved in the database. michael@0: PlacesUtils.favicons.expireAllFavicons(); michael@0: }); michael@0: }); michael@0: });