How to manually suspend Firefox extension's background script?

General discussion about web technology.
Post Reply
barbaz
Senior Member
Posts: 10949
Joined: Sat Aug 03, 2013 5:45 pm

How to manually suspend Firefox extension's background script?

Post by barbaz »

For converting Firefox extension from Manifest V2 to Manifest V3, the background script needs to be adapted to be non-persistent. Which means it's necessary to test that the background script behaves correctly when it gets suspended and then reloaded in a variety of states.

Such testing would be greatly facilitated by manually requesting immediate suspend of the background script.

How to do this in Firefox?

The reason to only "request" suspend is because of this:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onSuspend wrote:Note: If something prevents the event page from being unloaded, the runtime.onSuspendCanceled event will be sent and the page won't be unloaded.
... so testing this properly requires not forcing suspend in situations where an automatic suspend attempt would have been cancelled.

Thanks for any ideas.
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (X11; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0
Post Reply