Search code examples
google-chrome-extensionmicrosoft-edge-extension

Force extension become inactive


With manifest v3 the service workers become inactive after few seconds, but they stay active for a long time if devtools is opened (way beyond 5 minutes).

I need to test how my extension handles its active/inactive cycles. How can I force it to become inactive while devtools is opened?

(can't use devtools persistent logs for action popup, because it's being cleared each time)


Solution

    1. Open any visible page of your extension like the popup or the options
    2. Open devtools for that page (right-click the page, then choose "inspect")
    3. Go to Application tab, then Service Worker on the left.
    4. Now you can click Stop and Start to control the background script. You can also debug it and set breakpoints in this devtools. enter image description here

    If your extension doesn't have any page, open any file in a tab e.g. chrome-extension://ID/manifest.json where ID is the id of your extension. A quick method of doing it is to right-click any file of your extension in devtools Sources panel, then choose "Open in new tab".