First off, that is a pretty good summary and good read for beginners. It is clear that you have put a lot of effort into it: I have read it and here are some hints for improvements and corrections:
Note: Google Chrome uses the chrome
namespace for its APIs. Firefox supports both browser
and chrome
, so if you want to make your extension available cross-browser this is something you have to consider.
I’d mention that there are polyfills for the browser
namespace. Generally, browser
has a number of advantages which make it preferable over chrome
.
The Background Script also runs across multiple browser instances (e.g. you have more than one Firefox window open at the same time)
If you open additional windows (Ctrl+N
, double click the shortcut, …) they are opened in that same instance (same background process, same profile folder).
To launch a new instance, you have to launch Firefox with CLI args to prevent it from simply telling the existing instance to continue the command.
Different instances do not share their extension process(es).
Strictly speaking [UI pages] are somehow a hybrid between Content and Background Scripts.
UI pages have pretty much nothing in common with content scripts. They behave like they are iframe
s within the background page (ecxept that they are not in the DOM and are rendered elsewhere). If they are not opened in a private window of container tab, they can even access each others global scopes via browser.extension.getBackgroundPage()
/.getViews()
, because they are executed in the same process.
Background Scripts do not have access to a DOM
They do, it just won’t be rendered anywhere. But there are some useful things you can do with it, eg. attaching <script>
s or iframe
s as sandboxes. I even attach a number of audio
elements that I use for background playback to the DOM for debugging.
Debugging popups […] 1. On your previously opened debug window
This is quite a jump …
sometimes you need functionality that only privileged scripts an offer
can offer?
That’s it 