summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/places')
-rw-r--r--toolkit/components/places/PlacesFrecencyRecalculator.sys.mjs83
-rw-r--r--toolkit/components/places/PlacesQuery.sys.mjs8
-rw-r--r--toolkit/components/places/PlacesTransactions.sys.mjs11
-rw-r--r--toolkit/components/places/SQLFunctions.cpp19
-rw-r--r--toolkit/components/places/SyncedBookmarksMirror.sys.mjs6
-rw-r--r--toolkit/components/places/bookmark_sync/src/store.rs19
-rw-r--r--toolkit/components/places/mozIAsyncHistory.idl4
-rw-r--r--toolkit/components/places/mozISyncedBookmarksMirror.idl2
-rw-r--r--toolkit/components/places/tests/bookmarks/test_sync_fields.js2
-rw-r--r--toolkit/components/places/tests/browser/browser_visituri.js2
-rw-r--r--toolkit/components/places/tests/browser/previews/browser_thumbnails.js2
-rw-r--r--toolkit/components/places/tests/history/test_hasVisits.js2
-rw-r--r--toolkit/components/places/tests/history/test_insert.js2
-rw-r--r--toolkit/components/places/tests/history/test_insertMany.js2
-rw-r--r--toolkit/components/places/tests/history/test_remove.js2
-rw-r--r--toolkit/components/places/tests/history/test_removeMany.js2
-rw-r--r--toolkit/components/places/tests/history/test_removeVisitsByFilter.js2
-rw-r--r--toolkit/components/places/tests/history/test_update.js2
-rw-r--r--toolkit/components/places/tests/sync/test_bookmark_mirror_migration.js2
-rw-r--r--toolkit/components/places/tests/unit/test_PlacesObservers_counts.js58
-rw-r--r--toolkit/components/places/tests/unit/test_frecency_observers.js4
-rw-r--r--toolkit/components/places/tests/unit/test_frecency_recalculator.js16
-rw-r--r--toolkit/components/places/tests/unit/test_origins_parsing.js2
-rw-r--r--toolkit/components/places/tests/unit/xpcshell.toml2
24 files changed, 190 insertions, 66 deletions
diff --git a/toolkit/components/places/PlacesFrecencyRecalculator.sys.mjs b/toolkit/components/places/PlacesFrecencyRecalculator.sys.mjs
index 7c52c508ee..a1df8cac89 100644
--- a/toolkit/components/places/PlacesFrecencyRecalculator.sys.mjs
+++ b/toolkit/components/places/PlacesFrecencyRecalculator.sys.mjs
@@ -59,12 +59,31 @@ XPCOMUtils.defineLazyPreferenceGetter(
90
);
+// This pref stores whether recalculation should be faster.
+// It is set when we detect that a lot of changes happened recently, and it
+// will survive restarts. Once there's nothing left to recalculate, we unset
+// the pref and return to the normal recalculation rate.
+// Note this getter transforms the boolean pref value into an integer
+// acceleration rate.
+const PREF_ACCELERATE_RECALCULATION = "places.frecency.accelerateRecalculation";
+XPCOMUtils.defineLazyPreferenceGetter(
+ lazy,
+ "accelerationRate",
+ PREF_ACCELERATE_RECALCULATION,
+ false,
+ null,
+ accelerate => (accelerate ? 2 : 1)
+);
+
// Time between deferred task executions.
const DEFERRED_TASK_INTERVAL_MS = 2 * 60000;
// Maximum time to wait for an idle before the task is executed anyway.
const DEFERRED_TASK_MAX_IDLE_WAIT_MS = 5 * 60000;
// Number of entries to update at once.
const DEFAULT_CHUNK_SIZE = 50;
+// Threshold used to evaluate whether the number of Places events from the last
+// recalculation is high enough to deserve a recalculation rate increase.
+const ACCELERATION_EVENTS_THRESHOLD = 250;
export class PlacesFrecencyRecalculator {
classID = Components.ID("1141fd31-4c1a-48eb-8f1a-2f05fad94085");
@@ -104,11 +123,8 @@ export class PlacesFrecencyRecalculator {
return;
}
- this.#task = new lazy.DeferredTask(
- this.#taskFn.bind(this),
- DEFERRED_TASK_INTERVAL_MS,
- DEFERRED_TASK_MAX_IDLE_WAIT_MS
- );
+ this.#createOrUpdateTask();
+
lazy.AsyncShutdown.profileChangeTeardown.addBlocker(
"PlacesFrecencyRecalculator: shutdown",
() => this.#finalize()
@@ -133,6 +149,22 @@ export class PlacesFrecencyRecalculator {
this.maybeStartFrecencyRecalculation();
}
+ #createOrUpdateTask() {
+ let wasArmed = this.#task?.isArmed;
+ if (this.#task) {
+ this.#task.disarm();
+ this.#task.finalize().catch(console.error);
+ }
+ this.#task = new lazy.DeferredTask(
+ this.#taskFn.bind(this),
+ DEFERRED_TASK_INTERVAL_MS / lazy.accelerationRate,
+ DEFERRED_TASK_MAX_IDLE_WAIT_MS / lazy.accelerationRate
+ );
+ if (wasArmed) {
+ this.#task.arm();
+ }
+ }
+
async #taskFn() {
if (this.#task.isFinalized) {
return;
@@ -161,6 +193,40 @@ export class PlacesFrecencyRecalculator {
this.#task.finalize().catch(console.error);
}
+ #lastEventsCount = 0;
+
+ /**
+ * Evaluates whether recalculation speed should be increased, and eventually
+ * accelerates.
+ * @returns {boolean} whether the recalculation rate is increased.
+ */
+ maybeUpdateRecalculationSpeed() {
+ if (lazy.accelerationRate > 1) {
+ return true;
+ }
+ // We mostly care about additions to cover the common case of importing
+ // bookmarks or history. We may care about removals, but in most cases they
+ // reduce the number of entries to recalculate.
+ let eventsCount =
+ PlacesObservers.counts.get("page-visited") +
+ PlacesObservers.counts.get("bookmark-added");
+ let accelerate =
+ eventsCount - this.#lastEventsCount > ACCELERATION_EVENTS_THRESHOLD;
+ if (accelerate) {
+ Services.prefs.setBoolPref(PREF_ACCELERATE_RECALCULATION, true);
+ this.#createOrUpdateTask();
+ }
+ this.#lastEventsCount = eventsCount;
+ return accelerate;
+ }
+
+ #resetRecalculationSpeed() {
+ if (lazy.accelerationRate > 1) {
+ Services.prefs.clearUserPref(PREF_ACCELERATE_RECALCULATION);
+ this.#createOrUpdateTask();
+ }
+ }
+
/**
* Updates a chunk of outdated frecency values. If there's more frecency
* values to update at the end of the process, it may rearm the task.
@@ -169,6 +235,8 @@ export class PlacesFrecencyRecalculator {
* @resolves {boolean} Whether any entry was recalculated.
*/
async recalculateSomeFrecencies({ chunkSize = DEFAULT_CHUNK_SIZE } = {}) {
+ // In case of acceleration we don't bump up the chunkSize to avoid issues
+ // with slow disk systems.
lazy.logger.trace(
`Recalculate ${chunkSize >= 0 ? chunkSize : "infinite"} frecency values`
);
@@ -182,7 +250,7 @@ export class PlacesFrecencyRecalculator {
WHERE id IN (
SELECT id FROM moz_places
WHERE recalc_frecency = 1
- ORDER BY frecency DESC
+ ORDER BY frecency DESC, visit_count DESC
LIMIT ${chunkSize}
)
RETURNING id`
@@ -212,8 +280,10 @@ export class PlacesFrecencyRecalculator {
if (chunkSize > 0 && shouldRestartRecalculation) {
// There's more entries to recalculate, rearm the task.
+ this.maybeUpdateRecalculationSpeed();
this.#task.arm();
} else {
+ this.#resetRecalculationSpeed();
// There's nothing left to recalculate, wait for the next change.
lazy.PlacesUtils.history.shouldStartFrecencyRecalculation = false;
this.#task.disarm();
@@ -360,6 +430,7 @@ export class PlacesFrecencyRecalculator {
return;
case "frecency-recalculation-needed":
lazy.logger.trace("Frecency recalculation requested");
+ this.maybeUpdateRecalculationSpeed();
this.maybeStartFrecencyRecalculation();
return;
case "test-execute-taskFn":
diff --git a/toolkit/components/places/PlacesQuery.sys.mjs b/toolkit/components/places/PlacesQuery.sys.mjs
index 674e49b0ba..7ddf5ee988 100644
--- a/toolkit/components/places/PlacesQuery.sys.mjs
+++ b/toolkit/components/places/PlacesQuery.sys.mjs
@@ -58,7 +58,7 @@ export class PlacesQuery {
#historyListenerCallback = null;
/** @type {DeferredTask} */
#historyObserverTask = null;
- #searchInProgress = false;
+ searchInProgress = false;
/**
* Get a snapshot of history visits at this moment.
@@ -169,11 +169,11 @@ export class PlacesQuery {
GROUP BY url
ORDER BY ${orderBy}
LIMIT ${limit > 0 ? limit : -1}`;
- if (this.#searchInProgress) {
+ if (this.searchInProgress) {
db.interrupt();
}
try {
- this.#searchInProgress = true;
+ this.searchInProgress = true;
const rows = await db.executeCached(sql, {
query,
matchBehavior: Ci.mozIPlacesAutoComplete.MATCH_ANYWHERE_UNMODIFIED,
@@ -181,7 +181,7 @@ export class PlacesQuery {
});
return rows.map(row => this.formatRowAsVisit(row));
} finally {
- this.#searchInProgress = false;
+ this.searchInProgress = false;
}
}
diff --git a/toolkit/components/places/PlacesTransactions.sys.mjs b/toolkit/components/places/PlacesTransactions.sys.mjs
index bd0b7654a3..be922ec53f 100644
--- a/toolkit/components/places/PlacesTransactions.sys.mjs
+++ b/toolkit/components/places/PlacesTransactions.sys.mjs
@@ -31,11 +31,12 @@
* A note about GUIDs and item-ids
* -------------------------------
* There's an ongoing effort (see bug 1071511) to deprecate item-ids in Places
- * in favor of GUIDs. Both because new APIs (e.g. Bookmark.jsm) expose them to
- * the minimum necessary, and because GUIDs play much better with implementing
- * |redo|, this API doesn't support item-ids at all, and only accepts bookmark
- * GUIDs, both for input (e.g. for setting the parent folder for a new bookmark)
- * and for output (when the GUID for such a bookmark is propagated).
+ * in favor of GUIDs. Both because new APIs (e.g. Bookmarks.sys.mjs) expose them
+ * to the minimum necessary, and because GUIDs play much better with
+ * implementing |redo|, this API doesn't support item-ids at all, and only
+ * accepts bookmark GUIDs, both for input (e.g. for setting the parent folder
+ * for a new bookmark) and for output (when the GUID for such a bookmark is
+ * propagated).
*
* Constructing transactions
* -------------------------
diff --git a/toolkit/components/places/SQLFunctions.cpp b/toolkit/components/places/SQLFunctions.cpp
index 85c5cc8d17..de12b73583 100644
--- a/toolkit/components/places/SQLFunctions.cpp
+++ b/toolkit/components/places/SQLFunctions.cpp
@@ -1134,16 +1134,15 @@ GetQueryParamFunction::OnFunctionCall(mozIStorageValueArray* aArguments,
RefPtr<nsVariant> result = new nsVariant();
if (!queryString.IsEmpty() && !paramName.IsEmpty()) {
- URLParams::Parse(
- queryString, true,
- [&paramName, &result](const nsAString& aName, const nsAString& aValue) {
- NS_ConvertUTF16toUTF8 name(aName);
- if (!paramName.Equals(name)) {
- return true;
- }
- result->SetAsAString(aValue);
- return false;
- });
+ URLParams::Parse(queryString, true,
+ [&paramName, &result](const nsACString& aName,
+ const nsACString& aValue) {
+ if (!paramName.Equals(aName)) {
+ return true;
+ }
+ result->SetAsACString(aValue);
+ return false;
+ });
}
result.forget(_result);
diff --git a/toolkit/components/places/SyncedBookmarksMirror.sys.mjs b/toolkit/components/places/SyncedBookmarksMirror.sys.mjs
index a09e1b7eb3..c68761a086 100644
--- a/toolkit/components/places/SyncedBookmarksMirror.sys.mjs
+++ b/toolkit/components/places/SyncedBookmarksMirror.sys.mjs
@@ -2060,11 +2060,7 @@ function validateURL(rawURL) {
if (typeof rawURL != "string" || rawURL.length > DB_URL_LENGTH_MAX) {
return null;
}
- let url = null;
- try {
- url = new URL(rawURL);
- } catch (ex) {}
- return url;
+ return URL.parse(rawURL);
}
function validateKeyword(rawKeyword) {
diff --git a/toolkit/components/places/bookmark_sync/src/store.rs b/toolkit/components/places/bookmark_sync/src/store.rs
index 6e8d8024b4..e5cf973e5d 100644
--- a/toolkit/components/places/bookmark_sync/src/store.rs
+++ b/toolkit/components/places/bookmark_sync/src/store.rs
@@ -1219,7 +1219,6 @@ trait Column<T> {
fn from_column(raw: T) -> Result<Self>
where
Self: Sized;
- fn into_column(self) -> T;
}
impl Column<i64> for Kind {
@@ -1233,16 +1232,6 @@ impl Column<i64> for Kind {
_ => return Err(Error::UnknownItemKind(raw)),
})
}
-
- fn into_column(self) -> i64 {
- match self {
- Kind::Bookmark => mozISyncedBookmarksMerger::KIND_BOOKMARK as i64,
- Kind::Query => mozISyncedBookmarksMerger::KIND_QUERY as i64,
- Kind::Folder => mozISyncedBookmarksMerger::KIND_FOLDER as i64,
- Kind::Livemark => mozISyncedBookmarksMerger::KIND_LIVEMARK as i64,
- Kind::Separator => mozISyncedBookmarksMerger::KIND_SEPARATOR as i64,
- }
- }
}
impl Column<i64> for Validity {
@@ -1254,14 +1243,6 @@ impl Column<i64> for Validity {
_ => return Err(Error::UnknownItemValidity(raw).into()),
})
}
-
- fn into_column(self) -> i64 {
- match self {
- Validity::Valid => mozISyncedBookmarksMerger::VALIDITY_VALID as i64,
- Validity::Reupload => mozISyncedBookmarksMerger::VALIDITY_REUPLOAD as i64,
- Validity::Replace => mozISyncedBookmarksMerger::VALIDITY_REPLACE as i64,
- }
- }
}
/// Formats an optional value so that it can be included in a SQL statement.
diff --git a/toolkit/components/places/mozIAsyncHistory.idl b/toolkit/components/places/mozIAsyncHistory.idl
index 88690b4798..27487ebc9b 100644
--- a/toolkit/components/places/mozIAsyncHistory.idl
+++ b/toolkit/components/places/mozIAsyncHistory.idl
@@ -107,8 +107,8 @@ interface mozIVisitInfoCallback : nsISupports
* handleResult and handleError, respectively, if/once
* results/errors occur.
*/
- readonly attribute bool ignoreResults;
- readonly attribute bool ignoreErrors;
+ readonly attribute boolean ignoreResults;
+ readonly attribute boolean ignoreErrors;
};
[scriptable, function, uuid(994092bf-936f-449b-8dd6-0941e024360d)]
diff --git a/toolkit/components/places/mozISyncedBookmarksMirror.idl b/toolkit/components/places/mozISyncedBookmarksMirror.idl
index 0ceaeff5ad..701b7a128d 100644
--- a/toolkit/components/places/mozISyncedBookmarksMirror.idl
+++ b/toolkit/components/places/mozISyncedBookmarksMirror.idl
@@ -34,7 +34,7 @@ interface mozISyncedBookmarksMirrorProgressListener : nsISupports {
// A callback called when the merge finishes.
[scriptable, uuid(d23fdfea-92c8-409d-a516-08ae395d578f)]
interface mozISyncedBookmarksMirrorCallback : nsISupports {
- void handleSuccess(in bool result);
+ void handleSuccess(in boolean result);
void handleError(in nsresult code, in AString message);
};
diff --git a/toolkit/components/places/tests/bookmarks/test_sync_fields.js b/toolkit/components/places/tests/bookmarks/test_sync_fields.js
index 0a6f53fb85..b7b2ab4a1a 100644
--- a/toolkit/components/places/tests/bookmarks/test_sync_fields.js
+++ b/toolkit/components/places/tests/bookmarks/test_sync_fields.js
@@ -330,7 +330,7 @@ async function findTagFolder(tag) {
return results.length ? results[0].getResultByName("guid") : null;
}
-// Exercises the new, async calls implemented in `Bookmarks.jsm`.
+// Exercises the new, async calls implemented in `Bookmarks.sys.mjs`.
class AsyncTestCases extends TestCases {
async createFolder(parentGuid, title, index) {
let item = await PlacesUtils.bookmarks.insert({
diff --git a/toolkit/components/places/tests/browser/browser_visituri.js b/toolkit/components/places/tests/browser/browser_visituri.js
index 529c010e63..6aafe084e7 100644
--- a/toolkit/components/places/tests/browser/browser_visituri.js
+++ b/toolkit/components/places/tests/browser/browser_visituri.js
@@ -139,7 +139,7 @@ add_task(async function test_userpass() {
);
// Open the target link as background.
- await ContentTask.spawn(gBrowser.selectedBrowser, null, async args => {
+ await ContentTask.spawn(gBrowser.selectedBrowser, null, async () => {
let link = content.document.getElementById("target-userpass");
EventUtils.synthesizeMouseAtCenter(
link,
diff --git a/toolkit/components/places/tests/browser/previews/browser_thumbnails.js b/toolkit/components/places/tests/browser/previews/browser_thumbnails.js
index 27f4fa3745..4fbbafccf9 100644
--- a/toolkit/components/places/tests/browser/previews/browser_thumbnails.js
+++ b/toolkit/components/places/tests/browser/previews/browser_thumbnails.js
@@ -2,7 +2,7 @@
* https://creativecommons.org/publicdomain/zero/1.0/ */
/**
- * Tests PlacesPreviews.jsm
+ * Tests PlacesPreviews.sys.mjs
*/
const { PlacesPreviews } = ChromeUtils.importESModule(
"resource://gre/modules/PlacesPreviews.sys.mjs"
diff --git a/toolkit/components/places/tests/history/test_hasVisits.js b/toolkit/components/places/tests/history/test_hasVisits.js
index 36fc9fd7be..5c7b56a8f3 100644
--- a/toolkit/components/places/tests/history/test_hasVisits.js
+++ b/toolkit/components/places/tests/history/test_hasVisits.js
@@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
-// Tests for `History.hasVisits` as implemented in History.jsm
+// Tests for `History.hasVisits` as implemented in History.sys.mjs
"use strict";
diff --git a/toolkit/components/places/tests/history/test_insert.js b/toolkit/components/places/tests/history/test_insert.js
index a3a820ade9..ce83199516 100644
--- a/toolkit/components/places/tests/history/test_insert.js
+++ b/toolkit/components/places/tests/history/test_insert.js
@@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
-// Tests for `History.insert` as implemented in History.jsm
+// Tests for `History.insert` as implemented in History.sys.mjs
"use strict";
diff --git a/toolkit/components/places/tests/history/test_insertMany.js b/toolkit/components/places/tests/history/test_insertMany.js
index 3d0774cbf2..4fe1481d85 100644
--- a/toolkit/components/places/tests/history/test_insertMany.js
+++ b/toolkit/components/places/tests/history/test_insertMany.js
@@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
-// Tests for `History.insertMany` as implemented in History.jsm
+// Tests for `History.insertMany` as implemented in History.sys.mjs
"use strict";
diff --git a/toolkit/components/places/tests/history/test_remove.js b/toolkit/components/places/tests/history/test_remove.js
index 8c5e941fd0..c018a996f3 100644
--- a/toolkit/components/places/tests/history/test_remove.js
+++ b/toolkit/components/places/tests/history/test_remove.js
@@ -1,7 +1,7 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
-// Tests for `History.remove`, as implemented in History.jsm
+// Tests for `History.remove`, as implemented in History.sys.mjs
"use strict";
diff --git a/toolkit/components/places/tests/history/test_removeMany.js b/toolkit/components/places/tests/history/test_removeMany.js
index ff8c3a21ee..5c955af0e1 100644
--- a/toolkit/components/places/tests/history/test_removeMany.js
+++ b/toolkit/components/places/tests/history/test_removeMany.js
@@ -2,7 +2,7 @@
/* vim:set ts=2 sw=2 sts=2 et: */
// Tests for `History.remove` with removing many urls, as implemented in
-// History.jsm.
+// History.sys.mjs.
"use strict";
diff --git a/toolkit/components/places/tests/history/test_removeVisitsByFilter.js b/toolkit/components/places/tests/history/test_removeVisitsByFilter.js
index be01fcb901..1045245d89 100644
--- a/toolkit/components/places/tests/history/test_removeVisitsByFilter.js
+++ b/toolkit/components/places/tests/history/test_removeVisitsByFilter.js
@@ -1,7 +1,7 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
-// Tests for `History.removeVisitsByFilter`, as implemented in History.jsm
+// Tests for `History.removeVisitsByFilter`, as implemented in History.sys.mjs
"use strict";
diff --git a/toolkit/components/places/tests/history/test_update.js b/toolkit/components/places/tests/history/test_update.js
index d7beafd368..df5bcc7195 100644
--- a/toolkit/components/places/tests/history/test_update.js
+++ b/toolkit/components/places/tests/history/test_update.js
@@ -3,7 +3,7 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
-// Tests for `History.update` as implemented in History.jsm
+// Tests for `History.update` as implemented in History.sys.mjs
"use strict";
diff --git a/toolkit/components/places/tests/sync/test_bookmark_mirror_migration.js b/toolkit/components/places/tests/sync/test_bookmark_mirror_migration.js
index 86cf45eb0f..774ee9a1bb 100644
--- a/toolkit/components/places/tests/sync/test_bookmark_mirror_migration.js
+++ b/toolkit/components/places/tests/sync/test_bookmark_mirror_migration.js
@@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
-// Keep in sync with `SyncedBookmarksMirror.jsm`.
+// Keep in sync with `SyncedBookmarksMirror.sys.mjs`.
const CURRENT_MIRROR_SCHEMA_VERSION = 9;
// The oldest schema version that we support. Any databases with schemas older
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"]