extension API
Hint
The extension API is inherited from Firefox, and its primary documentation is maintained by Mozilla at MDN. Thunderbird implements only the subset of functions, events, and types listed here. The MDN pages may provide further details and examples, but they may also reference features that are not supported in Thunderbird.
The browser.extension API has utilities that can be used by any extension page. It includes support for exchanging messages between an extension and its content scripts or between extensions, as described in detail in Message Passing.
Functions
getBackgroundPage()
– [Added in TB 45]
Returns the JavaScript ‘window’ object for the background page running inside the current extension. Returns null if the extension has no background page.
getURL(path)
– [Added in TB 45]
Converts a relative path within an extension install directory to a fully-qualified URL.
Parameters
path
A path to a resource within an extension expressed relative to its install directory.
getViews([fetchProperties])
– [Added in TB 45]
Returns an array of the JavaScript ‘window’ objects for each of the pages running inside the current extension.
Note
If this is called from a page that is part of a private browsing window, such as a sidebar in a private window or a popup opened from a private window, then its return value will not include the extension’s background page.
Parameters
fetchProperties
tabId
Find a view according to a tab id. If this field is omitted, returns all views.
type
The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: ‘tab’, ‘popup’, ‘sidebar’.
windowId
The window to restrict the search to. If omitted, returns all views.
isAllowedFileSchemeAccess()
– [Added in TB 48]
Retrieves the state of the extension’s access to the ‘file://’ scheme (as determined by the user-controlled ‘Allow access to File URLs’ checkbox.
isAllowedIncognitoAccess()
– [Added in TB 48]
Retrieves the state of the extension’s access to Incognito-mode (as determined by the user-controlled ‘Allowed in Incognito’ checkbox.
Types
ViewType
– [Added in TB 45]
The type of extension view.
Properties
inIncognitoContext
True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. The latter only applies to extensions with ‘split’ incognito_behavior.
lastError
Set for the lifetime of a callback if an ansychronous extension api has resulted in an error. If no error has occured lastError will be undefined.