Hi all,
The runtime.getContexts() API is now available in dev channels, including Chrome Canary:
https://developer.chrome.com/docs/extensions/reference/runtime/#method-getContextsYou can see the original proposal which includes more information about the API here:
https://github.com/w3c/webextensions/blob/main/proposals/runtime_get_contexts.mdWhat’s the goal of the API?The goal of this API is to solve some of the use cases previously solved by the extension.getViews() API in MV2, although without exposing the HTMLWindow object in a service worker (which cannot use windows). We expect one major use case to be determining if pages like the popup or an offscreen document are open.
What should I try?We’re currently looking for any feedback on the behavior of the API. As this API is limited to specific channels, we currently have the most flexibility to make changes before we bring this to stable.
When will this API be released?We do not have a definite release date, but are hoping to ship within the next few Chrome releases depending on the feedback we receive.
What’s still to come?In the future, we plan to expose content script contexts in the API. Additionally, we are looking into updating our messaging APIs to support the context IDs returned.
What design decisions were made?We are explicitly not looking to expose the Window and allow direct access to other contexts from the service worker since HTMLWindow objects are unsupported in worker contexts. Additionally, we plan to keep this API asynchronous as building a list of contexts requires messaging between processes in a way which is inherently asynchronous in nature.
Thanks,
Oliver, on behalf of Chrome Extensions DevRel