summaryrefslogtreecommitdiffstats
path: root/browser/components/asrouter/tests
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/asrouter/tests')
-rw-r--r--browser/components/asrouter/tests/InflightAssetsMessageProvider.sys.mjs112
-rw-r--r--browser/components/asrouter/tests/NimbusRolloutMessageProvider.sys.mjs421
-rw-r--r--browser/components/asrouter/tests/browser/browser.toml5
-rw-r--r--browser/components/asrouter/tests/browser/browser_asrouter_bug1761522.js2
-rw-r--r--browser/components/asrouter/tests/browser/browser_asrouter_cfr.js117
-rw-r--r--browser/components/asrouter/tests/browser/browser_asrouter_keyboard_cfr.js162
-rw-r--r--browser/components/asrouter/tests/browser/browser_asrouter_milestone_message_cfr.js78
-rw-r--r--browser/components/asrouter/tests/browser/browser_asrouter_momentspagehub.js4
-rw-r--r--browser/components/asrouter/tests/unit/ASRouter.test.js107
-rw-r--r--browser/components/asrouter/tests/unit/ASRouterChild.test.js3
-rw-r--r--browser/components/asrouter/tests/unit/ASRouterParent.test.js2
-rw-r--r--browser/components/asrouter/tests/unit/ASRouterParentProcessMessageHandler.test.js27
-rw-r--r--browser/components/asrouter/tests/unit/ToolbarBadgeHub.test.js166
-rw-r--r--browser/components/asrouter/tests/unit/ToolbarPanelHub.test.js760
-rw-r--r--browser/components/asrouter/tests/unit/content-src/components/ASRouterAdmin.test.jsx44
-rw-r--r--browser/components/asrouter/tests/unit/unit-entry.js2
-rw-r--r--browser/components/asrouter/tests/xpcshell/head.js4
-rw-r--r--browser/components/asrouter/tests/xpcshell/test_PanelTestProvider.js1
18 files changed, 718 insertions, 1299 deletions
diff --git a/browser/components/asrouter/tests/InflightAssetsMessageProvider.sys.mjs b/browser/components/asrouter/tests/InflightAssetsMessageProvider.sys.mjs
index e92b210c12..adb14ecc38 100644
--- a/browser/components/asrouter/tests/InflightAssetsMessageProvider.sys.mjs
+++ b/browser/components/asrouter/tests/InflightAssetsMessageProvider.sys.mjs
@@ -10,58 +10,10 @@ export const InflightAssetsMessageProvider = {
getMessages() {
return [
{
- id: "MILESTONE_MESSAGE",
- groups: ["cfr"],
- content: {
- anchor_id: "tracking-protection-icon-box",
- bucket_id: "CFR_MILESTONE_MESSAGE",
- buttons: {
- primary: {
- action: {
- type: "OPEN_PROTECTION_REPORT",
- },
- event: "PROTECTION",
- label: {
- string_id: "cfr-doorhanger-milestone-ok-button",
- },
- },
- secondary: [
- {
- label: {
- string_id: "cfr-doorhanger-milestone-close-button",
- },
- action: {
- type: "CANCEL",
- },
- event: "DISMISS",
- },
- ],
- },
- category: "cfrFeatures",
- heading_text: {
- string_id: "cfr-doorhanger-milestone-heading",
- },
- layout: "short_message",
- notification_text: "",
- skip_address_bar_notifier: true,
- text: "",
- },
- frequency: {
- lifetime: 7,
- },
- targeting:
- "pageLoad >= 4 && firefoxVersion < 87 && userPrefs.cfrFeatures",
- template: "milestone_message",
- trigger: {
- id: "contentBlocking",
- params: ["ContentBlockingMilestone"],
- },
- },
- {
id: "MILESTONE_MESSAGE_87",
groups: ["cfr"],
content: {
- anchor_id: "tracking-protection-icon-box",
+ anchor_id: "tracking-protection-icon-container",
bucket_id: "CFR_MILESTONE_MESSAGE",
buttons: {
primary: {
@@ -98,7 +50,7 @@ export const InflightAssetsMessageProvider = {
lifetime: 7,
},
targeting:
- "pageLoad >= 4 && firefoxVersion >= 87 && userPrefs.cfrFeatures",
+ "pageLoad >= 4 && firefoxVersion >= 115 && firefoxVersion < 121 && userPrefs.cfrFeatures",
template: "milestone_message",
trigger: {
id: "contentBlocking",
@@ -275,66 +227,6 @@ export const InflightAssetsMessageProvider = {
],
},
},
- {
- id: "WNP_MOMENTS_12",
- groups: ["moments-pages"],
- content: {
- action: {
- data: {
- expire: 1640908800000,
- url: "https://www.mozilla.org/firefox/welcome/12",
- },
- id: "moments-wnp",
- },
- bucket_id: "WNP_MOMENTS_12",
- },
- targeting:
- 'localeLanguageCode == "en" && region in ["DE", "AT", "BE", "CA", "FR", "IE", "IT", "MY", "NL", "NZ", "SG", "CH", "US", "GB", "ES"] && (addonsInfo.addons|keys intersect ["@testpilot-containers"])|length == 1 && \'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features\'|preferenceValue && \'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons\'|preferenceValue',
- template: "update_action",
- trigger: {
- id: "momentsUpdate",
- },
- },
- {
- id: "WNP_MOMENTS_13",
- groups: ["moments-pages"],
- content: {
- action: {
- data: {
- expire: 1640908800000,
- url: "https://www.mozilla.org/firefox/welcome/13",
- },
- id: "moments-wnp",
- },
- bucket_id: "WNP_MOMENTS_13",
- },
- targeting:
- '(localeLanguageCode in ["en", "de", "fr", "nl", "it", "ms"] || locale == "es-ES") && region in ["DE", "AT", "BE", "CA", "FR", "IE", "IT", "MY", "NL", "NZ", "SG", "CH", "US", "GB", "ES"] && (addonsInfo.addons|keys intersect ["@testpilot-containers"])|length == 0 && \'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features\'|preferenceValue && \'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons\'|preferenceValue',
- template: "update_action",
- trigger: {
- id: "momentsUpdate",
- },
- },
- {
- id: "WNP_MOMENTS_14",
- groups: ["moments-pages"],
- content: {
- action: {
- data: {
- expire: 1668470400000,
- url: "https://www.mozilla.org/firefox/welcome/14",
- },
- id: "moments-wnp",
- },
- bucket_id: "WNP_MOMENTS_14",
- },
- targeting:
- 'localeLanguageCode in ["en", "de", "fr"] && region in ["AT", "BE", "CA", "CH", "DE", "ES", "FI", "FR", "GB", "IE", "IT", "MY", "NL", "NZ", "SE", "SG", "US"] && \'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features\'|preferenceValue && \'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons\'|preferenceValue',
- template: "update_action",
- trigger: {
- id: "momentsUpdate",
- },
- },
];
},
};
diff --git a/browser/components/asrouter/tests/NimbusRolloutMessageProvider.sys.mjs b/browser/components/asrouter/tests/NimbusRolloutMessageProvider.sys.mjs
index 5bfbec9557..f2c94f7de6 100644
--- a/browser/components/asrouter/tests/NimbusRolloutMessageProvider.sys.mjs
+++ b/browser/components/asrouter/tests/NimbusRolloutMessageProvider.sys.mjs
@@ -12,6 +12,427 @@ export const NimbusRolloutMessageProvider = {
getMessages() {
return [
{
+ // Nimbus slug: device-migration-q4-spotlights-remaining-population-esr:treatment (message 1 of 3)
+ // Recipe: https://experimenter.services.mozilla.com/nimbus/device-migration-q4-spotlights-remaining-population-esr/summary#treatment
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT",
+ groups: ["eco"],
+ content: {
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT",
+ modal: "tab",
+ screens: [
+ {
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT_BACKUP",
+ content: {
+ logo: {
+ height: "152px",
+ imageURL:
+ "https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/c92a41e4-82cf-4ad5-8480-04a138bfb3cd.png",
+ },
+ title: {
+ fontSize: "24px",
+ string_id: "device-migration-fxa-spotlight-heavy-user-header",
+ letterSpacing: 0,
+ },
+ subtitle: {
+ fontSize: "15px",
+ string_id: "device-migration-fxa-spotlight-heavy-user-body",
+ lineHeight: "1.4",
+ marginBlock: "8px 20px",
+ letterSpacing: 0,
+ paddingInline: "20px",
+ },
+ dismiss_button: {
+ action: {
+ navigate: true,
+ },
+ },
+ primary_button: {
+ label: {
+ string_id:
+ "device-migration-fxa-spotlight-heavy-user-primary-button",
+ paddingBlock: "4px",
+ paddingInline: "16px",
+ },
+ action: {
+ data: {
+ args: "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/switching-devices?utm_source=spotlight-default&utm_medium=firefox-desktop&utm_campaign=migration&utm_content=dont-forget-to-backup&entrypoint=device-migration-spotlight-experiment-v2",
+ where: "tabshifted",
+ },
+ type: "OPEN_URL",
+ navigate: true,
+ },
+ },
+ },
+ },
+ ],
+ backdrop: "transparent",
+ template: "multistage",
+ transitions: true,
+ },
+ trigger: {
+ id: "defaultBrowserCheck",
+ },
+ template: "spotlight",
+ frequency: {
+ lifetime: 1,
+ },
+ targeting:
+ "source == 'startup' && !willShowDefaultPrompt && 'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features'|preferenceValue && !usesFirefoxSync && !hasActiveEnterprisePolicies && userMonthlyActivity[userMonthlyActivity|length - 2][1]|date >= currentDate|date - (28 * 24 * 60 * 60 * 1000) && (((currentDate|date - profileAgeCreated|date) / 86400000 >= 168) || totalBookmarksCount >= 35)",
+ },
+ {
+ // Nimbus slug: device-migration-q4-spotlights-remaining-population-esr:treatment (message 2 of 3)
+ // Recipe: https://experimenter.services.mozilla.com/nimbus/device-migration-q4-spotlights-remaining-population-esr/summary#treatment
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT",
+ groups: ["eco"],
+ content: {
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT",
+ modal: "tab",
+ screens: [
+ {
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT_PEACE",
+ content: {
+ logo: {
+ height: "133px",
+ imageURL:
+ "https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/4a56d3ed-98c8-4a33-b853-b2cf7646efd8.png",
+ marginBlock: "22px -10px",
+ },
+ title: {
+ fontSize: "24px",
+ string_id:
+ "device-migration-fxa-spotlight-older-device-header",
+ letterSpacing: 0,
+ },
+ subtitle: {
+ fontSize: "15px",
+ string_id: "device-migration-fxa-spotlight-older-device-body",
+ lineHeight: "1.4",
+ marginBlock: "8px 20px",
+ letterSpacing: 0,
+ paddingInline: "40px",
+ },
+ dismiss_button: {
+ action: {
+ navigate: true,
+ },
+ },
+ primary_button: {
+ label: {
+ string_id:
+ "device-migration-fxa-spotlight-older-device-primary-button",
+ marginBlock: "0 22px",
+ paddingBlock: "4px",
+ paddingInline: "16px",
+ },
+ action: {
+ data: {
+ args: "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/switching-devices?utm_source=spotlight-default&utm_medium=firefox-desktop&utm_campaign=migration&utm_content=peace-of-mind&entrypoint=device-migration-spotlight-experiment-v2",
+ where: "tabshifted",
+ },
+ type: "OPEN_URL",
+ navigate: true,
+ },
+ },
+ },
+ },
+ ],
+ backdrop: "transparent",
+ template: "multistage",
+ transitions: true,
+ },
+ trigger: {
+ id: "defaultBrowserCheck",
+ },
+ template: "spotlight",
+ frequency: {
+ lifetime: 1,
+ },
+ targeting:
+ "source == 'startup' && !willShowDefaultPrompt && 'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features'|preferenceValue && !usesFirefoxSync && !hasActiveEnterprisePolicies && userMonthlyActivity[userMonthlyActivity|length - 2][1]|date >= currentDate|date - (28 * 24 * 60 * 60 * 1000) && !(((currentDate|date - profileAgeCreated|date) / 86400000 >= 168) || totalBookmarksCount >= 35) && os.isWindows && os.windowsVersion >= 6.1 && os.windowsBuildNumber < 22000",
+ },
+ {
+ // Nimbus slug: device-migration-q4-spotlights-remaining-population-esr:treatment (message 3 of 3)
+ // Recipe: https://experimenter.services.mozilla.com/nimbus/device-migration-q4-spotlights-remaining-population-esr/summary#treatment
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT",
+ groups: ["eco"],
+ content: {
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT",
+ modal: "tab",
+ screens: [
+ {
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT_NEW_DEVICE",
+ content: {
+ logo: {
+ height: "149px",
+ imageURL:
+ "https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/a43cd9cc-e8b2-477c-92f2-345557370de1.svg",
+ },
+ title: {
+ fontSize: "24px",
+ string_id:
+ "device-migration-fxa-spotlight-getting-new-device-header-2",
+ letterSpacing: 0,
+ },
+ subtitle: {
+ fontSize: "15px",
+ string_id:
+ "device-migration-fxa-spotlight-getting-new-device-body-2",
+ lineHeight: "1.4",
+ marginBlock: "8px 20px",
+ letterSpacing: 0,
+ paddingInline: "40px",
+ },
+ dismiss_button: {
+ action: {
+ navigate: true,
+ },
+ },
+ primary_button: {
+ label: {
+ string_id:
+ "device-migration-fxa-spotlight-getting-new-device-primary-button",
+ paddingBlock: "4px",
+ paddingInline: "16px",
+ },
+ action: {
+ data: {
+ args: "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/switching-devices?utm_source=spotlight-default&utm_medium=firefox-desktop&utm_campaign=migration&utm_content=new-device-in-your-future&entrypoint=device-migration-spotlight-experiment-v2",
+ where: "tabshifted",
+ },
+ type: "OPEN_URL",
+ navigate: true,
+ },
+ },
+ },
+ },
+ ],
+ backdrop: "transparent",
+ template: "multistage",
+ transitions: true,
+ },
+ trigger: {
+ id: "defaultBrowserCheck",
+ },
+ template: "spotlight",
+ frequency: {
+ lifetime: 1,
+ },
+ targeting:
+ "source == 'startup' && !willShowDefaultPrompt && 'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features'|preferenceValue && !usesFirefoxSync && !hasActiveEnterprisePolicies && userMonthlyActivity[userMonthlyActivity|length - 2][1]|date >= currentDate|date - (28 * 24 * 60 * 60 * 1000) && !(((currentDate|date - profileAgeCreated|date) / 86400000 >= 168) || totalBookmarksCount >= 35) && !(os.isWindows && os.windowsVersion >= 6.1 && os.windowsBuildNumber < 22000)",
+ },
+ {
+ // Nimbus slug: device-migration-q4-spotlights-remaining-population:treatment (message 1 of 3)
+ // Version range: 122+
+ // Recipe: https://experimenter.services.mozilla.com/nimbus/device-migration-q4-spotlights-remaining-population/summary#treatment
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT",
+ groups: ["eco"],
+ content: {
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT",
+ modal: "tab",
+ screens: [
+ {
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT_BACKUP",
+ content: {
+ logo: {
+ height: "152px",
+ imageURL:
+ "https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/c92a41e4-82cf-4ad5-8480-04a138bfb3cd.png",
+ },
+ title: {
+ fontSize: "24px",
+ string_id: "device-migration-fxa-spotlight-heavy-user-header",
+ letterSpacing: 0,
+ },
+ subtitle: {
+ fontSize: "15px",
+ string_id: "device-migration-fxa-spotlight-heavy-user-body",
+ lineHeight: "1.4",
+ marginBlock: "8px 20px",
+ letterSpacing: 0,
+ paddingInline: "20px",
+ },
+ dismiss_button: {
+ action: {
+ navigate: true,
+ },
+ },
+ primary_button: {
+ label: {
+ string_id:
+ "device-migration-fxa-spotlight-heavy-user-primary-button",
+ paddingBlock: "4px",
+ paddingInline: "16px",
+ },
+ action: {
+ data: {
+ args: "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/switching-devices?utm_source=spotlight-default&utm_medium=firefox-desktop&utm_campaign=migration&utm_content=dont-forget-to-backup&entrypoint=device-migration-spotlight-experiment-v2",
+ where: "tabshifted",
+ },
+ type: "OPEN_URL",
+ navigate: true,
+ },
+ },
+ },
+ },
+ ],
+ backdrop: "transparent",
+ template: "multistage",
+ transitions: true,
+ },
+ trigger: {
+ id: "defaultBrowserCheck",
+ },
+ template: "spotlight",
+ frequency: {
+ lifetime: 1,
+ },
+ targeting:
+ "source == 'startup' && !willShowDefaultPrompt && 'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features'|preferenceValue && !usesFirefoxSync && !hasActiveEnterprisePolicies && userMonthlyActivity[userMonthlyActivity|length - 2][1]|date >= currentDate|date - (28 * 24 * 60 * 60 * 1000) && (((currentDate|date - profileAgeCreated|date) / 86400000 >= 168) || totalBookmarksCount >= 35)",
+ },
+ {
+ // Nimbus slug: device-migration-q4-spotlights-remaining-population:treatment (message 2 of 3)
+ // Version range: 122+
+ // Recipe: https://experimenter.services.mozilla.com/nimbus/device-migration-q4-spotlights-remaining-population/summary#treatment
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT",
+ groups: ["eco"],
+ content: {
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT",
+ modal: "tab",
+ screens: [
+ {
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT_PEACE",
+ content: {
+ logo: {
+ height: "133px",
+ imageURL:
+ "https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/4a56d3ed-98c8-4a33-b853-b2cf7646efd8.png",
+ marginBlock: "22px -10px",
+ },
+ title: {
+ fontSize: "24px",
+ string_id:
+ "device-migration-fxa-spotlight-older-device-header",
+ letterSpacing: 0,
+ },
+ subtitle: {
+ fontSize: "15px",
+ string_id: "device-migration-fxa-spotlight-older-device-body",
+ lineHeight: "1.4",
+ marginBlock: "8px 20px",
+ letterSpacing: 0,
+ paddingInline: "40px",
+ },
+ dismiss_button: {
+ action: {
+ navigate: true,
+ },
+ },
+ primary_button: {
+ label: {
+ string_id:
+ "device-migration-fxa-spotlight-older-device-primary-button",
+ marginBlock: "0 22px",
+ paddingBlock: "4px",
+ paddingInline: "16px",
+ },
+ action: {
+ data: {
+ args: "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/switching-devices?utm_source=spotlight-default&utm_medium=firefox-desktop&utm_campaign=migration&utm_content=peace-of-mind&entrypoint=device-migration-spotlight-experiment-v2",
+ where: "tabshifted",
+ },
+ type: "OPEN_URL",
+ navigate: true,
+ },
+ },
+ },
+ },
+ ],
+ backdrop: "transparent",
+ template: "multistage",
+ transitions: true,
+ },
+ trigger: {
+ id: "defaultBrowserCheck",
+ },
+ template: "spotlight",
+ frequency: {
+ lifetime: 1,
+ },
+ targeting:
+ "source == 'startup' && !willShowDefaultPrompt && 'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features'|preferenceValue && !usesFirefoxSync && !hasActiveEnterprisePolicies && userMonthlyActivity[userMonthlyActivity|length - 2][1]|date >= currentDate|date - (28 * 24 * 60 * 60 * 1000) && !(((currentDate|date - profileAgeCreated|date) / 86400000 >= 168) || totalBookmarksCount >= 35) && os.isWindows && os.windowsVersion >= 6.1 && os.windowsBuildNumber < 22000",
+ },
+ {
+ // Nimbus slug: device-migration-q4-spotlights-remaining-population:treatment (message 3 of 3)
+ // Version range: 122+
+ // Recipe: https://experimenter.services.mozilla.com/nimbus/device-migration-q4-spotlights-remaining-population/summary#treatment
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT",
+ groups: ["eco"],
+ content: {
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT",
+ modal: "tab",
+ screens: [
+ {
+ id: "Q4_DEVICE_MIGRATION_BACKUP_SPOTLIGHT_NEW_DEVICE",
+ content: {
+ logo: {
+ height: "149px",
+ imageURL:
+ "https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/a43cd9cc-e8b2-477c-92f2-345557370de1.svg",
+ },
+ title: {
+ fontSize: "24px",
+ string_id:
+ "device-migration-fxa-spotlight-getting-new-device-header-2",
+ letterSpacing: 0,
+ },
+ subtitle: {
+ fontSize: "15px",
+ string_id:
+ "device-migration-fxa-spotlight-getting-new-device-body-2",
+ lineHeight: "1.4",
+ marginBlock: "8px 20px",
+ letterSpacing: 0,
+ paddingInline: "40px",
+ },
+ dismiss_button: {
+ action: {
+ navigate: true,
+ },
+ },
+ primary_button: {
+ label: {
+ string_id:
+ "device-migration-fxa-spotlight-getting-new-device-primary-button",
+ paddingBlock: "4px",
+ paddingInline: "16px",
+ },
+ action: {
+ data: {
+ args: "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/switching-devices?utm_source=spotlight-default&utm_medium=firefox-desktop&utm_campaign=migration&utm_content=new-device-in-your-future&entrypoint=device-migration-spotlight-experiment-v2",
+ where: "tabshifted",
+ },
+ type: "OPEN_URL",
+ navigate: true,
+ },
+ },
+ },
+ },
+ ],
+ backdrop: "transparent",
+ template: "multistage",
+ transitions: true,
+ },
+ trigger: {
+ id: "defaultBrowserCheck",
+ },
+ template: "spotlight",
+ frequency: {
+ lifetime: 1,
+ },
+ targeting:
+ "source == 'startup' && !willShowDefaultPrompt && 'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features'|preferenceValue && !usesFirefoxSync && !hasActiveEnterprisePolicies && userMonthlyActivity[userMonthlyActivity|length - 2][1]|date >= currentDate|date - (28 * 24 * 60 * 60 * 1000) && !(((currentDate|date - profileAgeCreated|date) / 86400000 >= 168) || totalBookmarksCount >= 35) && !(os.isWindows && os.windowsVersion >= 6.1 && os.windowsBuildNumber < 22000)",
+ },
+ {
// Nimbus slug: fox-doodle-set-to-default-early-day-user-de-fr-it-treatment-a-rollout:treatment-a
// Version range: 116+
// Recipe: https://experimenter.services.mozilla.com/nimbus/fox-doodle-set-to-default-early-day-user-de-fr-it-treatment-a-rollout/summary#treatment-a
diff --git a/browser/components/asrouter/tests/browser/browser.toml b/browser/components/asrouter/tests/browser/browser.toml
index 7bed40373d..60ce42dfd8 100644
--- a/browser/components/asrouter/tests/browser/browser.toml
+++ b/browser/components/asrouter/tests/browser/browser.toml
@@ -21,6 +21,11 @@ skip-if = ["os == 'linux' && bits == 64 && !debug"] # Bug 1643036
["browser_asrouter_infobar.js"]
+["browser_asrouter_keyboard_cfr.js"]
+https_first_disabled = true
+
+["browser_asrouter_milestone_message_cfr.js"]
+
["browser_asrouter_momentspagehub.js"]
tags = "remote-settings"
diff --git a/browser/components/asrouter/tests/browser/browser_asrouter_bug1761522.js b/browser/components/asrouter/tests/browser/browser_asrouter_bug1761522.js
index 19fcb63131..d22605d589 100644
--- a/browser/components/asrouter/tests/browser/browser_asrouter_bug1761522.js
+++ b/browser/components/asrouter/tests/browser/browser_asrouter_bug1761522.js
@@ -20,7 +20,7 @@ const { RemoteSettings } = ChromeUtils.importESModule(
);
// This pref is used to override the Remote Settings server URL in tests.
-// See SERVER_URL in services/settings/Utils.jsm for more details.
+// See SERVER_URL in services/settings/Utils.sys.mjs for more details.
const RS_SERVER_PREF = "services.settings.server";
const FLUENT_CONTENT = "asrouter-test-string = Test Test Test\n";
diff --git a/browser/components/asrouter/tests/browser/browser_asrouter_cfr.js b/browser/components/asrouter/tests/browser/browser_asrouter_cfr.js
index e29771c24f..1979c81a79 100644
--- a/browser/components/asrouter/tests/browser/browser_asrouter_cfr.js
+++ b/browser/components/asrouter/tests/browser/browser_asrouter_cfr.js
@@ -115,14 +115,6 @@ function checkCFRAddonsElements(notification) {
);
}
-function checkCFRTrackingProtectionMilestone(notification) {
- Assert.ok(notification.hidden === false, "Panel should be visible");
- Assert.ok(
- notification.getAttribute("data-notification-category") === "short_message",
- "Panel have correct data attribute"
- );
-}
-
function clearNotifications() {
for (let notification of PopupNotifications._currentNotifications) {
notification.remove();
@@ -498,59 +490,6 @@ add_task(async function test_cfr_addon_install() {
Services.fog.testResetFOG();
});
-add_task(
- async function test_cfr_tracking_protection_milestone_notification_remove() {
- await SpecialPowers.pushPrefEnv({
- set: [
- ["browser.contentblocking.cfr-milestone.milestone-achieved", 1000],
- [
- "browser.newtabpage.activity-stream.asrouter.providers.cfr",
- `{"id":"cfr","enabled":true,"type":"local","localProvider":"CFRMessageProvider","updateCycleInMs":3600000}`,
- ],
- ],
- });
-
- // addRecommendation checks that scheme starts with http and host matches
- let browser = gBrowser.selectedBrowser;
- BrowserTestUtils.startLoadingURIString(browser, "http://example.com/");
- await BrowserTestUtils.browserLoaded(browser, false, "http://example.com/");
-
- const showPanel = BrowserTestUtils.waitForEvent(
- PopupNotifications.panel,
- "popupshown"
- );
-
- Services.obs.notifyObservers(
- {
- wrappedJSObject: {
- event: "ContentBlockingMilestone",
- },
- },
- "SiteProtection:ContentBlockingMilestone"
- );
-
- await showPanel;
-
- const notification = document.getElementById(
- "contextual-feature-recommendation-notification"
- );
-
- checkCFRTrackingProtectionMilestone(notification);
-
- Assert.ok(notification.secondaryButton);
- let hidePanel = BrowserTestUtils.waitForEvent(
- PopupNotifications.panel,
- "popuphidden"
- );
-
- notification.secondaryButton.click();
- await hidePanel;
- await SpecialPowers.popPrefEnv();
- clearNotifications();
- Services.fog.testResetFOG();
- }
-);
-
add_task(async function test_cfr_addon_and_features_show() {
// addRecommendation checks that scheme starts with http and host matches
let browser = gBrowser.selectedBrowser;
@@ -747,62 +686,6 @@ add_task(async function test_providerNames() {
}
});
-add_task(async function test_cfr_notification_keyboard() {
- // addRecommendation checks that scheme starts with http and host matches
- const browser = gBrowser.selectedBrowser;
- BrowserTestUtils.startLoadingURIString(browser, "http://example.com/");
- await BrowserTestUtils.browserLoaded(browser, false, "http://example.com/");
-
- const response = await trigger_cfr_panel(browser, "example.com");
- Assert.ok(
- response,
- "Should return true if addRecommendation checks were successful"
- );
-
- // Open the panel with the keyboard.
- // Toolbar buttons aren't always focusable; toolbar keyboard navigation
- // makes them focusable on demand. Therefore, we must force focus.
- const button = document.getElementById("contextual-feature-recommendation");
- button.setAttribute("tabindex", "-1");
- button.focus();
- button.removeAttribute("tabindex");
-
- let focused = BrowserTestUtils.waitForEvent(
- PopupNotifications.panel,
- "focus",
- true
- );
- EventUtils.synthesizeKey(" ");
- await focused;
- Assert.ok(true, "Focus inside panel after button pressed");
-
- let hidden = BrowserTestUtils.waitForEvent(
- PopupNotifications.panel,
- "popuphidden"
- );
- EventUtils.synthesizeKey("KEY_Escape");
- await hidden;
- Assert.ok(true, "Panel hidden after Escape pressed");
-
- const showPanel = BrowserTestUtils.waitForEvent(
- PopupNotifications.panel,
- "popupshown"
- );
- // Need to dismiss the notification to clear the RecommendationMap
- document.getElementById("contextual-feature-recommendation").click();
- await showPanel;
-
- const hidePanel = BrowserTestUtils.waitForEvent(
- PopupNotifications.panel,
- "popuphidden"
- );
- document
- .getElementById("contextual-feature-recommendation-notification")
- .button.click();
- await hidePanel;
- Services.fog.testResetFOG();
-});
-
add_task(function test_updateCycleForProviders() {
Services.prefs
.getChildList("browser.newtabpage.activity-stream.asrouter.providers.")
diff --git a/browser/components/asrouter/tests/browser/browser_asrouter_keyboard_cfr.js b/browser/components/asrouter/tests/browser/browser_asrouter_keyboard_cfr.js
new file mode 100644
index 0000000000..c3dfc0b0bb
--- /dev/null
+++ b/browser/components/asrouter/tests/browser/browser_asrouter_keyboard_cfr.js
@@ -0,0 +1,162 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* eslint-disable @microsoft/sdl/no-insecure-url */
+function clearNotifications() {
+ for (let notification of PopupNotifications._currentNotifications) {
+ notification.remove();
+ }
+
+ // Clicking the primary action also removes the notification
+ Assert.equal(
+ PopupNotifications._currentNotifications.length,
+ 0,
+ "Should have removed the notification"
+ );
+}
+
+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 = () => "http://example.com";
+ Services.fog.testResetFOG();
+
+ registerCleanupFunction(() => {
+ CFRPageActions._fetchLatestAddonVersion = _fetchLatestAddonVersion;
+ clearNotifications();
+ CFRPageActions.clearRecommendations();
+ });
+});
+
+add_task(async function test_cfr_notification_keyboard() {
+ // addRecommendation checks that scheme starts with http and host matches
+ const browser = gBrowser.selectedBrowser;
+ BrowserTestUtils.startLoadingURIString(browser, "http://example.com/");
+ await BrowserTestUtils.browserLoaded(browser, false, "http://example.com/");
+
+ clearNotifications();
+
+ let recommendation = {
+ template: "cfr_doorhanger",
+ groups: ["mochitest-group"],
+ content: {
+ layout: "addon_recommendation",
+ category: "cfrAddons",
+ anchor_id: "page-action-buttons",
+ icon_class: "cfr-doorhanger-medium-icon",
+ skip_address_bar_notifier: false,
+ heading_text: "Sample Mochitest",
+ icon: "chrome://activity-stream/content/data/content/assets/glyph-webextension-16.svg",
+ icon_dark_theme:
+ "chrome://activity-stream/content/data/content/assets/glyph-webextension-16.svg",
+ info_icon: {
+ label: { attributes: { tooltiptext: "Why am I seeing this" } },
+ sumo_path: "extensionrecommendations",
+ },
+ addon: {
+ id: "addon-id",
+ title: "Addon name",
+ icon: "chrome://browser/skin/addons/addon-install-downloading.svg",
+ author: "Author name",
+ amo_url: "https://example.com",
+ rating: "4.5",
+ users: "1.1M",
+ },
+ text: "Mochitest",
+ buttons: {
+ primary: {
+ label: {
+ value: "OK",
+ attributes: { accesskey: "O" },
+ },
+ action: {
+ type: "CANCEL",
+ data: {},
+ },
+ },
+ secondary: [
+ {
+ label: {
+ value: "Cancel",
+ attributes: { accesskey: "C" },
+ },
+ action: {
+ type: "CANCEL",
+ },
+ },
+ ],
+ },
+ },
+ };
+
+ recommendation.content.notification_text = new String("Mochitest"); // eslint-disable-line
+ recommendation.content.notification_text.attributes = {
+ tooltiptext: "Mochitest tooltip",
+ "a11y-announcement": "Mochitest announcement",
+ };
+
+ const response = await CFRPageActions.addRecommendation(
+ gBrowser.selectedBrowser,
+ "example.com",
+ recommendation,
+ // Use the real AS dispatch method to trigger real notifications
+ ASRouter.dispatchCFRAction
+ );
+
+ Assert.ok(
+ response,
+ "Should return true if addRecommendation checks were successful"
+ );
+
+ // Open the panel with the keyboard.
+ // Toolbar buttons aren't always focusable; toolbar keyboard navigation
+ // makes them focusable on demand. Therefore, we must force focus.
+ const button = document.getElementById("contextual-feature-recommendation");
+ button.setAttribute("tabindex", "-1");
+
+ let buttonFocused = BrowserTestUtils.waitForEvent(button, "focus");
+ button.focus();
+ await buttonFocused;
+
+ Assert.ok(true, "Focus page action button");
+
+ let focused = BrowserTestUtils.waitForEvent(
+ PopupNotifications.panel,
+ "focus",
+ true
+ );
+
+ EventUtils.synthesizeKey(" ");
+ await focused;
+ Assert.ok(true, "Focus inside panel after button pressed");
+
+ button.removeAttribute("tabindex");
+
+ let hidden = BrowserTestUtils.waitForEvent(
+ PopupNotifications.panel,
+ "popuphidden"
+ );
+ EventUtils.synthesizeKey("KEY_Escape");
+ await hidden;
+ Assert.ok(true, "Panel hidden after Escape pressed");
+
+ const showPanel = BrowserTestUtils.waitForEvent(
+ PopupNotifications.panel,
+ "popupshown"
+ );
+ // Need to dismiss the notification to clear the RecommendationMap
+ document.getElementById("contextual-feature-recommendation").click();
+ await showPanel;
+
+ const hidePanel = BrowserTestUtils.waitForEvent(
+ PopupNotifications.panel,
+ "popuphidden"
+ );
+ document
+ .getElementById("contextual-feature-recommendation-notification")
+ .button.click();
+ await hidePanel;
+ Services.fog.testResetFOG();
+});
diff --git a/browser/components/asrouter/tests/browser/browser_asrouter_milestone_message_cfr.js b/browser/components/asrouter/tests/browser/browser_asrouter_milestone_message_cfr.js
new file mode 100644
index 0000000000..6585963d6f
--- /dev/null
+++ b/browser/components/asrouter/tests/browser/browser_asrouter_milestone_message_cfr.js
@@ -0,0 +1,78 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* eslint-disable @microsoft/sdl/no-insecure-url */
+function checkCFRTrackingProtectionMilestone(notification) {
+ Assert.ok(notification.hidden === false, "Panel should be visible");
+ Assert.ok(
+ notification.getAttribute("data-notification-category") === "short_message",
+ "Panel have correct data attribute"
+ );
+}
+
+function clearNotifications() {
+ for (let notification of PopupNotifications._currentNotifications) {
+ notification.remove();
+ }
+
+ // Clicking the primary action also removes the notification
+ Assert.equal(
+ PopupNotifications._currentNotifications.length,
+ 0,
+ "Should have removed the notification"
+ );
+}
+
+add_task(
+ async function test_cfr_tracking_protection_milestone_notification_remove() {
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["browser.contentblocking.cfr-milestone.milestone-achieved", 1000],
+ [
+ "browser.newtabpage.activity-stream.asrouter.providers.cfr",
+ `{"id":"cfr","enabled":true,"type":"local","localProvider":"CFRMessageProvider","updateCycleInMs":3600000}`,
+ ],
+ ],
+ });
+
+ // addRecommendation checks that scheme starts with http and host matches
+ let browser = gBrowser.selectedBrowser;
+ BrowserTestUtils.startLoadingURIString(browser, "http://example.com/");
+ await BrowserTestUtils.browserLoaded(browser, false, "http://example.com/");
+
+ const showPanel = BrowserTestUtils.waitForEvent(
+ PopupNotifications.panel,
+ "popupshown"
+ );
+
+ Services.obs.notifyObservers(
+ {
+ wrappedJSObject: {
+ event: "ContentBlockingMilestone",
+ },
+ },
+ "SiteProtection:ContentBlockingMilestone"
+ );
+
+ await showPanel;
+
+ const notification = document.getElementById(
+ "contextual-feature-recommendation-notification"
+ );
+
+ checkCFRTrackingProtectionMilestone(notification);
+
+ Assert.ok(notification.secondaryButton);
+ let hidePanel = BrowserTestUtils.waitForEvent(
+ PopupNotifications.panel,
+ "popuphidden"
+ );
+
+ notification.secondaryButton.click();
+ await hidePanel;
+ await SpecialPowers.popPrefEnv();
+ clearNotifications();
+ Services.fog.testResetFOG();
+ }
+);
diff --git a/browser/components/asrouter/tests/browser/browser_asrouter_momentspagehub.js b/browser/components/asrouter/tests/browser/browser_asrouter_momentspagehub.js
index f752d01116..aea702bb61 100644
--- a/browser/components/asrouter/tests/browser/browser_asrouter_momentspagehub.js
+++ b/browser/components/asrouter/tests/browser/browser_asrouter_momentspagehub.js
@@ -14,11 +14,11 @@ const { ASRouter } = ChromeUtils.importESModule(
const HOMEPAGE_OVERRIDE_PREF = "browser.startup.homepage_override.once";
add_task(async function test_with_rs_messages() {
- // Force the WNPanel provider cache to 0 by modifying updateCycleInMs
+ // Force the cfr provider cache to 0 by modifying updateCycleInMs
await SpecialPowers.pushPrefEnv({
set: [
[
- "browser.newtabpage.activity-stream.asrouter.providers.whats-new-panel",
+ "browser.newtabpage.activity-stream.asrouter.providers.cfr",
`{"id":"cfr","enabled":true,"type":"remote-settings","collection":"cfr","updateCycleInMs":0}`,
],
],
diff --git a/browser/components/asrouter/tests/unit/ASRouter.test.js b/browser/components/asrouter/tests/unit/ASRouter.test.js
index 7df1449a14..1f5899fce1 100644
--- a/browser/components/asrouter/tests/unit/ASRouter.test.js
+++ b/browser/components/asrouter/tests/unit/ASRouter.test.js
@@ -48,7 +48,6 @@ describe("ASRouter", () => {
let fakeAttributionCode;
let fakeTargetingContext;
let FakeToolbarBadgeHub;
- let FakeToolbarPanelHub;
let FakeMomentsPageHub;
let ASRouterTargeting;
let screenImpressions;
@@ -151,7 +150,6 @@ describe("ASRouter", () => {
cfr: "",
"message-groups": "",
"messaging-experiments": "",
- "whats-new-panel": "",
},
totalBookmarksCount: {},
firefoxVersion: 80,
@@ -159,7 +157,6 @@ describe("ASRouter", () => {
needsUpdate: {},
hasPinnedTabs: false,
hasAccessedFxAPanel: false,
- isWhatsNewPanelEnabled: true,
userPrefs: {
cfrFeatures: true,
cfrAddons: true,
@@ -203,12 +200,6 @@ describe("ASRouter", () => {
writeAttributionFile: () => Promise.resolve(),
getCachedAttributionData: sinon.stub(),
};
- FakeToolbarPanelHub = {
- init: sandbox.stub(),
- uninit: sandbox.stub(),
- forceShowMessage: sandbox.stub(),
- enableToolbarButton: sandbox.stub(),
- };
FakeToolbarBadgeHub = {
init: sandbox.stub(),
uninit: sandbox.stub(),
@@ -252,7 +243,6 @@ describe("ASRouter", () => {
PanelTestProvider,
MacAttribution: { applicationPath: "" },
ToolbarBadgeHub: FakeToolbarBadgeHub,
- ToolbarPanelHub: FakeToolbarPanelHub,
MomentsPageHub: FakeMomentsPageHub,
KintoHttpClient: class {
bucket() {
@@ -354,7 +344,6 @@ describe("ASRouter", () => {
// ASRouter init called in `beforeEach` block above
assert.calledOnce(FakeToolbarBadgeHub.init);
- assert.calledOnce(FakeToolbarPanelHub.init);
assert.calledOnce(FakeMomentsPageHub.init);
assert.calledWithExactly(
@@ -370,15 +359,6 @@ describe("ASRouter", () => {
);
assert.calledWithExactly(
- FakeToolbarPanelHub.init,
- Router.waitForInitialized,
- {
- getMessages: Router.handleMessageRequest,
- sendTelemetry: Router.sendTelemetry,
- }
- );
-
- assert.calledWithExactly(
FakeMomentsPageHub.init,
Router.waitForInitialized,
{
@@ -678,25 +658,10 @@ describe("ASRouter", () => {
sandbox.stub(CFRPageActions, "addRecommendation");
browser = {};
});
- it("should route whatsnew_panel_message message to the right hub", () => {
- Router.routeCFRMessage(
- { template: "whatsnew_panel_message" },
- browser,
- "",
- true
- );
-
- assert.calledOnce(FakeToolbarPanelHub.forceShowMessage);
- assert.notCalled(FakeToolbarBadgeHub.registerBadgeNotificationListener);
- assert.notCalled(CFRPageActions.addRecommendation);
- assert.notCalled(CFRPageActions.forceRecommendation);
- assert.notCalled(FakeMomentsPageHub.executeAction);
- });
it("should route moments messages to the right hub", () => {
Router.routeCFRMessage({ template: "update_action" }, browser, "", true);
assert.calledOnce(FakeMomentsPageHub.executeAction);
- assert.notCalled(FakeToolbarPanelHub.forceShowMessage);
assert.notCalled(FakeToolbarBadgeHub.registerBadgeNotificationListener);
assert.notCalled(CFRPageActions.addRecommendation);
assert.notCalled(CFRPageActions.forceRecommendation);
@@ -705,7 +670,6 @@ describe("ASRouter", () => {
Router.routeCFRMessage({ template: "toolbar_badge" }, browser);
assert.calledOnce(FakeToolbarBadgeHub.registerBadgeNotificationListener);
- assert.notCalled(FakeToolbarPanelHub.forceShowMessage);
assert.notCalled(CFRPageActions.addRecommendation);
assert.notCalled(CFRPageActions.forceRecommendation);
assert.notCalled(FakeMomentsPageHub.executeAction);
@@ -721,7 +685,6 @@ describe("ASRouter", () => {
assert.calledOnce(CFRPageActions.addRecommendation);
assert.notCalled(CFRPageActions.forceRecommendation);
assert.notCalled(FakeToolbarBadgeHub.registerBadgeNotificationListener);
- assert.notCalled(FakeToolbarPanelHub.forceShowMessage);
assert.notCalled(FakeMomentsPageHub.executeAction);
});
it("should route cfr_doorhanger message to the right hub force = false", () => {
@@ -733,7 +696,6 @@ describe("ASRouter", () => {
);
assert.calledOnce(CFRPageActions.addRecommendation);
- assert.notCalled(FakeToolbarPanelHub.forceShowMessage);
assert.notCalled(FakeToolbarBadgeHub.registerBadgeNotificationListener);
assert.notCalled(CFRPageActions.forceRecommendation);
assert.notCalled(FakeMomentsPageHub.executeAction);
@@ -742,7 +704,6 @@ describe("ASRouter", () => {
Router.routeCFRMessage({ template: "cfr_doorhanger" }, browser, {}, true);
assert.calledOnce(CFRPageActions.forceRecommendation);
- assert.notCalled(FakeToolbarPanelHub.forceShowMessage);
assert.notCalled(CFRPageActions.addRecommendation);
assert.notCalled(FakeToolbarBadgeHub.registerBadgeNotificationListener);
assert.notCalled(FakeMomentsPageHub.executeAction);
@@ -759,7 +720,6 @@ describe("ASRouter", () => {
const { args } = CFRPageActions.addRecommendation.firstCall;
// Host should be null
assert.isNull(args[1]);
- assert.notCalled(FakeToolbarPanelHub.forceShowMessage);
assert.notCalled(FakeToolbarBadgeHub.registerBadgeNotificationListener);
assert.notCalled(CFRPageActions.forceRecommendation);
assert.notCalled(FakeMomentsPageHub.executeAction);
@@ -773,7 +733,6 @@ describe("ASRouter", () => {
);
assert.calledOnce(CFRPageActions.forceRecommendation);
- assert.notCalled(FakeToolbarPanelHub.forceShowMessage);
assert.notCalled(CFRPageActions.addRecommendation);
assert.notCalled(FakeToolbarBadgeHub.registerBadgeNotificationListener);
assert.notCalled(FakeMomentsPageHub.executeAction);
@@ -786,7 +745,6 @@ describe("ASRouter", () => {
true
);
- assert.notCalled(FakeToolbarPanelHub.forceShowMessage);
assert.notCalled(CFRPageActions.forceRecommendation);
assert.notCalled(CFRPageActions.addRecommendation);
assert.notCalled(FakeToolbarBadgeHub.registerBadgeNotificationListener);
@@ -961,7 +919,6 @@ describe("ASRouter", () => {
type: "local",
enabled: true,
messages: [
- "whatsnew_panel_message",
"cfr_doorhanger",
"toolbar_badge",
"update_action",
@@ -1272,43 +1229,6 @@ describe("ASRouter", () => {
Router.state.messageImpressions
);
});
- it("should return all unblocked messages that match the template, trigger if returnAll=true", async () => {
- const message1 = {
- provider: "whats_new",
- id: "1",
- template: "whatsnew_panel_message",
- trigger: { id: "whatsNewPanelOpened" },
- groups: ["whats_new"],
- };
- const message2 = {
- provider: "whats_new",
- id: "2",
- template: "whatsnew_panel_message",
- trigger: { id: "whatsNewPanelOpened" },
- groups: ["whats_new"],
- };
- const message3 = {
- provider: "whats_new",
- id: "3",
- template: "badge",
- groups: ["whats_new"],
- };
- ASRouterTargeting.findMatchingMessage.callsFake(() => [
- message2,
- message1,
- ]);
- await Router.setState({
- messages: [message3, message2, message1],
- providers: [{ id: "whats_new" }],
- });
- const result = await Router.handleMessageRequest({
- template: "whatsnew_panel_message",
- triggerId: "whatsNewPanelOpened",
- returnAll: true,
- });
-
- assert.deepEqual(result, [message2, message1]);
- });
it("should forward trigger param info", async () => {
const trigger = {
triggerId: "foo",
@@ -1854,33 +1774,6 @@ describe("ASRouter", () => {
});
});
- describe("#forceWNPanel", () => {
- let browser = {
- ownerGlobal: {
- document: new Document(),
- PanelUI: {
- showSubView: sinon.stub(),
- panel: {
- setAttribute: sinon.stub(),
- },
- },
- },
- };
- let fakePanel = {
- setAttribute: sinon.stub(),
- };
- sinon
- .stub(browser.ownerGlobal.document, "getElementById")
- .returns(fakePanel);
-
- it("should call enableToolbarButton", async () => {
- await Router.forceWNPanel(browser);
- assert.calledOnce(FakeToolbarPanelHub.enableToolbarButton);
- assert.calledOnce(browser.ownerGlobal.PanelUI.showSubView);
- assert.calledWith(fakePanel.setAttribute, "noautohide", true);
- });
- });
-
describe("_triggerHandler", () => {
it("should call #sendTriggerMessage with the correct trigger", () => {
const getter = sandbox.stub();
diff --git a/browser/components/asrouter/tests/unit/ASRouterChild.test.js b/browser/components/asrouter/tests/unit/ASRouterChild.test.js
index b73e56d510..c6533e073d 100644
--- a/browser/components/asrouter/tests/unit/ASRouterChild.test.js
+++ b/browser/components/asrouter/tests/unit/ASRouterChild.test.js
@@ -1,6 +1,6 @@
/*eslint max-nested-callbacks: ["error", 10]*/
import { ASRouterChild } from "actors/ASRouterChild.sys.mjs";
-import { MESSAGE_TYPE_HASH as msg } from "modules/ActorConstants.sys.mjs";
+import { MESSAGE_TYPE_HASH as msg } from "modules/ActorConstants.mjs";
describe("ASRouterChild", () => {
let asRouterChild = null;
@@ -24,7 +24,6 @@ describe("ASRouterChild", () => {
msg.DISABLE_PROVIDER,
msg.ENABLE_PROVIDER,
msg.EXPIRE_QUERY_CACHE,
- msg.FORCE_WHATSNEW_PANEL,
msg.IMPRESSION,
msg.RESET_PROVIDER_PREF,
msg.SET_PROVIDER_USER_PREF,
diff --git a/browser/components/asrouter/tests/unit/ASRouterParent.test.js b/browser/components/asrouter/tests/unit/ASRouterParent.test.js
index 0358b1261c..e65d7db825 100644
--- a/browser/components/asrouter/tests/unit/ASRouterParent.test.js
+++ b/browser/components/asrouter/tests/unit/ASRouterParent.test.js
@@ -1,5 +1,5 @@
import { ASRouterParent } from "actors/ASRouterParent.sys.mjs";
-import { MESSAGE_TYPE_HASH as msg } from "modules/ActorConstants.sys.mjs";
+import { MESSAGE_TYPE_HASH as msg } from "modules/ActorConstants.mjs";
describe("ASRouterParent", () => {
let asRouterParent = null;
diff --git a/browser/components/asrouter/tests/unit/ASRouterParentProcessMessageHandler.test.js b/browser/components/asrouter/tests/unit/ASRouterParentProcessMessageHandler.test.js
index 7bfec3e099..6a965c5689 100644
--- a/browser/components/asrouter/tests/unit/ASRouterParentProcessMessageHandler.test.js
+++ b/browser/components/asrouter/tests/unit/ASRouterParentProcessMessageHandler.test.js
@@ -1,6 +1,6 @@
import { ASRouterParentProcessMessageHandler } from "modules/ASRouterParentProcessMessageHandler.sys.mjs";
import { _ASRouter } from "modules/ASRouter.sys.mjs";
-import { MESSAGE_TYPE_HASH as msg } from "modules/ActorConstants.sys.mjs";
+import { MESSAGE_TYPE_HASH as msg } from "modules/ActorConstants.mjs";
describe("ASRouterParentProcessMessageHandler", () => {
let handler = null;
@@ -14,8 +14,6 @@ describe("ASRouterParentProcessMessageHandler", () => {
"addImpression",
"evaluateExpression",
"forceAttribution",
- "forceWNPanel",
- "closeWNPanel",
"forcePBWindow",
"resetGroupsState",
"resetMessageState",
@@ -122,7 +120,6 @@ describe("ASRouterParentProcessMessageHandler", () => {
[
msg.AS_ROUTER_TELEMETRY_USER_EVENT,
msg.TOOLBAR_BADGE_TELEMETRY,
- msg.TOOLBAR_PANEL_TELEMETRY,
msg.MOMENTS_PAGE_TELEMETRY,
msg.DOORHANGER_TELEMETRY,
].forEach(type => {
@@ -309,28 +306,6 @@ describe("ASRouterParentProcessMessageHandler", () => {
assert.calledOnce(config.router.forceAttribution);
});
});
- describe("FORCE_WHATSNEW_PANEL action", () => {
- it("default calls forceWNPanel", () => {
- handler.handleMessage(
- msg.FORCE_WHATSNEW_PANEL,
- {},
- { browser: { ownerGlobal: {} } }
- );
- assert.calledOnce(config.router.forceWNPanel);
- assert.calledWith(config.router.forceWNPanel, { ownerGlobal: {} });
- });
- });
- describe("CLOSE_WHATSNEW_PANEL action", () => {
- it("default calls closeWNPanel", () => {
- handler.handleMessage(
- msg.CLOSE_WHATSNEW_PANEL,
- {},
- { browser: { ownerGlobal: {} } }
- );
- assert.calledOnce(config.router.closeWNPanel);
- assert.calledWith(config.router.closeWNPanel, { ownerGlobal: {} });
- });
- });
describe("FORCE_PRIVATE_BROWSING_WINDOW action", () => {
it("default calls forcePBWindow", () => {
handler.handleMessage(
diff --git a/browser/components/asrouter/tests/unit/ToolbarBadgeHub.test.js b/browser/components/asrouter/tests/unit/ToolbarBadgeHub.test.js
index 3e91b657bc..cfeac77025 100644
--- a/browser/components/asrouter/tests/unit/ToolbarBadgeHub.test.js
+++ b/browser/components/asrouter/tests/unit/ToolbarBadgeHub.test.js
@@ -1,10 +1,6 @@
import { _ToolbarBadgeHub } from "modules/ToolbarBadgeHub.sys.mjs";
import { GlobalOverrider } from "test/unit/utils";
import { OnboardingMessageProvider } from "modules/OnboardingMessageProvider.sys.mjs";
-import {
- _ToolbarPanelHub,
- ToolbarPanelHub,
-} from "modules/ToolbarPanelHub.sys.mjs";
describe("ToolbarBadgeHub", () => {
let sandbox;
@@ -13,7 +9,6 @@ describe("ToolbarBadgeHub", () => {
let fakeSendTelemetry;
let isBrowserPrivateStub;
let fxaMessage;
- let whatsnewMessage;
let fakeElement;
let globals;
let everyWindowStub;
@@ -36,28 +31,6 @@ describe("ToolbarBadgeHub", () => {
const onboardingMsgs =
await OnboardingMessageProvider.getUntranslatedMessages();
fxaMessage = onboardingMsgs.find(({ id }) => id === "FXA_ACCOUNTS_BADGE");
- whatsnewMessage = {
- id: `WHATS_NEW_BADGE_71`,
- template: "toolbar_badge",
- content: {
- delay: 1000,
- target: "whats-new-menu-button",
- action: { id: "show-whatsnew-button" },
- badgeDescription: { string_id: "cfr-badge-reader-label-newfeature" },
- },
- priority: 1,
- trigger: { id: "toolbarBadgeUpdate" },
- frequency: {
- // Makes it so that we track impressions for this message while at the
- // same time it can have unlimited impressions
- lifetime: Infinity,
- },
- // Never saw this message or saw it in the past 4 days or more recent
- targeting: `isWhatsNewPanelEnabled &&
- (!messageImpressions['WHATS_NEW_BADGE_71'] ||
- (messageImpressions['WHATS_NEW_BADGE_71']|length >= 1 &&
- currentDate|date - messageImpressions['WHATS_NEW_BADGE_71'][0] <= 4 * 24 * 3600 * 1000))`,
- };
fakeElement = {
classList: {
add: sandbox.stub(),
@@ -93,7 +66,6 @@ describe("ToolbarBadgeHub", () => {
setStringPrefStub = sandbox.stub();
requestIdleCallbackStub = sandbox.stub().callsFake(fn => fn());
globals.set({
- ToolbarPanelHub,
requestIdleCallback: requestIdleCallbackStub,
EveryWindow: everyWindowStub,
PrivateBrowsingUtils: { isBrowserPrivate: isBrowserPrivateStub },
@@ -139,16 +111,6 @@ describe("ToolbarBadgeHub", () => {
assert.calledTwice(instance.messageRequest);
});
- it("should add a pref observer", async () => {
- await instance.init(sandbox.stub().resolves(), {});
-
- assert.calledOnce(addObserverStub);
- assert.calledWithExactly(
- addObserverStub,
- instance.prefs.WHATSNEW_TOOLBAR_PANEL,
- instance
- );
- });
});
describe("#uninit", () => {
beforeEach(async () => {
@@ -164,16 +126,6 @@ describe("ToolbarBadgeHub", () => {
assert.calledOnce(clearTimeoutStub);
assert.calledWithExactly(clearTimeoutStub, 2);
});
- it("should remove the pref observer", () => {
- instance.uninit();
-
- assert.calledOnce(removeObserverStub);
- assert.calledWithExactly(
- removeObserverStub,
- instance.prefs.WHATSNEW_TOOLBAR_PANEL,
- instance
- );
- });
});
describe("messageRequest", () => {
let handleMessageRequestStub;
@@ -293,66 +245,6 @@ describe("ToolbarBadgeHub", () => {
instance.removeAllNotifications
);
});
- it("should execute actions if they exist", () => {
- sandbox.stub(instance, "executeAction");
- instance.addToolbarNotification(target, whatsnewMessage);
-
- assert.calledOnce(instance.executeAction);
- assert.calledWithExactly(instance.executeAction, {
- ...whatsnewMessage.content.action,
- message_id: whatsnewMessage.id,
- });
- });
- it("should create a description element", () => {
- sandbox.stub(instance, "executeAction");
- instance.addToolbarNotification(target, whatsnewMessage);
-
- assert.calledOnce(fakeDocument.createElement);
- assert.calledWithExactly(fakeDocument.createElement, "span");
- });
- it("should set description id to element and to button", () => {
- sandbox.stub(instance, "executeAction");
- instance.addToolbarNotification(target, whatsnewMessage);
-
- assert.calledWithExactly(
- fakeElement.setAttribute,
- "id",
- "toolbarbutton-notification-description"
- );
- assert.calledWithExactly(
- fakeElement.setAttribute,
- "aria-labelledby",
- `toolbarbutton-notification-description ${whatsnewMessage.content.target}`
- );
- });
- it("should attach fluent id to description", () => {
- sandbox.stub(instance, "executeAction");
- instance.addToolbarNotification(target, whatsnewMessage);
-
- assert.calledOnce(fakeDocument.l10n.setAttributes);
- assert.calledWithExactly(
- fakeDocument.l10n.setAttributes,
- fakeElement,
- whatsnewMessage.content.badgeDescription.string_id
- );
- });
- it("should add an impression for the message", () => {
- instance.addToolbarNotification(target, whatsnewMessage);
-
- assert.calledOnce(instance._addImpression);
- assert.calledWithExactly(instance._addImpression, whatsnewMessage);
- });
- it("should send an impression ping", async () => {
- sandbox.stub(instance, "sendUserEventTelemetry");
- instance.addToolbarNotification(target, whatsnewMessage);
-
- assert.calledOnce(instance.sendUserEventTelemetry);
- assert.calledWithExactly(
- instance.sendUserEventTelemetry,
- "IMPRESSION",
- whatsnewMessage
- );
- });
});
describe("registerBadgeNotificationListener", () => {
let msg_no_delay;
@@ -410,44 +302,6 @@ describe("ToolbarBadgeHub", () => {
assert.calledOnce(everyWindowStub.unregisterCallback);
assert.calledWithExactly(everyWindowStub.unregisterCallback, instance.id);
});
- it("should only call executeAction for 'update_action' messages", () => {
- const stub = sandbox.stub(instance, "executeAction");
- const updateActionMsg = { ...msg_no_delay, template: "update_action" };
-
- instance.registerBadgeNotificationListener(updateActionMsg);
-
- assert.notCalled(everyWindowStub.registerCallback);
- assert.calledOnce(stub);
- });
- });
- describe("executeAction", () => {
- let blockMessageByIdStub;
- beforeEach(async () => {
- blockMessageByIdStub = sandbox.stub();
- await instance.init(sandbox.stub().resolves(), {
- blockMessageById: blockMessageByIdStub,
- });
- });
- it("should call ToolbarPanelHub.enableToolbarButton", () => {
- const stub = sandbox.stub(
- _ToolbarPanelHub.prototype,
- "enableToolbarButton"
- );
-
- instance.executeAction({ id: "show-whatsnew-button" });
-
- assert.calledOnce(stub);
- });
- it("should call ToolbarPanelHub.enableAppmenuButton", () => {
- const stub = sandbox.stub(
- _ToolbarPanelHub.prototype,
- "enableAppmenuButton"
- );
-
- instance.executeAction({ id: "show-whatsnew-button" });
-
- assert.calledOnce(stub);
- });
});
describe("removeToolbarNotification", () => {
it("should remove the notification", () => {
@@ -629,24 +483,4 @@ describe("ToolbarBadgeHub", () => {
assert.propertyVal(ping.data, "event", "CLICK");
});
});
- describe("#observe", () => {
- it("should make a message request when the whats new pref is changed", () => {
- sandbox.stub(instance, "messageRequest");
-
- instance.observe("", "", instance.prefs.WHATSNEW_TOOLBAR_PANEL);
-
- assert.calledOnce(instance.messageRequest);
- assert.calledWithExactly(instance.messageRequest, {
- template: "toolbar_badge",
- triggerId: "toolbarBadgeUpdate",
- });
- });
- it("should not react to other pref changes", () => {
- sandbox.stub(instance, "messageRequest");
-
- instance.observe("", "", "foo");
-
- assert.notCalled(instance.messageRequest);
- });
- });
});
diff --git a/browser/components/asrouter/tests/unit/ToolbarPanelHub.test.js b/browser/components/asrouter/tests/unit/ToolbarPanelHub.test.js
deleted file mode 100644
index 1755f62308..0000000000
--- a/browser/components/asrouter/tests/unit/ToolbarPanelHub.test.js
+++ /dev/null
@@ -1,760 +0,0 @@
-import { _ToolbarPanelHub } from "modules/ToolbarPanelHub.sys.mjs";
-import { GlobalOverrider } from "test/unit/utils";
-import { PanelTestProvider } from "modules/PanelTestProvider.sys.mjs";
-
-describe("ToolbarPanelHub", () => {
- let globals;
- let sandbox;
- let instance;
- let everyWindowStub;
- let fakeDocument;
- let fakeWindow;
- let fakeElementById;
- let fakeElementByTagName;
- let createdCustomElements = [];
- let eventListeners = {};
- let addObserverStub;
- let removeObserverStub;
- let getBoolPrefStub;
- let setBoolPrefStub;
- let waitForInitializedStub;
- let isBrowserPrivateStub;
- let fakeSendTelemetry;
- let getEarliestRecordedDateStub;
- let getEventsByDateRangeStub;
- let defaultSearchStub;
- let scriptloaderStub;
- let fakeRemoteL10n;
- let getViewNodeStub;
-
- beforeEach(async () => {
- sandbox = sinon.createSandbox();
- globals = new GlobalOverrider();
- instance = new _ToolbarPanelHub();
- waitForInitializedStub = sandbox.stub().resolves();
- fakeElementById = {
- setAttribute: sandbox.stub(),
- removeAttribute: sandbox.stub(),
- querySelector: sandbox.stub().returns(null),
- querySelectorAll: sandbox.stub().returns([]),
- appendChild: sandbox.stub(),
- addEventListener: sandbox.stub(),
- hasAttribute: sandbox.stub(),
- toggleAttribute: sandbox.stub(),
- remove: sandbox.stub(),
- removeChild: sandbox.stub(),
- };
- fakeElementByTagName = {
- setAttribute: sandbox.stub(),
- removeAttribute: sandbox.stub(),
- querySelector: sandbox.stub().returns(null),
- querySelectorAll: sandbox.stub().returns([]),
- appendChild: sandbox.stub(),
- addEventListener: sandbox.stub(),
- hasAttribute: sandbox.stub(),
- toggleAttribute: sandbox.stub(),
- remove: sandbox.stub(),
- removeChild: sandbox.stub(),
- };
- fakeDocument = {
- getElementById: sandbox.stub().returns(fakeElementById),
- getElementsByTagName: sandbox.stub().returns(fakeElementByTagName),
- querySelector: sandbox.stub().returns({}),
- createElement: tagName => {
- const element = {
- tagName,
- classList: {},
- addEventListener: (ev, fn) => {
- eventListeners[ev] = fn;
- },
- appendChild: sandbox.stub(),
- setAttribute: sandbox.stub(),
- textContent: "",
- };
- element.classList.add = sandbox.stub();
- element.classList.includes = className =>
- element.classList.add.firstCall.args[0] === className;
- createdCustomElements.push(element);
- return element;
- },
- l10n: {
- translateElements: sandbox.stub(),
- translateFragment: sandbox.stub(),
- formatMessages: sandbox.stub().resolves([{}]),
- setAttributes: sandbox.stub(),
- },
- };
- fakeWindow = {
- // eslint-disable-next-line object-shorthand
- DocumentFragment: function () {
- return fakeElementById;
- },
- document: fakeDocument,
- browser: {
- ownerDocument: fakeDocument,
- },
- MozXULElement: { insertFTLIfNeeded: sandbox.stub() },
- ownerGlobal: {
- openLinkIn: sandbox.stub(),
- gBrowser: "gBrowser",
- },
- PanelUI: {
- panel: fakeElementById,
- whatsNewPanel: fakeElementById,
- },
- customElements: { get: sandbox.stub() },
- };
- everyWindowStub = {
- registerCallback: sandbox.stub(),
- unregisterCallback: sandbox.stub(),
- };
- scriptloaderStub = { loadSubScript: sandbox.stub() };
- addObserverStub = sandbox.stub();
- removeObserverStub = sandbox.stub();
- getBoolPrefStub = sandbox.stub();
- setBoolPrefStub = sandbox.stub();
- fakeSendTelemetry = sandbox.stub();
- isBrowserPrivateStub = sandbox.stub();
- getEarliestRecordedDateStub = sandbox.stub().returns(
- // A random date that's not the current timestamp
- new Date() - 500
- );
- getEventsByDateRangeStub = sandbox.stub().returns([]);
- getViewNodeStub = sandbox.stub().returns(fakeElementById);
- defaultSearchStub = { defaultEngine: { name: "DDG" } };
- fakeRemoteL10n = {
- l10n: {},
- reloadL10n: sandbox.stub(),
- createElement: sandbox
- .stub()
- .callsFake((doc, el) => fakeDocument.createElement(el)),
- };
- globals.set({
- EveryWindow: everyWindowStub,
- Services: {
- ...Services,
- prefs: {
- addObserver: addObserverStub,
- removeObserver: removeObserverStub,
- getBoolPref: getBoolPrefStub,
- setBoolPref: setBoolPrefStub,
- },
- search: defaultSearchStub,
- scriptloader: scriptloaderStub,
- },
- PrivateBrowsingUtils: {
- isBrowserPrivate: isBrowserPrivateStub,
- },
- TrackingDBService: {
- getEarliestRecordedDate: getEarliestRecordedDateStub,
- getEventsByDateRange: getEventsByDateRangeStub,
- },
- SpecialMessageActions: {
- handleAction: sandbox.stub(),
- },
- RemoteL10n: fakeRemoteL10n,
- PanelMultiView: {
- getViewNode: getViewNodeStub,
- },
- });
- });
- afterEach(() => {
- instance.uninit();
- sandbox.restore();
- globals.restore();
- eventListeners = {};
- createdCustomElements = [];
- });
- it("should create an instance", () => {
- assert.ok(instance);
- });
- it("should enableAppmenuButton() on init() just once", async () => {
- instance.enableAppmenuButton = sandbox.stub();
-
- await instance.init(waitForInitializedStub, { getMessages: () => {} });
- await instance.init(waitForInitializedStub, { getMessages: () => {} });
-
- assert.calledOnce(instance.enableAppmenuButton);
-
- instance.uninit();
-
- await instance.init(waitForInitializedStub, { getMessages: () => {} });
-
- assert.calledTwice(instance.enableAppmenuButton);
- });
- it("should unregisterCallback on uninit()", () => {
- instance.uninit();
- assert.calledTwice(everyWindowStub.unregisterCallback);
- });
- describe("#maybeLoadCustomElement", () => {
- it("should not load customElements a second time", () => {
- instance.maybeLoadCustomElement({ customElements: new Map() });
- instance.maybeLoadCustomElement({
- customElements: new Map([["remote-text", true]]),
- });
-
- assert.calledOnce(scriptloaderStub.loadSubScript);
- });
- });
- describe("#toggleWhatsNewPref", () => {
- it("should call Services.prefs.setBoolPref() with the opposite value", () => {
- let checkbox = {};
- let event = { target: checkbox };
- // checkbox starts false
- checkbox.checked = false;
-
- // toggling the checkbox to set the value to true;
- // Preferences.set() gets called before the checkbox changes,
- // so we have to call it with the opposite value.
- instance.toggleWhatsNewPref(event);
-
- assert.calledOnce(setBoolPrefStub);
- assert.calledWith(
- setBoolPrefStub,
- "browser.messaging-system.whatsNewPanel.enabled",
- !checkbox.checked
- );
- });
- it("should report telemetry with the opposite value", () => {
- let sendUserEventTelemetryStub = sandbox.stub(
- instance,
- "sendUserEventTelemetry"
- );
- let event = {
- target: { checked: true, ownerGlobal: fakeWindow },
- };
-
- instance.toggleWhatsNewPref(event);
-
- assert.calledOnce(sendUserEventTelemetryStub);
- const { args } = sendUserEventTelemetryStub.firstCall;
- assert.equal(args[1], "WNP_PREF_TOGGLE");
- assert.propertyVal(args[3].value, "prefValue", false);
- });
- });
- describe("#enableAppmenuButton", () => {
- it("should registerCallback on enableAppmenuButton() if there are messages", async () => {
- await instance.init(waitForInitializedStub, {
- getMessages: sandbox.stub().resolves([{}, {}]),
- });
- // init calls `enableAppmenuButton`
- everyWindowStub.registerCallback.resetHistory();
-
- await instance.enableAppmenuButton();
-
- assert.calledOnce(everyWindowStub.registerCallback);
- assert.calledWithExactly(
- everyWindowStub.registerCallback,
- "appMenu-whatsnew-button",
- sinon.match.func,
- sinon.match.func
- );
- });
- it("should not registerCallback on enableAppmenuButton() if there are no messages", async () => {
- instance.init(waitForInitializedStub, {
- getMessages: sandbox.stub().resolves([]),
- });
- // init calls `enableAppmenuButton`
- everyWindowStub.registerCallback.resetHistory();
-
- await instance.enableAppmenuButton();
-
- assert.notCalled(everyWindowStub.registerCallback);
- });
- });
- describe("#disableAppmenuButton", () => {
- it("should call the unregisterCallback", () => {
- assert.notCalled(everyWindowStub.unregisterCallback);
-
- instance.disableAppmenuButton();
-
- assert.calledOnce(everyWindowStub.unregisterCallback);
- assert.calledWithExactly(
- everyWindowStub.unregisterCallback,
- "appMenu-whatsnew-button"
- );
- });
- });
- describe("#enableToolbarButton", () => {
- it("should registerCallback on enableToolbarButton if messages.length", async () => {
- await instance.init(waitForInitializedStub, {
- getMessages: sandbox.stub().resolves([{}, {}]),
- });
- // init calls `enableAppmenuButton`
- everyWindowStub.registerCallback.resetHistory();
-
- await instance.enableToolbarButton();
-
- assert.calledOnce(everyWindowStub.registerCallback);
- assert.calledWithExactly(
- everyWindowStub.registerCallback,
- "whats-new-menu-button",
- sinon.match.func,
- sinon.match.func
- );
- });
- it("should not registerCallback on enableToolbarButton if no messages", async () => {
- await instance.init(waitForInitializedStub, {
- getMessages: sandbox.stub().resolves([]),
- });
-
- await instance.enableToolbarButton();
-
- assert.notCalled(everyWindowStub.registerCallback);
- });
- });
- describe("Show/Hide functions", () => {
- it("should unhide appmenu button on _showAppmenuButton()", async () => {
- await instance._showAppmenuButton(fakeWindow);
-
- assert.equal(fakeElementById.hidden, false);
- });
- it("should hide appmenu button on _hideAppmenuButton()", () => {
- instance._hideAppmenuButton(fakeWindow);
- assert.equal(fakeElementById.hidden, true);
- });
- it("should not do anything if the window is closed", () => {
- instance._hideAppmenuButton(fakeWindow, true);
- assert.notCalled(global.PanelMultiView.getViewNode);
- });
- it("should not throw if the element does not exist", () => {
- let fn = instance._hideAppmenuButton.bind(null, {
- browser: { ownerDocument: {} },
- });
- getViewNodeStub.returns(undefined);
- assert.doesNotThrow(fn);
- });
- it("should unhide toolbar button on _showToolbarButton()", async () => {
- await instance._showToolbarButton(fakeWindow);
-
- assert.equal(fakeElementById.hidden, false);
- });
- it("should hide toolbar button on _hideToolbarButton()", () => {
- instance._hideToolbarButton(fakeWindow);
- assert.equal(fakeElementById.hidden, true);
- });
- });
- describe("#renderMessages", () => {
- let getMessagesStub;
- beforeEach(() => {
- getMessagesStub = sandbox.stub();
- instance.init(waitForInitializedStub, {
- getMessages: getMessagesStub,
- sendTelemetry: fakeSendTelemetry,
- });
- });
- it("should have correct state", async () => {
- const messages = (await PanelTestProvider.getMessages()).filter(
- m => m.template === "whatsnew_panel_message"
- );
-
- getMessagesStub.returns(messages);
- const ev1 = sandbox.stub();
- ev1.withArgs("type").returns(1); // tracker
- ev1.withArgs("count").returns(4);
- const ev2 = sandbox.stub();
- ev2.withArgs("type").returns(4); // fingerprinter
- ev2.withArgs("count").returns(3);
- getEventsByDateRangeStub.returns([
- { getResultByName: ev1 },
- { getResultByName: ev2 },
- ]);
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- assert.propertyVal(instance.state.contentArguments, "trackerCount", 4);
- assert.propertyVal(
- instance.state.contentArguments,
- "fingerprinterCount",
- 3
- );
- });
- it("should render messages to the panel on renderMessages()", async () => {
- const messages = (await PanelTestProvider.getMessages()).filter(
- m => m.template === "whatsnew_panel_message"
- );
- messages[0].content.link_text = { string_id: "link_text_id" };
-
- getMessagesStub.returns(messages);
- const ev1 = sandbox.stub();
- ev1.withArgs("type").returns(1); // tracker
- ev1.withArgs("count").returns(4);
- const ev2 = sandbox.stub();
- ev2.withArgs("type").returns(4); // fingerprinter
- ev2.withArgs("count").returns(3);
- getEventsByDateRangeStub.returns([
- { getResultByName: ev1 },
- { getResultByName: ev2 },
- ]);
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- for (let message of messages) {
- assert.ok(
- fakeRemoteL10n.createElement.args.find(
- ([, , args]) => args && args.classList === "whatsNew-message-title"
- )
- );
- if (message.content.layout === "tracking-protections") {
- assert.ok(
- fakeRemoteL10n.createElement.args.find(
- ([, , args]) =>
- args && args.classList === "whatsNew-message-subtitle"
- )
- );
- }
- if (message.id === "WHATS_NEW_FINGERPRINTER_COUNTER_72") {
- assert.ok(
- fakeRemoteL10n.createElement.args.find(
- ([, el, args]) => el === "h2" && args.content === 3
- )
- );
- }
- assert.ok(
- fakeRemoteL10n.createElement.args.find(
- ([, , args]) =>
- args && args.classList === "whatsNew-message-content"
- )
- );
- }
- // Call the click handler to make coverage happy.
- eventListeners.mouseup();
- assert.calledOnce(global.SpecialMessageActions.handleAction);
- });
- it("should clear previous messages on 2nd renderMessages()", async () => {
- const messages = (await PanelTestProvider.getMessages()).filter(
- m => m.template === "whatsnew_panel_message"
- );
- const removeStub = sandbox.stub();
- fakeElementById.querySelectorAll.onCall(0).returns([]);
- fakeElementById.querySelectorAll
- .onCall(1)
- .returns([{ remove: removeStub }, { remove: removeStub }]);
-
- getMessagesStub.returns(messages);
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- assert.calledTwice(removeStub);
- });
- it("should sort based on order field value", async () => {
- const messages = (await PanelTestProvider.getMessages()).filter(
- m =>
- m.template === "whatsnew_panel_message" &&
- m.content.published_date === 1560969794394
- );
-
- messages.forEach(m => (m.content.title = m.order));
-
- getMessagesStub.returns(messages);
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- // Select the title elements that are supposed to be set to the same
- // value as the `order` field of the message
- const titleEls = fakeRemoteL10n.createElement.args
- .filter(
- ([, , args]) => args && args.classList === "whatsNew-message-title"
- )
- .map(([, , args]) => args.content);
- assert.deepEqual(titleEls, [1, 2, 3]);
- });
- it("should accept string for image attributes", async () => {
- const messages = (await PanelTestProvider.getMessages()).filter(
- m => m.id === "WHATS_NEW_70_1"
- );
- getMessagesStub.returns(messages);
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- const imageEl = createdCustomElements.find(el => el.tagName === "img");
- assert.calledOnce(imageEl.setAttribute);
- assert.calledWithExactly(
- imageEl.setAttribute,
- "alt",
- "Firefox Send Logo"
- );
- });
- it("should set state values as data-attribute", async () => {
- const message = (await PanelTestProvider.getMessages()).find(
- m => m.template === "whatsnew_panel_message"
- );
- getMessagesStub.returns([message]);
- instance.state.contentArguments = { foo: "foo", bar: "bar" };
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- const [, , args] = fakeRemoteL10n.createElement.args.find(
- ([, , elArgs]) => elArgs && elArgs.attributes
- );
- assert.ok(args);
- // Currently this.state.contentArguments has 8 different entries
- assert.lengthOf(Object.keys(args.attributes), 8);
- assert.equal(
- args.attributes.searchEngineName,
- defaultSearchStub.defaultEngine.name
- );
- });
- it("should only render unique dates (no duplicates)", async () => {
- const messages = (await PanelTestProvider.getMessages()).filter(
- m => m.template === "whatsnew_panel_message"
- );
- const uniqueDates = [
- ...new Set(messages.map(m => m.content.published_date)),
- ];
- getMessagesStub.returns(messages);
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- const dateElements = fakeRemoteL10n.createElement.args.filter(
- ([, el, args]) =>
- el === "p" && args.classList === "whatsNew-message-date"
- );
- assert.lengthOf(dateElements, uniqueDates.length);
- });
- it("should listen for panelhidden and remove the toolbar button", async () => {
- getMessagesStub.returns([]);
- fakeDocument.getElementById
- .withArgs("customizationui-widget-panel")
- .returns(null);
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- assert.notCalled(fakeElementById.addEventListener);
- });
- it("should attach doCommand cbs that handle user actions", async () => {
- const messages = (await PanelTestProvider.getMessages()).filter(
- m => m.template === "whatsnew_panel_message"
- );
- getMessagesStub.returns(messages);
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- const messageEl = createdCustomElements.find(
- el =>
- el.tagName === "div" && el.classList.includes("whatsNew-message-body")
- );
- const anchorEl = createdCustomElements.find(el => el.tagName === "a");
-
- assert.notCalled(global.SpecialMessageActions.handleAction);
-
- messageEl.doCommand();
- anchorEl.doCommand();
-
- assert.calledTwice(global.SpecialMessageActions.handleAction);
- });
- it("should listen for panelhidden and remove the toolbar button", async () => {
- getMessagesStub.returns([]);
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- assert.calledOnce(fakeElementById.addEventListener);
- assert.calledWithExactly(
- fakeElementById.addEventListener,
- "popuphidden",
- sinon.match.func,
- {
- once: true,
- }
- );
- const [, cb] = fakeElementById.addEventListener.firstCall.args;
-
- assert.notCalled(everyWindowStub.unregisterCallback);
-
- cb();
-
- assert.calledOnce(everyWindowStub.unregisterCallback);
- assert.calledWithExactly(
- everyWindowStub.unregisterCallback,
- "whats-new-menu-button"
- );
- });
- describe("#IMPRESSION", () => {
- it("should dispatch a IMPRESSION for messages", async () => {
- // means panel is triggered from the toolbar button
- fakeElementById.hasAttribute.returns(true);
- const messages = (await PanelTestProvider.getMessages()).filter(
- m => m.template === "whatsnew_panel_message"
- );
- getMessagesStub.returns(messages);
- const spy = sandbox.spy(instance, "sendUserEventTelemetry");
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- assert.calledOnce(spy);
- assert.calledOnce(fakeSendTelemetry);
- assert.propertyVal(
- spy.firstCall.args[2],
- "id",
- messages
- .map(({ id }) => id)
- .sort()
- .join(",")
- );
- });
- it("should dispatch a CLICK for clicking a message", async () => {
- // means panel is triggered from the toolbar button
- fakeElementById.hasAttribute.returns(true);
- // Force to render the message
- fakeElementById.querySelector.returns(null);
- const messages = (await PanelTestProvider.getMessages()).filter(
- m => m.template === "whatsnew_panel_message"
- );
- getMessagesStub.returns([messages[0]]);
- const spy = sandbox.spy(instance, "sendUserEventTelemetry");
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- assert.calledOnce(spy);
- assert.calledOnce(fakeSendTelemetry);
-
- spy.resetHistory();
-
- // Message click event listener cb
- eventListeners.mouseup();
-
- assert.calledOnce(spy);
- assert.calledWithExactly(spy, fakeWindow, "CLICK", messages[0]);
- });
- it("should dispatch a IMPRESSION with toolbar_dropdown", async () => {
- // means panel is triggered from the toolbar button
- fakeElementById.hasAttribute.returns(true);
- const messages = (await PanelTestProvider.getMessages()).filter(
- m => m.template === "whatsnew_panel_message"
- );
- getMessagesStub.resolves(messages);
- const spy = sandbox.spy(instance, "sendUserEventTelemetry");
- const panelPingId = messages
- .map(({ id }) => id)
- .sort()
- .join(",");
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- assert.calledOnce(spy);
- assert.calledWithExactly(
- spy,
- fakeWindow,
- "IMPRESSION",
- {
- id: panelPingId,
- },
- {
- value: {
- view: "toolbar_dropdown",
- },
- }
- );
- assert.calledOnce(fakeSendTelemetry);
- const {
- args: [dispatchPayload],
- } = fakeSendTelemetry.lastCall;
- assert.propertyVal(dispatchPayload, "type", "TOOLBAR_PANEL_TELEMETRY");
- assert.propertyVal(dispatchPayload.data, "message_id", panelPingId);
- assert.deepEqual(dispatchPayload.data.event_context, {
- view: "toolbar_dropdown",
- });
- });
- it("should dispatch a IMPRESSION with application_menu", async () => {
- // means panel is triggered as a subview in the application menu
- fakeElementById.hasAttribute.returns(false);
- const messages = (await PanelTestProvider.getMessages()).filter(
- m => m.template === "whatsnew_panel_message"
- );
- getMessagesStub.resolves(messages);
- const spy = sandbox.spy(instance, "sendUserEventTelemetry");
- const panelPingId = messages
- .map(({ id }) => id)
- .sort()
- .join(",");
-
- await instance.renderMessages(fakeWindow, fakeDocument, "container-id");
-
- assert.calledOnce(spy);
- assert.calledWithExactly(
- spy,
- fakeWindow,
- "IMPRESSION",
- {
- id: panelPingId,
- },
- {
- value: {
- view: "application_menu",
- },
- }
- );
- assert.calledOnce(fakeSendTelemetry);
- const {
- args: [dispatchPayload],
- } = fakeSendTelemetry.lastCall;
- assert.propertyVal(dispatchPayload, "type", "TOOLBAR_PANEL_TELEMETRY");
- assert.propertyVal(dispatchPayload.data, "message_id", panelPingId);
- assert.deepEqual(dispatchPayload.data.event_context, {
- view: "application_menu",
- });
- });
- });
- describe("#forceShowMessage", () => {
- const panelSelector = "PanelUI-whatsNew-message-container";
- let removeMessagesSpy;
- let renderMessagesStub;
- let addEventListenerStub;
- let messages;
- let browser;
- beforeEach(async () => {
- messages = (await PanelTestProvider.getMessages()).find(
- m => m.id === "WHATS_NEW_70_1"
- );
- removeMessagesSpy = sandbox.spy(instance, "removeMessages");
- renderMessagesStub = sandbox.spy(instance, "renderMessages");
- addEventListenerStub = fakeElementById.addEventListener;
- browser = { ownerGlobal: fakeWindow, ownerDocument: fakeDocument };
- fakeElementById.querySelectorAll.returns([fakeElementById]);
- });
- it("should call removeMessages when forcing a message to show", () => {
- instance.forceShowMessage(browser, messages);
-
- assert.calledWithExactly(removeMessagesSpy, fakeWindow, panelSelector);
- });
- it("should call renderMessages when forcing a message to show", () => {
- instance.forceShowMessage(browser, messages);
-
- assert.calledOnce(renderMessagesStub);
- assert.calledWithExactly(
- renderMessagesStub,
- fakeWindow,
- fakeDocument,
- panelSelector,
- {
- force: true,
- messages: Array.isArray(messages) ? messages : [messages],
- }
- );
- });
- it("should cleanup after the panel is hidden when forcing a message to show", () => {
- instance.forceShowMessage(browser, messages);
-
- assert.calledOnce(addEventListenerStub);
- assert.calledWithExactly(
- addEventListenerStub,
- "popuphidden",
- sinon.match.func
- );
-
- const [, cb] = addEventListenerStub.firstCall.args;
- // Reset the call count from the first `forceShowMessage` call
- removeMessagesSpy.resetHistory();
- cb({ target: { ownerGlobal: fakeWindow } });
-
- assert.calledOnce(removeMessagesSpy);
- assert.calledWithExactly(removeMessagesSpy, fakeWindow, panelSelector);
- });
- it("should exit gracefully if called before a browser exists", () => {
- instance.forceShowMessage(null, messages);
- assert.neverCalledWith(removeMessagesSpy, fakeWindow, panelSelector);
- });
- });
- });
-});
diff --git a/browser/components/asrouter/tests/unit/content-src/components/ASRouterAdmin.test.jsx b/browser/components/asrouter/tests/unit/content-src/components/ASRouterAdmin.test.jsx
index 46d5704107..c5b0d09b39 100644
--- a/browser/components/asrouter/tests/unit/content-src/components/ASRouterAdmin.test.jsx
+++ b/browser/components/asrouter/tests/unit/content-src/components/ASRouterAdmin.test.jsx
@@ -1,4 +1,7 @@
-import { ASRouterAdminInner } from "content-src/components/ASRouterAdmin/ASRouterAdmin";
+import {
+ ASRouterAdminInner,
+ toBinary,
+} from "content-src/components/ASRouterAdmin/ASRouterAdmin";
import { ASRouterUtils } from "content-src/asrouter-utils";
import { GlobalOverrider } from "test/unit/utils";
import React from "react";
@@ -259,4 +262,43 @@ describe("ASRouterAdmin", () => {
});
});
});
+ describe("toBinary", () => {
+ // Bringing the 'fromBinary' function over from
+ // messagepreview to prove it works
+ function fromBinary(encoded) {
+ const binary = atob(decodeURIComponent(encoded));
+ const bytes = new Uint8Array(binary.length);
+ for (let i = 0; i < bytes.length; i++) {
+ bytes[i] = binary.charCodeAt(i);
+ }
+ return String.fromCharCode(...new Uint16Array(bytes.buffer));
+ }
+
+ it("correctly encodes a latin string", () => {
+ const testString = "Hi I am a test string";
+ const expectedResult =
+ "SABpACAASQAgAGEAbQAgAGEAIAB0AGUAcwB0ACAAcwB0AHIAaQBuAGcA";
+
+ const encodedResult = toBinary(testString);
+
+ assert.equal(encodedResult, expectedResult);
+
+ const decodedResult = fromBinary(encodedResult);
+
+ assert.equal(decodedResult, testString);
+ });
+
+ it("correctly encodes a non-latin string", () => {
+ const nonLatinString = "тестовое сообщение";
+ const expectedResult = "QgQ1BEEEQgQ+BDIEPgQ1BCAAQQQ+BD4EMQRJBDUEPQQ4BDUE";
+
+ const encodedResult = toBinary("тестовое сообщение");
+
+ assert.equal(encodedResult, expectedResult);
+
+ const decodedResult = fromBinary(encodedResult);
+
+ assert.equal(decodedResult, nonLatinString);
+ });
+ });
});
diff --git a/browser/components/asrouter/tests/unit/unit-entry.js b/browser/components/asrouter/tests/unit/unit-entry.js
index f2046a81cb..2464b02c58 100644
--- a/browser/components/asrouter/tests/unit/unit-entry.js
+++ b/browser/components/asrouter/tests/unit/unit-entry.js
@@ -14,7 +14,7 @@ import FxMSCommonSchema from "../../content-src/schemas/FxMSCommon.schema.json";
import {
MESSAGE_TYPE_LIST,
MESSAGE_TYPE_HASH,
-} from "modules/ActorConstants.sys.mjs";
+} from "modules/ActorConstants.mjs";
enzyme.configure({ adapter: new Adapter() });
diff --git a/browser/components/asrouter/tests/xpcshell/head.js b/browser/components/asrouter/tests/xpcshell/head.js
index 0c6cec1ac8..fa361a00b9 100644
--- a/browser/components/asrouter/tests/xpcshell/head.js
+++ b/browser/components/asrouter/tests/xpcshell/head.js
@@ -81,10 +81,6 @@ async function makeValidators() {
"resource://testing-common/UpdateAction.schema.json",
{ common: true }
),
- whatsnew_panel_message: await schemaValidatorFor(
- "resource://testing-common/WhatsNewMessage.schema.json",
- { common: true }
- ),
feature_callout: await schemaValidatorFor(
// For now, Feature Callout and Spotlight share a common schema
"resource://testing-common/Spotlight.schema.json",
diff --git a/browser/components/asrouter/tests/xpcshell/test_PanelTestProvider.js b/browser/components/asrouter/tests/xpcshell/test_PanelTestProvider.js
index 3523355659..7e9892a595 100644
--- a/browser/components/asrouter/tests/xpcshell/test_PanelTestProvider.js
+++ b/browser/components/asrouter/tests/xpcshell/test_PanelTestProvider.js
@@ -22,7 +22,6 @@ add_task(async function test_PanelTestProvider() {
cfr_doorhanger: 1,
milestone_message: 0,
update_action: 1,
- whatsnew_panel_message: 7,
spotlight: 3,
feature_callout: 1,
pb_newtab: 2,