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.

Return type (Promise)

_returns

getURL(path)

– [Added in TB 45]

Converts a relative path within an extension install directory to a fully-qualified URL.

Parameters

path

path

(string)

A path to a resource within an extension expressed relative to its install directory.

Return type (Promise)

_returns

string

The fully-qualified URL to the resource.

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

[fetchProperties]

(object, optional)

tabId

[tabId]

(integer, optional)

Find a view according to a tab id. If this field is omitted, returns all views.

type

[type]

(ViewType, optional)

The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: ‘tab’, ‘popup’, ‘sidebar’.

windowId

[windowId]

(integer, optional)

The window to restrict the search to. If omitted, returns all views.

Return type (Promise)

_returns

array of Window

Array of global objects

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.

Return type (Promise)

_returns

boolean

True if the extension can access the ‘file://’ scheme, false otherwise.

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.

Return type (Promise)

_returns

boolean

True if the extension has access to Incognito mode, false otherwise.

Types

ViewType

– [Added in TB 45]

The type of extension view.

string

Supported values:

popup

popup

sidebar

sidebar

– [Added in TB 54]

tab

tab

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.