Trigger Listeners

A set of action listeners that can be used to trigger CFR messages.


As part of the CFR definition the message can register at most one trigger used to decide when the message is shown.

Most triggers (unless otherwise specified) take the same arguments of hosts and/or patterns used to target the message to specific websites.

// Optional set of hosts to filter out triggers only to certain websites
let params: string[];
// Optional set of [match patterns]( to filter out triggers only to certain websites
let patterns: string[];
  // Show the message when opening
  "trigger": { "id": "openURL", "params": ["", ""] }
  // Show the message when opening any HTTP, HTTPS URL.
  trigger: { id: "openURL", patterns: ["*://*/*"] }

Available trigger actions


Happens when the user loads a Reader Mode compatible webpage.


Happens when the user bookmarks or navigates to a bookmarked URL.

Does not filter by host or patterns.


Happens every time a user navigates (or switches tab to) to any of the hosts or patterns arguments provided. Additionally it stores timestamps of these visits that are provided back to the targeting context. They can be used inside of the targeting expression:

// Has at least 3 visits in the past hour
recentVisits[.timestamp > (currentDate|date - 3600 * 1000 * 1)]|length >= 3
interface visit {
  host: string,
  timestamp: UnixTimestamp
// Host and timestamp for every visit to "Host"
let recentVisits: visit[];


Happens every time the user loads a new URL that matches the provided hosts or patterns. During a browsing session it keeps track of visits to unique urls that can be used inside targeting expression.

// True on the third visit for the URL which the trigger matched on
visitsCount >= 3


Happens every time the user saves or updates a login via the login capture doorhanger. Provides a type to diferentiate between the two events that can be used in targeting.

Does not filter by host or patterns.

let type = "update" | "save";


Happens at the and of a document load and for every subsequent content blocked event. Provides a context of the number of pages loaded in the current browsing session that can be used in targeting.

Does not filter by host or patterns.

The event it reports back is a flag or a combination of flags merged together by ANDing the various STATE_BLOCKED_* flags.

let event: ContentBlockingEventFlag;
let pageLoad = number;


Happens at startup, when opening a newtab and when navigating to about:home. At startup it provides the result of running DefaultBrowserCheck.willCheckDefaultBrowser to follow existing behaviour if needed. On the newtab/homepage it reports the source as newtab.

let source = "newtab" | undefined;
let willShowDefaultPrompt = boolean;


Happens when the user successfully goes through a captive portal authentication flow.


Watch for changes on any number of preferences. Runs when a pref is added, removed or modified.

// Register a message with the following trigger
  id: "preferenceObserver",
  params: ["pref name"]


Happens when navigating to about:firefoxview or other about pages with Feature Callout tours enabled


Happens when the user closes n or more tabs in a session

// Register a message with the following trigger id and
// include the tabsClosedCount context variable in the targeting.
// Here, the message triggers after two or more tabs are closed.
  id: "nthTabClosed",
  targeting: "tabsClosedCount >= 2"