Docs
Web API
chrome.runtime
# chrome.runtime
On this page
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
Member Result Status Gate
idstring realm no permission; contexts: Background, Popup, Tab, Offscreen, Content The extension's id.
lastErrorobject realm no permission; contexts: Background, Popup, Tab, Offscreen, Content The error of the call whose callback runs, else undefined. One left unread is logged.
getURL(string path)string realm no permission; contexts: Background, Popup, Tab, Offscreen, Content The absolute URL of a file of the extension.
getManifest()object realm no permission; contexts: Background, Popup, Tab, Offscreen, Content The manifest, its MSG_* replaced.
connect(optional string extensionId, optional ConnectInfo connectInfo)Port realm no permission; contexts: Background, Popup, Tab, Offscreen, Content A port to the extension's contexts that listen to onConnect (another extension: none).
sendMessage(optional string extensionId, any message, optional MessageOptions options)any host no permission; contexts: Background, Popup, Tab, Offscreen, Content To 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()PlatformInfo host
setUninstallURL(optional string url)void host Accepted; no page opens when the extension is removed.
getContexts(ContextFilter filter)ExtensionContext []host The extension's contexts as the browser knows them (the background only while it runs).
reload()void host The package is read again; every context of the extension closes.
openOptionsPage()void host
# Events
Event Listener's parameters Gate
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.
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.
Property Type
osPlatformOs
archstring
nacl_archstring
# MessageSender
Who sent a message or opened a port (the browser fills it: a context cannot forge it).
Property Type
id (optional)string
url (optional)string
origin (optional)string
frameId (optional)i64
documentId (optional)string
# MessageOptions
Property Type
includeTlsChannelId (optional)bool
# ConnectInfo
Property Type
name (optional)string
includeTlsChannelId (optional)bool
# Port
One end of a port: postMessage, disconnect, onMessage, onDisconnect.
# InstalledDetails
Property Type
reasonOnInstalledReason
previousVersion (optional)string
id (optional)string
# ContextFilter
Property Type
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
Property Type
contextTypeContextType
contextIdstring
tabIdi64
windowIdi64
frameIdi64
documentId (optional)string
documentUrl (optional)string
documentOrigin (optional)string
incognitobool
Previous chrome.permissions
Next chrome.scripting
Edit this page on GitHub