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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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