Wren a web browser where WebAssembly runs everything, JavaScript included

chrome.runtime

The extension's own facts, its messages and its ports (src/page/ext_api.odin, ext_router.odin, ext_tabs.odin). An offscreen document has this namespace only; a content script has its messages, its ports and its own facts.

Gate: no permission; contexts: Background, Popup, Tab, Offscreen. Source: api/ext_runtime.widl.

Methods and properties

MemberResultStatusGate
idstringrealmno permission; contexts: Background, Popup, Tab, Offscreen, ContentThe extension's id.
lastErrorobjectrealmno permission; contexts: Background, Popup, Tab, Offscreen, ContentThe error of the call whose callback runs, else undefined. One left unread is logged.
getURL(string path)stringrealmno permission; contexts: Background, Popup, Tab, Offscreen, ContentThe absolute URL of a file of the extension.
getManifest()objectrealmno permission; contexts: Background, Popup, Tab, Offscreen, ContentThe manifest, its MSG_* replaced.
connect(optional string extensionId, optional ConnectInfo connectInfo)Portrealmno permission; contexts: Background, Popup, Tab, Offscreen, ContentA port to the extension's contexts that listen to onConnect (another extension: none).
sendMessage(optional string extensionId, any message, optional MessageOptions options)anyhostno permission; contexts: Background, Popup, Tab, Offscreen, ContentTo every page and the background of the extension, not the sender and not the content scripts. The first answer wins; with no receiver, "Could not establish connection. Receiving end does not exist.".
getPlatformInfo()PlatformInfohost
setUninstallURL(optional string url)voidhostAccepted; no page opens when the extension is removed.
getContexts(ContextFilter filter)ExtensionContext[]hostThe extension's contexts as the browser knows them (the background only while it runs).
reload()voidhostThe package is read again; every context of the extension closes.
openOptionsPage()voidhost

Events

EventListener's parametersGate
onMessageany message, MessageSender sender, function sendResponseno permission; contexts: Background, Popup, Tab, Offscreen, Content
onConnectPort portno permission; contexts: Background, Popup, Tab, Offscreen, Content
onInstalledInstalledDetails details
onStartup``
onSuspend``
onSuspendCanceled``
onUpdateAvailableobject details

Types

OnInstalledReason

A string: "install", "update", "chrome_update", "shared_module_update". chrome.runtime.OnInstalledReason names them.

PlatformOs

A string: "mac", "win", "android", "cros", "linux", "openbsd", "fuchsia". chrome.runtime.PlatformOs names them.

ContextType

A string: "TAB", "POPUP", "BACKGROUND", "OFFSCREEN_DOCUMENT", "SIDE_PANEL", "DEVELOPER_TOOLS". chrome.runtime.ContextType names them.

PlatformInfo

PropertyType
osPlatformOs
archstring
nacl_archstring

MessageSender

Who sent a message or opened a port (the browser fills it: a context cannot forge it).

PropertyType
id (optional)string
url (optional)string
origin (optional)string
frameId (optional)i64
documentId (optional)string

MessageOptions

PropertyType
includeTlsChannelId (optional)bool

ConnectInfo

PropertyType
name (optional)string
includeTlsChannelId (optional)bool

Port

One end of a port: postMessage, disconnect, onMessage, onDisconnect.

PropertyType
namestring
sender (optional)MessageSender

InstalledDetails

PropertyType
reasonOnInstalledReason
previousVersion (optional)string
id (optional)string

ContextFilter

PropertyType
contextTypes (optional)ContextType[]
contextIds (optional)string[]
tabIds (optional)i64[]
windowIds (optional)i64[]
frameIds (optional)i64[]
documentIds (optional)string[]
documentUrls (optional)string[]
documentOrigins (optional)string[]
incognito (optional)bool

ExtensionContext

PropertyType
contextTypeContextType
contextIdstring
tabIdi64
windowIdi64
frameIdi64
documentId (optional)string
documentUrl (optional)string
documentOrigin (optional)string
incognitobool

Edit this page on GitHub