runtime.MessageSender

An object containing information about the sender of a message or connection request that is passed to the runtime.onMessage() listener.

It is also a property of runtime.Port, but only in the Port instance passed into the runtime.onConnect() or runtime.onConnectExternal() listeners.

Type

Values of this type are objects. They contain the following properties:

documentId Optional

string. A UUID of the document that opened the connection.

documentLifecycle Optional

string. The lifecycle state the document that opened the connection was in when the port was created. Note that the lifecycle state of the document may have changed since the port was created.

frameId Optional

integer. The frame that opened the connection. Zero for top-level frames, positive for child frames. This is only set when tab is set.

id Optional

string. The ID of the extension that sent the message, if the message was sent by an extension. If the sender has an ID explicitly set using the browser_specific_settings key in manifest.json, then id has this value. Otherwise, it has the ID that was generated for the sender.

origin Optional

string. The origin of the page or frame that opened the connection. It can differ from the url property (e.g., about:blank) or be opaque (e.g., sandboxed iframes). This is useful for identifying if the origin can be trusted if it isn't apparent from the URL.

tab Optional

tabs.Tab. The tabs.Tab which opened the connection. This property is only present when the connection was opened from a tab (including content scripts).

tlsChannelId Optional

string. The TLS channel ID of the page or frame that opened the connection, if requested by the extension and available.

url Optional

string. The URL of the page or frame hosting the script that sent the message.

If the sender is a script running in an extension page (such as a background page, an options page, or a browser action or page action popup), the URL is in the form "moz-extension://<extension-internal-id>/path/to/page.html". If the sender is a background script and you haven't included a background page, it is "moz-extension://<extension-internal-id>/_generated_background_page.html".

If the sender is a script running in a web page (including content and normal page scripts), then url is the web page URL. If the script is running in an iframe, url is the iframe's URL.

userScriptWorldId Optional

string. The worldId of the USER_SCRIPT world that sent the message. Only present in runtime.onUserScriptMessage and in port.sender for runtime.onUserScriptConnect.

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
MessageSender
Chrome – Full support
Chrome 26 (Release date: 2013-03-26)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote
footnote Before version 54, 'id' was the add-on's internal UUID, not the add-on ID.
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote
footnote Before version 54, 'id' was the add-on's internal UUID, not the add-on ID.
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
documentId
Chrome – Full support
Chrome 106 (Release date: 2022-09-27)
footnote Full support
Edge – Full support
Edge 106 (Release date: 2022-10-03)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 92 (Release date: 2022-10-19)
footnote Full support
Safari – Full support
Safari 18.4 (Release date: 2025-03-31)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – Full support
Safari on iOS 18.4 (Release date: 2025-03-31)
footnote Full support
documentLifecycle
Chrome – Full support
Chrome 106 (Release date: 2022-09-27)
footnote Full support
Edge – Full support
Edge 106 (Release date: 2022-10-03)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 92 (Release date: 2022-10-19)
footnote Full support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
frameId
Chrome – Full support
Chrome 41 (Release date: 2015-03-03)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 28 (Release date: 2015-03-10)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
id
Chrome – Full support
Chrome 26 (Release date: 2013-03-26)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
origin
Chrome – Full support
Chrome 80 (Release date: 2020-02-04)
footnote Full support
Edge – Full support
Edge 80 (Release date: 2020-02-07)
footnote Full support
Firefox – Full support
Firefox 126 (Release date: 2024-05-14)
footnote Full support
Opera – Full support
Opera 67 (Release date: 2020-03-03)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 126 (Release date: 2024-05-14)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
tab
Chrome – Full support
Chrome 26 (Release date: 2013-03-26)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
tlsChannelId
Chrome – Full support
Chrome 32 (Release date: 2014-01-14)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 19 (Release date: 2014-01-28)
footnote Full support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
url
Chrome – Full support
Chrome 28 (Release date: 2013-07-09)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

Note: This API is based on Chromium's chrome.runtime API. This documentation is derived from runtime.json in the Chromium code.