toolkit/components/places/tests/unit/test_frecency_zero_updated.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 // 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