michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Tests a zero frecency is correctly updated when inserting new valid visits. michael@0: michael@0: function run_test() michael@0: { michael@0: run_next_test() michael@0: } michael@0: michael@0: add_task(function () michael@0: { michael@0: const TEST_URI = NetUtil.newURI("http://example.com/"); michael@0: let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, michael@0: TEST_URI, michael@0: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: "A title"); michael@0: yield promiseAsyncUpdates(); michael@0: do_check_true(frecencyForUrl(TEST_URI) > 0); michael@0: michael@0: // Removing the bookmark should leave an orphan page with zero frecency. michael@0: // Note this would usually be expired later by expiration. michael@0: PlacesUtils.bookmarks.removeItem(id); michael@0: yield promiseAsyncUpdates(); michael@0: do_check_eq(frecencyForUrl(TEST_URI), 0); michael@0: michael@0: // Now add a valid visit to the page, frecency should increase. michael@0: yield promiseAddVisits({ uri: TEST_URI }); michael@0: do_check_true(frecencyForUrl(TEST_URI) > 0); michael@0: });