toolkit/components/places/tests/favicons/test_expireAllFavicons.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 });

mercurial