toolkit/components/places/tests/unit/test_frecency_zero_updated.js

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 // Tests a zero frecency is correctly updated when inserting new valid visits.
     6 function run_test()
     7 {
     8   run_next_test()
     9 }
    11 add_task(function ()
    12 {
    13   const TEST_URI = NetUtil.newURI("http://example.com/");
    14   let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
    15                                                 TEST_URI,
    16                                                 PlacesUtils.bookmarks.DEFAULT_INDEX,
    17                                                 "A title");
    18   yield promiseAsyncUpdates();
    19   do_check_true(frecencyForUrl(TEST_URI) > 0);
    21   // Removing the bookmark should leave an orphan page with zero frecency.
    22   // Note this would usually be expired later by expiration.
    23   PlacesUtils.bookmarks.removeItem(id);
    24   yield promiseAsyncUpdates();
    25   do_check_eq(frecencyForUrl(TEST_URI), 0);
    27   // Now add a valid visit to the page, frecency should increase.
    28   yield promiseAddVisits({ uri: TEST_URI });
    29   do_check_true(frecencyForUrl(TEST_URI) > 0);
    30 });

mercurial