browser/components/urlbar/tests/browser-quickactions/browser_commands.js opens
about:preferences#experimental through the "labs" quick action and closes the tab
before it has loaded, then fails with "leaked 1 window(s) until shutdown
[url = about:preferences#experimental]".
main.js loads its pane modules with the synchronous ChromeUtils.importESModule
({ global: "current" }), which spins the event loop until the module graph has
been fetched, so the tab can be closed part way through. Evaluation then resumes
against a torn down window, and the modules imported after that point run their
own top level code against it: they register Settings whose setup() adds pref and
observer service observers long after onUnload removed the ones that existed, and
tabs-browsing.mjs throws a TypeError reaching for
window.browsingContext.topChromeWindow.
Preferences.addSetting has to refuse after unload as well, because no check at an
import site can help the module whose load was the spin: languages.mjs was
already in flight when the window went away, so it finishes and registers its
settings regardless, as does the rest of main.js.
Bug 2041626 stopped this spin from hanging shutdown outright; this is the
post-unload execution that fix left behind.
Differential Revision: https://phabricator.services.mozilla.com/D321912