What context does a popup's JS run in?

80 views
Skip to first unread message

Edu

unread,
Aug 1, 2024, 7:23:07 AMAug 1
to Chromium Extensions
Seems that there are at least 3 different contexts in which JS runs:

- The page script(s)
- The content script(s)
- The background aka service-worker script(s)

Popups can too run JS. What context is this JS running in? Is it its own context? Are there docs explaining the available contexts and key the key features of each? Wasn't able to find an overview or other useful information in the Core Concepts section of the chrome dev docs.

woxxom

unread,
Aug 1, 2024, 2:00:14 PMAug 1
to Chromium Extensions, Edu
The popup is a standard document with a URL like chrome-extension://id/popup.html or whatever else you've specified via default_popup key or chrome.action.setPopup API. It's technically just like a tab for your extension's page, but shown in a special small window. It has access to all of `chrome` API available for this extension. Note that since the popup is a separate window it has its own separate devtools: right-click inside the popup and select "inspect" in the menu.
Reply all
Reply to author
Forward
0 new messages