/* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ /** * Test TrustPanel Breach Icon logic. */ "use strict"; ChromeUtils.defineESModuleGetters(this, { RemoteSettings: "resource://services-settings/remote-settings.sys.mjs", BrowserTestUtils: "resource://testing-common/BrowserTestUtils.sys.mjs", ExperimentAPI: "resource://nimbus/ExperimentAPI.sys.mjs", NimbusTestUtils: "resource://testing-common/NimbusTestUtils.sys.mjs", PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs", UrlClassifierTestUtils: "resource://testing-common/UrlClassifierTestUtils.sys.mjs", }); const TRACKING_PAGE = // eslint-disable-next-line sdl/no-insecure-url "http://tracking.example.org/browser/browser/base/content/test/browser-protectionsUI/trackingPage.html"; // Same trackingPage.html, served from a different eTLD+1 than TRACKING_PAGE // (and than the cryptomining/fingerprinting tracker hosts, which are under // example.com) so that navigations between the two count as cross-site. // another-tracking.example.net is a pre-registered test-only domain used // elsewhere in the tree for this same purpose (see server-locations.txt). const OTHER_HOST_TRACKING_PAGE = // eslint-disable-next-line sdl/no-insecure-url "http://another-tracking.example.net/browser/browser/base/content/test/browser-protectionsUI/trackingPage.html"; // Cross-site to TRACKING_PAGE. Responds with 204 No Content, or redirects when // given a ?redirect= query. const NO_CONTENT_URL = // eslint-disable-next-line sdl/no-insecure-url "http://another-tracking.example.net/browser/browser/base/content/test/browser-trustPanel/navigation.sjs"; const TEST_BREACH = { // Make sure the breach is a recent one, since breaches older than a year are not taken into account: AddedDate: Temporal.Now.plainDateTimeISO().toString(), BreachDate: Temporal.Now.plainDateISO().toString(), Domain: "example.org", Name: "TestBreach", PwnCount: 42, DataClasses: ["Email addresses", "Passwords"], _status: "synced", id: "047940fe-d2fd-4314-b636-b4a952ee1234", last_modified: "1541615610052", schema: "1541615609018", }; add_setup(async function setup() { await RemoteSettings("fxmonitor-breaches").emit("sync", { data: { current: [TEST_BREACH] }, }); await SpecialPowers.pushPrefEnv({ set: [ ["browser.urlbar.trustPanel.featureGate", true], ["browser.urlbar.trustPanel.breachAlerts", true], [ "urlclassifier.features.cryptomining.blacklistHosts", "cryptomining.example.com", ], [ "urlclassifier.features.cryptomining.annotate.blacklistHosts", "cryptomining.example.com", ], // trackingPage.html contains a static