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

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 // Tests a zero frecency is correctly updated when inserting new valid visits.
michael@0 5
michael@0 6 function run_test()
michael@0 7 {
michael@0 8 run_next_test()
michael@0 9 }
michael@0 10
michael@0 11 add_task(function ()
michael@0 12 {
michael@0 13 const TEST_URI = NetUtil.newURI("http://example.com/");
michael@0 14 let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
michael@0 15 TEST_URI,
michael@0 16 PlacesUtils.bookmarks.DEFAULT_INDEX,
michael@0 17 "A title");
michael@0 18 yield promiseAsyncUpdates();
michael@0 19 do_check_true(frecencyForUrl(TEST_URI) > 0);
michael@0 20
michael@0 21 // Removing the bookmark should leave an orphan page with zero frecency.
michael@0 22 // Note this would usually be expired later by expiration.
michael@0 23 PlacesUtils.bookmarks.removeItem(id);
michael@0 24 yield promiseAsyncUpdates();
michael@0 25 do_check_eq(frecencyForUrl(TEST_URI), 0);
michael@0 26
michael@0 27 // Now add a valid visit to the page, frecency should increase.
michael@0 28 yield promiseAddVisits({ uri: TEST_URI });
michael@0 29 do_check_true(frecencyForUrl(TEST_URI) > 0);
michael@0 30 });

mercurial