|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Tests a zero frecency is correctly updated when inserting new valid visits. |
|
5 |
|
6 function run_test() |
|
7 { |
|
8 run_next_test() |
|
9 } |
|
10 |
|
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); |
|
20 |
|
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); |
|
26 |
|
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 }); |