Detect if any Firefox window is full screen as an add-on

I want my WebExtension API-based Firefox add-on to behave differently when any tab’s content is running in full screen mode. What is the best way to detect this?

windows.WindowState cannot be used, as fullscreen can mean both running as a fullscreen application and content running in full screen mode.

tabs.query() does not have a query property for detecting if a tab’s content is running in a full screen state.

(Also posted to StackOverflow.)

You’d have to check the tab’s window.fullScreen (https://developer.mozilla.org/en-US/docs/Web/API/Window/fullScreen) property with a content script.

Unfortunately that does not work because window.fullScreen applies to if the Firefox window is running full screen, not any content in the tab running full screen.

The only solution I could find to do this with 100% confidence is to inject a content script into every tab and check if document.fullscreenElement is null.

I have made a feature request related to this use case.