summaryrefslogtreecommitdiffstats
path: root/browser/components/asrouter/tests/browser
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/asrouter/tests/browser')
-rw-r--r--browser/components/asrouter/tests/browser/browser_asrouter_cfr.js66
-rw-r--r--browser/components/asrouter/tests/browser/browser_asrouter_experimentsAPILoader.js2
-rw-r--r--browser/components/asrouter/tests/browser/browser_asrouter_targeting.js2
-rw-r--r--browser/components/asrouter/tests/browser/browser_feature_callout_panel.js2
-rw-r--r--browser/components/asrouter/tests/browser/browser_trigger_listeners.js4
-rw-r--r--browser/components/asrouter/tests/browser/head.js4
6 files changed, 36 insertions, 44 deletions
diff --git a/browser/components/asrouter/tests/browser/browser_asrouter_cfr.js b/browser/components/asrouter/tests/browser/browser_asrouter_cfr.js
index 0cab79994e..e29771c24f 100644
--- a/browser/components/asrouter/tests/browser/browser_asrouter_cfr.js
+++ b/browser/components/asrouter/tests/browser/browser_asrouter_cfr.js
@@ -183,7 +183,8 @@ add_setup(async function () {
// Store it in order to restore to the original value
const { _fetchLatestAddonVersion } = CFRPageActions;
// Prevent fetching the real addon url and making a network request
- CFRPageActions._fetchLatestAddonVersion = x => "http://example.com";
+ CFRPageActions._fetchLatestAddonVersion = () => "http://example.com";
+ Services.fog.testResetFOG();
registerCleanupFunction(() => {
CFRPageActions._fetchLatestAddonVersion = _fetchLatestAddonVersion;
@@ -193,20 +194,10 @@ add_setup(async function () {
});
add_task(async function test_cfr_notification_show() {
- registerCleanupFunction(() => {
- Services.prefs.clearUserPref(
- "browser.newtabpage.activity-stream.telemetry"
- );
- // Reset fog to clear pings here for private window test later.
- Services.fog.testResetFOG();
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.newtabpage.activity-stream.telemetry", true]],
});
- Services.prefs.setBoolPref(
- "browser.newtabpage.activity-stream.telemetry",
- true
- );
-
- Services.fog.testResetFOG();
let pingSubmitted = false;
GleanPings.messagingSystem.testBeforeNextSubmit(() => {
pingSubmitted = true;
@@ -266,6 +257,7 @@ add_task(async function test_cfr_notification_show() {
);
Assert.ok(pingSubmitted, "Recorded an event");
+ Services.fog.testResetFOG();
});
add_task(async function test_cfr_notification_show() {
@@ -332,6 +324,7 @@ add_task(async function test_cfr_notification_show() {
0,
"Should have removed the notification"
);
+ Services.fog.testResetFOG();
});
add_task(async function test_cfr_notification_minimize() {
@@ -379,6 +372,7 @@ add_task(async function test_cfr_notification_minimize() {
.getElementById("contextual-feature-recommendation-notification")
.button.click();
await hidePanel;
+ Services.fog.testResetFOG();
});
add_task(async function test_cfr_notification_minimize_2() {
@@ -441,6 +435,7 @@ add_task(async function test_cfr_notification_minimize_2() {
clearNotifications();
CFRPageActions.clearRecommendations();
+ Services.fog.testResetFOG();
});
add_task(async function test_cfr_addon_install() {
@@ -500,6 +495,7 @@ add_task(async function test_cfr_addon_install() {
);
clearNotifications();
+ Services.fog.testResetFOG();
});
add_task(
@@ -551,6 +547,7 @@ add_task(
await hidePanel;
await SpecialPowers.popPrefEnv();
clearNotifications();
+ Services.fog.testResetFOG();
}
);
@@ -642,6 +639,7 @@ add_task(async function test_cfr_addon_and_features_show() {
0,
"Should have removed the notification"
);
+ Services.fog.testResetFOG();
});
add_task(async function test_onLocationChange_cb() {
@@ -678,9 +676,8 @@ add_task(async function test_onLocationChange_cb() {
Assert.equal(count, 2, "We moved to a new document");
- registerCleanupFunction(() => {
- ASRouterTriggerListeners.get("openURL").uninit();
- });
+ ASRouterTriggerListeners.get("openURL").uninit();
+ Services.fog.testResetFOG();
});
add_task(async function test_matchPattern() {
@@ -730,9 +727,8 @@ add_task(async function test_matchPattern() {
"www.example.com is a different host that also matches the pattern."
);
- registerCleanupFunction(() => {
- ASRouterTriggerListeners.get("frequentVisits").uninit();
- });
+ ASRouterTriggerListeners.get("frequentVisits").uninit();
+ Services.fog.testResetFOG();
});
add_task(async function test_providerNames() {
@@ -741,11 +737,11 @@ add_task(async function test_providerNames() {
const cfrProviderPrefs = Services.prefs.getChildList(providersBranch);
for (const prefName of cfrProviderPrefs) {
const prefValue = JSON.parse(Services.prefs.getStringPref(prefName));
- if (prefValue && prefValue.id) {
+ if (prefValue?.id) {
Assert.equal(
prefValue.id,
prefName.slice(providersBranch.length),
- "Provider id and pref name do not match"
+ "Provider id and pref name should match"
);
}
}
@@ -804,6 +800,7 @@ add_task(async function test_cfr_notification_keyboard() {
.getElementById("contextual-feature-recommendation-notification")
.button.click();
await hidePanel;
+ Services.fog.testResetFOG();
});
add_task(function test_updateCycleForProviders() {
@@ -811,19 +808,18 @@ add_task(function test_updateCycleForProviders() {
.getChildList("browser.newtabpage.activity-stream.asrouter.providers.")
.forEach(provider => {
const prefValue = JSON.parse(Services.prefs.getStringPref(provider, ""));
- if (prefValue && prefValue.type === "remote-settings") {
- Assert.ok(prefValue.updateCycleInMs);
+ if (prefValue?.type === "remote-settings") {
+ is(
+ typeof prefValue.updateCycleInMs,
+ "number",
+ "updateCycleInMs is set"
+ );
}
});
});
add_task(async function test_heartbeat_tactic_2() {
clearNotifications();
- registerCleanupFunction(() => {
- // Remove the tab opened by clicking the heartbeat message
- gBrowser.removeCurrentTab();
- clearNotifications();
- });
const msg = (await CFRMessageProvider.getMessages()).find(
m => m.id === "HEARTBEAT_TACTIC_2"
@@ -858,18 +854,15 @@ add_task(async function test_heartbeat_tactic_2() {
document.getElementById("contextual-feature-recommendation").click();
await newTabPromise;
+ gBrowser.removeCurrentTab();
+ clearNotifications();
+ Services.fog.testResetFOG();
});
add_task(async function test_cfr_doorhanger_in_private_window() {
- registerCleanupFunction(() => {
- Services.prefs.clearUserPref(
- "browser.newtabpage.activity-stream.telemetry"
- );
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.newtabpage.activity-stream.telemetry", true]],
});
- Services.prefs.setBoolPref(
- "browser.newtabpage.activity-stream.telemetry",
- true
- );
let pingSubmitted = false;
GleanPings.messagingSystem.testBeforeNextSubmit(() => {
@@ -929,4 +922,5 @@ add_task(async function test_cfr_doorhanger_in_private_window() {
Assert.ok(pingSubmitted, "Submitted a CFR messaging system ping");
await BrowserTestUtils.closeWindow(win);
+ Services.fog.testResetFOG();
});
diff --git a/browser/components/asrouter/tests/browser/browser_asrouter_experimentsAPILoader.js b/browser/components/asrouter/tests/browser/browser_asrouter_experimentsAPILoader.js
index 14f4dda54f..88f284719e 100644
--- a/browser/components/asrouter/tests/browser/browser_asrouter_experimentsAPILoader.js
+++ b/browser/components/asrouter/tests/browser/browser_asrouter_experimentsAPILoader.js
@@ -444,7 +444,7 @@ add_task(async function test_emptyMessage() {
);
// Clear all messages
- ASRouter.setState(state => ({
+ ASRouter.setState(() => ({
messages: [],
}));
diff --git a/browser/components/asrouter/tests/browser/browser_asrouter_targeting.js b/browser/components/asrouter/tests/browser/browser_asrouter_targeting.js
index 432b4b75a7..55f278fd7d 100644
--- a/browser/components/asrouter/tests/browser/browser_asrouter_targeting.js
+++ b/browser/components/asrouter/tests/browser/browser_asrouter_targeting.js
@@ -93,7 +93,7 @@ add_task(async function return_nothing_for_no_matching_message() {
add_task(async function check_other_error_handling() {
let called = false;
- function onError(...args) {
+ function onError() {
called = true;
}
diff --git a/browser/components/asrouter/tests/browser/browser_feature_callout_panel.js b/browser/components/asrouter/tests/browser/browser_feature_callout_panel.js
index 1f87c71ec7..af2bc99e63 100644
--- a/browser/components/asrouter/tests/browser/browser_feature_callout_panel.js
+++ b/browser/components/asrouter/tests/browser/browser_feature_callout_panel.js
@@ -186,7 +186,7 @@ add_task(async function panel_feature_callout_anchor_open_attr() {
win.document.querySelector(calloutDismissSelector).click();
},
- (win, calloutContainer) => {
+ () => {
ok(
!anchor.hasAttribute("open"),
"Callout container's anchor node should not have its [open] attribute set"
diff --git a/browser/components/asrouter/tests/browser/browser_trigger_listeners.js b/browser/components/asrouter/tests/browser/browser_trigger_listeners.js
index 7c86645221..d7fb15b308 100644
--- a/browser/components/asrouter/tests/browser/browser_trigger_listeners.js
+++ b/browser/components/asrouter/tests/browser/browser_trigger_listeners.js
@@ -16,10 +16,10 @@ const mockIdleService = {
},
QueryInterface: ChromeUtils.generateQI(["nsIUserIdleService"]),
idleTime: 1200000,
- addIdleObserver(observer, time) {
+ addIdleObserver(observer) {
this._observers.add(observer);
},
- removeIdleObserver(observer, time) {
+ removeIdleObserver(observer) {
this._observers.delete(observer);
},
};
diff --git a/browser/components/asrouter/tests/browser/head.js b/browser/components/asrouter/tests/browser/head.js
index dd5e451540..51cd975d75 100644
--- a/browser/components/asrouter/tests/browser/head.js
+++ b/browser/components/asrouter/tests/browser/head.js
@@ -11,9 +11,7 @@ ChromeUtils.defineESModuleGetters(this, {
"resource:///modules/asrouter/FeatureCalloutMessages.sys.mjs",
PlacesTestUtils: "resource://testing-common/PlacesTestUtils.sys.mjs",
-});
-XPCOMUtils.defineLazyModuleGetters(this, {
- QueryCache: "resource:///modules/asrouter/ASRouterTargeting.jsm",
+ QueryCache: "resource:///modules/asrouter/ASRouterTargeting.sys.mjs",
});
const { FxAccounts } = ChromeUtils.importESModule(
"resource://gre/modules/FxAccounts.sys.mjs"