/* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ /** * Verifies that the trust panel/toolbar's blocked-tracker count and the * shown on about:protections agree right after * visiting a single tracking page. * (The former counts trackers on a single page, the latter over all pages * in the past seven days — so visiting a single page should cause both to * increase by the same number.) * * This lives in its own file, with no other tests, on purpose: * TrackingDBService.sumAllEvents() flushes every live window's pending * content-blocking events to the database, so that we can assume that * subsequent events are caused by the trackers triggered by the test. * However, if a tab closed by an earlier test still is mid-teardown, * it could still throw new events after the sumAllEvents call, * which would then be counted by the . */ "use strict"; ChromeUtils.defineESModuleGetters(this, { BrowserTestUtils: "resource://testing-common/BrowserTestUtils.sys.mjs", }); XPCOMUtils.defineLazyServiceGetter( this, "TrackingDBService", "@mozilla.org/tracking-db-service;1", Ci.nsITrackingDBService ); const TRACKING_PAGE = // eslint-disable-next-line sdl/no-insecure-url "http://tracking.example.org/browser/browser/base/content/test/protectionsUI/trackingPage.html"; function trustIconContainer() { return document.getElementById("trust-icon-container"); } async function waitForTrustIconClass(className, message) { await TestUtils.waitForCondition( () => trustIconContainer()?.classList.contains(className), message, 100, 100 ); } add_setup(async function setup() { await SpecialPowers.pushPrefEnv({ set: [ ["browser.urlbar.trustPanel.featureGate", true], [ "urlclassifier.features.cryptomining.blacklistHosts", "cryptomining.example.com", ], [ "urlclassifier.features.cryptomining.annotate.blacklistHosts", "cryptomining.example.com", ], // trackingPage.html contains a static