diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /toolkit/components/places/tests/unit | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/places/tests/unit')
5 files changed, 79 insertions, 3 deletions
diff --git a/toolkit/components/places/tests/unit/test_PlacesObservers_counts.js b/toolkit/components/places/tests/unit/test_PlacesObservers_counts.js new file mode 100644 index 0000000000..3eb7c2d2a9 --- /dev/null +++ b/toolkit/components/places/tests/unit/test_PlacesObservers_counts.js @@ -0,0 +1,58 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test PlacesObservers.counts. + +add_task(async function test_counts() { + const url = "http://example.com/title"; + await PlacesUtils.history.insertMany([ + { + title: "will change", + url, + visits: [{ transition: TRANSITION_LINK }], + }, + { + title: "changed", + url, + referrer: url, + visits: [{ transition: TRANSITION_LINK }], + }, + { + title: "another", + url: "http://example.com/another", + visits: [{ transition: TRANSITION_LINK }], + }, + ]); + await PlacesUtils.bookmarks.insert({ + url, + parentGuid: PlacesUtils.bookmarks.toolbarGuid, + }); + await PlacesUtils.history.clear(); + await PlacesUtils.bookmarks.eraseEverything; + + Assert.strictEqual( + PlacesObservers.counts.get("non-existing"), + undefined, + "Check non existing event returns undefined" + ); + Assert.strictEqual( + PlacesObservers.counts.get("page-removed"), + 0, + "Check non fired event returns 0" + ); + Assert.strictEqual( + PlacesObservers.counts.get("page-visited"), + 3, + "Check fired event `page-visited`" + ); + Assert.strictEqual( + PlacesObservers.counts.get("history-cleared"), + 1, + "Check fired event `history-cleared`" + ); + Assert.strictEqual( + PlacesObservers.counts.get("bookmark-added"), + 1, + "Check fired event `bookmark-added`" + ); +}); diff --git a/toolkit/components/places/tests/unit/test_frecency_observers.js b/toolkit/components/places/tests/unit/test_frecency_observers.js index 44747b06f9..bc7a7ca099 100644 --- a/toolkit/components/places/tests/unit/test_frecency_observers.js +++ b/toolkit/components/places/tests/unit/test_frecency_observers.js @@ -37,7 +37,7 @@ add_task(async function test_nsNavHistory_UpdateFrecency() { await promise; }); -// History.jsm invalidateFrecencies() +// History.sys.mjs invalidateFrecencies() add_task(async function test_invalidateFrecencies() { let url = Services.io.newURI("http://test-invalidateFrecencies.com/"); // Bookmarking the URI is enough to add it to moz_places, and importantly, it @@ -54,7 +54,7 @@ add_task(async function test_invalidateFrecencies() { await promise; }); -// History.jsm clear() should not cause a frecency recalculation since pages +// History.sys.mjs clear() should not cause a frecency recalculation since pages // are removed. add_task(async function test_clear() { let received = []; diff --git a/toolkit/components/places/tests/unit/test_frecency_recalculator.js b/toolkit/components/places/tests/unit/test_frecency_recalculator.js index ed4501c56a..414882eaf5 100644 --- a/toolkit/components/places/tests/unit/test_frecency_recalculator.js +++ b/toolkit/components/places/tests/unit/test_frecency_recalculator.js @@ -176,3 +176,19 @@ add_task(async function test_chunk_time_telemetry() { "Should still not have set shouldStartFrecencyRecalculation" ); }); + +add_task(async function test_acceleration() { + await PlacesTestUtils.addVisits( + new Array(300).fill("https://www.mozilla.org/") + ); + + Assert.ok( + PlacesFrecencyRecalculator.maybeUpdateRecalculationSpeed(), + "Recalculation accelerated" + ); + await PlacesFrecencyRecalculator.recalculateAnyOutdatedFrecencies(); + Assert.ok( + !PlacesFrecencyRecalculator.maybeUpdateRecalculationSpeed(), + "Recalculation back to normal rate" + ); +}); diff --git a/toolkit/components/places/tests/unit/test_origins_parsing.js b/toolkit/components/places/tests/unit/test_origins_parsing.js index bdeabce271..8372e9fb66 100644 --- a/toolkit/components/places/tests/unit/test_origins_parsing.js +++ b/toolkit/components/places/tests/unit/test_origins_parsing.js @@ -71,7 +71,7 @@ add_task(async function parsing() { // The history cannot be deleted at a URL with a user path. } else { expectedOrigins = expectedOrigins.filter( - ([prefix, hostPort]) => !prefix.startsWith(uri.scheme + ":") + ([prefix]) => !prefix.startsWith(uri.scheme + ":") ); } await checkDB(expectedOrigins); diff --git a/toolkit/components/places/tests/unit/xpcshell.toml b/toolkit/components/places/tests/unit/xpcshell.toml index 8a56fcc370..62de0c0db7 100644 --- a/toolkit/components/places/tests/unit/xpcshell.toml +++ b/toolkit/components/places/tests/unit/xpcshell.toml @@ -179,6 +179,8 @@ prefs = ["places.frecency.pages.alternative.featureGate=true"] ["test_pageGuid_bookmarkGuid.js"] +["test_PlacesObservers_counts.js"] + ["test_placeURIs.js"] ["test_promiseBookmarksTree.js"] |