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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/tests/unit/test_frecency_zero_updated.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,30 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +// Tests a zero frecency is correctly updated when inserting new valid visits.
     1.8 +
     1.9 +function run_test()
    1.10 +{
    1.11 +  run_next_test()
    1.12 +}
    1.13 +
    1.14 +add_task(function ()
    1.15 +{
    1.16 +  const TEST_URI = NetUtil.newURI("http://example.com/");
    1.17 +  let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
    1.18 +                                                TEST_URI,
    1.19 +                                                PlacesUtils.bookmarks.DEFAULT_INDEX,
    1.20 +                                                "A title");
    1.21 +  yield promiseAsyncUpdates();
    1.22 +  do_check_true(frecencyForUrl(TEST_URI) > 0);
    1.23 +
    1.24 +  // Removing the bookmark should leave an orphan page with zero frecency.
    1.25 +  // Note this would usually be expired later by expiration.
    1.26 +  PlacesUtils.bookmarks.removeItem(id);
    1.27 +  yield promiseAsyncUpdates();
    1.28 +  do_check_eq(frecencyForUrl(TEST_URI), 0);
    1.29 +
    1.30 +  // Now add a valid visit to the page, frecency should increase.
    1.31 +  yield promiseAddVisits({ uri: TEST_URI });
    1.32 +  do_check_true(frecencyForUrl(TEST_URI) > 0);
    1.33 +});

mercurial