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.

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

mercurial