summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/protectionsUI/browser_protectionsUI_info_message.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/base/content/test/protectionsUI/browser_protectionsUI_info_message.js')
-rw-r--r--browser/base/content/test/protectionsUI/browser_protectionsUI_info_message.js90
1 files changed, 90 insertions, 0 deletions
diff --git a/browser/base/content/test/protectionsUI/browser_protectionsUI_info_message.js b/browser/base/content/test/protectionsUI/browser_protectionsUI_info_message.js
new file mode 100644
index 0000000000..fadfaaab98
--- /dev/null
+++ b/browser/base/content/test/protectionsUI/browser_protectionsUI_info_message.js
@@ -0,0 +1,90 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* Tests the info message that apears in the protections panel
+ * on first render, and afterward by clicking the "info" icon */
+
+"use strict";
+
+const TRACKING_PAGE =
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ "http://tracking.example.org/browser/browser/base/content/test/protectionsUI/trackingPage.html";
+
+add_setup(async function () {
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ // Set the auto hide timing to 100ms for blocking the test less.
+ ["browser.protections_panel.toast.timeout", 100],
+ // Hide protections cards so as not to trigger more async messaging
+ // when landing on the page.
+ ["browser.contentblocking.report.monitor.enabled", false],
+ ["browser.contentblocking.report.lockwise.enabled", false],
+ ["browser.contentblocking.report.proxy.enabled", false],
+ ["privacy.trackingprotection.enabled", true],
+ // Set the infomessage pref to ensure the message is displayed
+ // every time
+ ["browser.protections_panel.infoMessage.seen", false],
+ ],
+ });
+ let oldCanRecord = Services.telemetry.canRecordExtended;
+ Services.telemetry.canRecordExtended = true;
+ Services.telemetry.clearEvents();
+
+ registerCleanupFunction(() => {
+ Services.telemetry.canRecordExtended = oldCanRecord;
+ Services.telemetry.clearEvents();
+ });
+});
+
+add_task(async function testPanelInfoMessage() {
+ let tab = await BrowserTestUtils.openNewForegroundTab(
+ gBrowser,
+ TRACKING_PAGE
+ );
+
+ await openProtectionsPanel();
+
+ await TestUtils.waitForCondition(() => {
+ return gProtectionsHandler._protectionsPopup.hasAttribute(
+ "infoMessageShowing"
+ );
+ });
+
+ // Test that the info message is displayed when the panel opens
+ let container = document.getElementById("messaging-system-message-container");
+ let message = document.getElementById("protections-popup-message");
+ let learnMoreLink = document.querySelector(
+ "#messaging-system-message-container .text-link"
+ );
+
+ // Check the visibility of the info message.
+ ok(
+ BrowserTestUtils.isVisible(container),
+ "The message container should exist."
+ );
+
+ ok(BrowserTestUtils.isVisible(message), "The message should be visible.");
+
+ ok(BrowserTestUtils.isVisible(learnMoreLink), "The link should be visible.");
+
+ // Check telemetry for the info message
+ let events = Services.telemetry.snapshotEvents(
+ Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS,
+ false
+ ).parent;
+ let messageEvents = events.filter(
+ e =>
+ e[1] == "security.ui.protectionspopup" &&
+ e[2] == "open" &&
+ e[3] == "protectionspopup_cfr" &&
+ e[4] == "impression"
+ );
+ is(
+ messageEvents.length,
+ 1,
+ "recorded telemetry for showing the info message"
+ );
+ //Clear telemetry from this test so that the next one doesn't fall over
+ Services.telemetry.clearEvents();
+ BrowserTestUtils.removeTab(tab);
+});