summaryrefslogtreecommitdiffstats
path: root/toolkit/components/telemetry/tests/unit
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /toolkit/components/telemetry/tests/unit
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-upstream/125.0.1.tar.xz
firefox-upstream/125.0.1.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/telemetry/tests/unit')
-rw-r--r--toolkit/components/telemetry/tests/unit/data/search-extensions/search-config-v2.json40
-rw-r--r--toolkit/components/telemetry/tests/unit/head.js6
-rw-r--r--toolkit/components/telemetry/tests/unit/test_EventPing.js8
-rw-r--r--toolkit/components/telemetry/tests/unit/test_TelemetryController.js2
-rw-r--r--toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js17
-rw-r--r--toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment_search.js13
-rw-r--r--toolkit/components/telemetry/tests/unit/test_TelemetryEvents.js2
-rw-r--r--toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js6
-rw-r--r--toolkit/components/telemetry/tests/unit/test_TelemetryLateWrites.js8
-rw-r--r--toolkit/components/telemetry/tests/unit/test_TelemetrySendOldPings.js2
-rw-r--r--toolkit/components/telemetry/tests/unit/test_TelemetrySession.js10
-rw-r--r--toolkit/components/telemetry/tests/unit/xpcshell.toml1
12 files changed, 78 insertions, 37 deletions
diff --git a/toolkit/components/telemetry/tests/unit/data/search-extensions/search-config-v2.json b/toolkit/components/telemetry/tests/unit/data/search-extensions/search-config-v2.json
new file mode 100644
index 0000000000..4117f72662
--- /dev/null
+++ b/toolkit/components/telemetry/tests/unit/data/search-extensions/search-config-v2.json
@@ -0,0 +1,40 @@
+{
+ "data": [
+ {
+ "recordType": "engine",
+ "identifier": "telemetrySearchIdentifier",
+ "base": {
+ "name": "telemetrySearchIdentifier",
+ "urls": {
+ "search": {
+ "base": "https://ar.wikipedia.org/wiki/%D8%AE%D8%A7%D8%B5:%D8%A8%D8%AD%D8%AB",
+ "params": [
+ {
+ "name": "sourceId",
+ "value": "Mozilla-search"
+ }
+ ],
+ "searchTermParamName": "search"
+ },
+ "suggestions": {
+ "base": "https://ar.wikipedia.org/w/api.php?action=opensearch",
+ "searchTermParamName": "search"
+ }
+ }
+ },
+ "variants": [
+ {
+ "environment": { "allRegionsAndLocales": true }
+ }
+ ]
+ },
+ {
+ "recordType": "defaultEngines",
+ "specificDefaults": []
+ },
+ {
+ "recordType": "engineOrders",
+ "orders": []
+ }
+ ]
+}
diff --git a/toolkit/components/telemetry/tests/unit/head.js b/toolkit/components/telemetry/tests/unit/head.js
index 7a9d8e41a2..e6cc7f4aa8 100644
--- a/toolkit/components/telemetry/tests/unit/head.js
+++ b/toolkit/components/telemetry/tests/unit/head.js
@@ -76,7 +76,7 @@ const PingServer = {
},
resetPingHandler() {
- this.registerPingHandler((request, response) => {
+ this.registerPingHandler(request => {
let r = request;
this._log.trace(
`defaultPingHandler() - ${r.method} ${r.scheme}://${r.host}:${r.port}${r.path}`
@@ -410,7 +410,7 @@ function fakeGzipCompressStringForNextPing(length) {
"resource://gre/modules/TelemetrySend.sys.mjs"
);
let largePayload = generateString(length);
- Policy.gzipCompressString = data => {
+ Policy.gzipCompressString = () => {
Policy.gzipCompressString = gzipCompressString;
return largePayload;
};
@@ -543,7 +543,7 @@ if (runningInParent) {
}
fakePingSendTimer(
- (callback, timeout) => {
+ callback => {
Services.tm.dispatchToMainThread(() => callback());
},
() => {}
diff --git a/toolkit/components/telemetry/tests/unit/test_EventPing.js b/toolkit/components/telemetry/tests/unit/test_EventPing.js
index 450e88a846..8ff05ee2e2 100644
--- a/toolkit/components/telemetry/tests/unit/test_EventPing.js
+++ b/toolkit/components/telemetry/tests/unit/test_EventPing.js
@@ -8,7 +8,7 @@ ChromeUtils.defineESModuleGetters(this, {
TelemetryEventPing: "resource://gre/modules/EventPing.sys.mjs",
});
-function checkPingStructure(type, payload, options) {
+function checkPingStructure(type, payload) {
Assert.equal(
type,
TelemetryEventPing.EVENT_PING_TYPE,
@@ -84,7 +84,7 @@ add_task(async function test_eventLimitReached() {
fakePolicy(pass, pass, fail);
recordEvents(999);
fakePolicy(
- (callback, delay) => {
+ () => {
Telemetry.recordEvent("telemetry.test", "test2", "object1");
fakePolicy(pass, pass, (type, payload, options) => {
checkPingStructure(type, payload, options);
@@ -120,7 +120,7 @@ add_task(async function test_eventLimitReached() {
fakePolicy(fail, fail, fail);
recordEvents(998);
fakePolicy(
- (callback, delay) => {
+ callback => {
Telemetry.recordEvent("telemetry.test", "test2", "object2");
Telemetry.recordEvent("telemetry.test", "test2", "object2");
fakePolicy(pass, pass, (type, payload, options) => {
@@ -162,7 +162,7 @@ add_task(async function test_eventLimitReached() {
// the two events we lost.
fakePolicy(fail, fail, fail);
recordEvents(999);
- fakePolicy((callback, delay) => {
+ fakePolicy(callback => {
fakePolicy(pass, pass, (type, payload, options) => {
checkPingStructure(type, payload, options);
Assert.ok(options.addClientId, "Adds the client id.");
diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryController.js b/toolkit/components/telemetry/tests/unit/test_TelemetryController.js
index 5af7adf6b0..d18dfd55e8 100644
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryController.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryController.js
@@ -536,7 +536,7 @@ add_task(async function test_midnightPingSendFuzzing() {
// A ping after midnight within the fuzzing delay should not get sent.
now = new Date(2030, 5, 2, 0, 40, 0);
fakeNow(now);
- PingServer.registerPingHandler((req, res) => {
+ PingServer.registerPingHandler(() => {
Assert.ok(false, "No ping should be received yet.");
});
let timerPromise = waitForTimer();
diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
index aa9fbf11f0..a67788623d 100644
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
@@ -426,7 +426,7 @@ add_task(async function test_addonsWatch_InterestingChange() {
return new Promise(resolve =>
TelemetryEnvironment.registerChangeListener(
"testWatchAddons_Changes" + aExpected,
- (reason, data) => {
+ reason => {
Assert.equal(reason, "addons-changed");
receivedNotifications++;
resolve();
@@ -630,13 +630,10 @@ add_task(async function test_addons() {
};
let deferred = Promise.withResolvers();
- TelemetryEnvironment.registerChangeListener(
- "test_WebExtension",
- (reason, data) => {
- Assert.equal(reason, "addons-changed");
- deferred.resolve();
- }
- );
+ TelemetryEnvironment.registerChangeListener("test_WebExtension", reason => {
+ Assert.equal(reason, "addons-changed");
+ deferred.resolve();
+ });
// Install an add-on so we have some data.
let addon = await installXPIFromURL(ADDON_INSTALL_URL);
@@ -881,7 +878,7 @@ add_task(async function test_collectionWithbrokenAddonData() {
return new Promise(resolve =>
TelemetryEnvironment.registerChangeListener(
"testBrokenAddon_collection" + aExpected,
- (reason, data) => {
+ reason => {
Assert.equal(reason, "addons-changed");
receivedNotifications++;
resolve();
@@ -1052,7 +1049,7 @@ add_task(async function test_experimentsAPI() {
const EXPERIMENT2 = "experiment-2";
const EXPERIMENT2_BRANCH = "other-branch";
- let checkExperiment = (environmentData, id, branch, type = null) => {
+ let checkExperiment = (environmentData, id, branch) => {
Assert.ok(
"experiments" in environmentData,
"The current environment must report the experiment annotations."
diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment_search.js b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment_search.js
index 0dc3849508..5d042cfb33 100644
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment_search.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment_search.js
@@ -7,6 +7,10 @@ const { TelemetryEnvironment } = ChromeUtils.importESModule(
const { SearchTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/SearchTestUtils.sys.mjs"
);
+
+const { SearchUtils } = ChromeUtils.importESModule(
+ "resource://gre/modules/SearchUtils.sys.mjs"
+);
const { TelemetryEnvironmentTesting } = ChromeUtils.importESModule(
"resource://testing-common/TelemetryEnvironmentTesting.sys.mjs"
);
@@ -140,10 +144,13 @@ async function checkDefaultSearch(privateOn, reInitSearchService) {
Assert.equal(data.settings.defaultSearchEngine, "telemetrySearchIdentifier");
let expectedSearchEngineData = {
name: "telemetrySearchIdentifier",
- loadPath: "[addon]telemetrySearchIdentifier@search.mozilla.org",
+ loadPath: SearchUtils.newSearchConfigEnabled
+ ? "[app]telemetrySearchIdentifier@search.mozilla.org"
+ : "[addon]telemetrySearchIdentifier@search.mozilla.org",
origin: "default",
- submissionURL:
- "https://ar.wikipedia.org/wiki/%D8%AE%D8%A7%D8%B5:%D8%A8%D8%AD%D8%AB?search=&sourceId=Mozilla-search",
+ submissionURL: SearchUtils.newSearchConfigEnabled
+ ? "https://ar.wikipedia.org/wiki/%D8%AE%D8%A7%D8%B5:%D8%A8%D8%AD%D8%AB?sourceId=Mozilla-search&search="
+ : "https://ar.wikipedia.org/wiki/%D8%AE%D8%A7%D8%B5:%D8%A8%D8%AD%D8%AB?search=&sourceId=Mozilla-search",
};
Assert.deepEqual(
data.settings.defaultSearchEngineData,
diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryEvents.js b/toolkit/components/telemetry/tests/unit/test_TelemetryEvents.js
index 4369c5a608..3d5e826914 100644
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEvents.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEvents.js
@@ -279,7 +279,7 @@ add_task(async function test_recording() {
// Check that the events were summarized properly.
let summaries = {};
- expected.forEach(({ optout, event }) => {
+ expected.forEach(({ event }) => {
let [category, eObject, method] = event;
let uniqueEventName = `${category}#${eObject}#${method}`;
if (!(uniqueEventName in summaries)) {
diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js b/toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js
index 1ac0c76351..bf66ef0d99 100644
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js
@@ -12,7 +12,7 @@ function numberRange(lower, upper) {
return a;
}
-function check_histogram(histogram_type, name, min, max, bucket_count) {
+function check_histogram(histogram_type, name, min, max) {
var h = Telemetry.getHistogramById(name);
h.add(0);
var s = h.snapshot();
@@ -507,7 +507,7 @@ add_task(async function test_keyed_boolean_histogram() {
sum: 1,
values: { 0: 0, 1: 1, 2: 0 },
};
- let testHistograms = numberRange(0, 3).map(i =>
+ let testHistograms = numberRange(0, 3).map(() =>
JSON.parse(JSON.stringify(histogramBase))
);
let testKeys = [];
@@ -558,7 +558,7 @@ add_task(async function test_keyed_count_histogram() {
sum: 0,
values: { 0: 1, 1: 0 },
};
- let testHistograms = numberRange(0, 5).map(i =>
+ let testHistograms = numberRange(0, 5).map(() =>
JSON.parse(JSON.stringify(histogramBase))
);
let testKeys = [];
diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryLateWrites.js b/toolkit/components/telemetry/tests/unit/test_TelemetryLateWrites.js
index 00891c36e8..fbc2e57271 100644
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryLateWrites.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryLateWrites.js
@@ -112,11 +112,7 @@ function actual_test() {
Assert.ok("memoryMap" in lateWrites);
Assert.equal(lateWrites.memoryMap.length, N_MODULES);
for (let id in LOADED_MODULES) {
- let matchingLibrary = lateWrites.memoryMap.filter(function (
- library,
- idx,
- array
- ) {
+ let matchingLibrary = lateWrites.memoryMap.filter(function (library) {
return library[1] == id;
});
Assert.equal(matchingLibrary.length, 1);
@@ -132,7 +128,7 @@ function actual_test() {
let second_stack = lateWrites.stacks[1];
function stackChecker(canonicalStack) {
let unevalCanonicalStack = uneval(canonicalStack);
- return function (obj, idx, array) {
+ return function (obj) {
return unevalCanonicalStack == obj;
};
}
diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetrySendOldPings.js b/toolkit/components/telemetry/tests/unit/test_TelemetrySendOldPings.js
index 7b7b0f674d..716b459680 100644
--- a/toolkit/components/telemetry/tests/unit/test_TelemetrySendOldPings.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetrySendOldPings.js
@@ -91,7 +91,7 @@ function assertReceivedPings(aExpectedNum) {
*
* @param aRequest the HTTP request sent from HttpServer.
*/
-function pingHandler(aRequest) {
+function pingHandler() {
gSeenPings++;
}
diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetrySession.js b/toolkit/components/telemetry/tests/unit/test_TelemetrySession.js
index 9267c96ce1..fbd2e5bee2 100644
--- a/toolkit/components/telemetry/tests/unit/test_TelemetrySession.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetrySession.js
@@ -923,7 +923,7 @@ add_task(async function test_dailyDuplication() {
Assert.equal(ping.payload.info.reason, REASON_DAILY);
// We don't expect to receive any other daily ping in this test, so assert if we do.
- PingServer.registerPingHandler((req, res) => {
+ PingServer.registerPingHandler(() => {
Assert.ok(
false,
"No more daily pings should be sent/received in this test."
@@ -967,7 +967,7 @@ add_task(async function test_dailyOverdue() {
fakeNow(now);
// Assert if we receive something!
- PingServer.registerPingHandler((req, res) => {
+ PingServer.registerPingHandler(() => {
Assert.ok(false, "No daily ping should be received if not overdue!.");
});
@@ -1396,7 +1396,7 @@ add_task(async function test_sendFirstShutdownPing() {
// the appropriate behavior from the preference flags.
// Assert failure if we recive a ping.
- PingServer.registerPingHandler((req, res) => {
+ PingServer.registerPingHandler(req => {
const receivedPing = decodeRequestPayload(req);
Assert.ok(
false,
@@ -2038,7 +2038,7 @@ add_task(async function test_schedulerEnvironmentReschedules() {
);
// We don't expect to receive any daily ping in this test, so assert if we do.
- PingServer.registerPingHandler((req, res) => {
+ PingServer.registerPingHandler(req => {
const receivedPing = decodeRequestPayload(req);
Assert.ok(
false,
@@ -2072,7 +2072,7 @@ add_task(async function test_schedulerNothingDue() {
await TelemetryController.testReset();
// We don't expect to receive any ping in this test, so assert if we do.
- PingServer.registerPingHandler((req, res) => {
+ PingServer.registerPingHandler(req => {
const receivedPing = decodeRequestPayload(req);
Assert.ok(
false,
diff --git a/toolkit/components/telemetry/tests/unit/xpcshell.toml b/toolkit/components/telemetry/tests/unit/xpcshell.toml
index 2dbaaff1a3..dbff9c627c 100644
--- a/toolkit/components/telemetry/tests/unit/xpcshell.toml
+++ b/toolkit/components/telemetry/tests/unit/xpcshell.toml
@@ -5,6 +5,7 @@ firefox-appdir = "browser"
# xpcshell fails to install tests if we move them under the test entry.
support-files = [
"data/search-extensions/engines.json",
+ "data/search-extensions/search-config-v2.json",
"data/search-extensions/telemetrySearchIdentifier/manifest.json",
"engine.xml",
"system.xpi",