Access to WebExtensions API from Debug console

I am looking for an environment where I can try out little bits of code. When I try
var w = browser.windows.getCurrent() in the browser console I get
Uncaught TypeError: browser.windows is undefined.

I’ve tried various other things without luck. I thought the console was supposed to be in the same environment that background scripts run in.

Is there some way I can make it work, or at least understand what environment I am in?

OTOH, window.getWorkspaceID() did run. More about why I care below.

FF 78.10.0esr on Debian GNU/Linux.

My substantive goal is to find out if the windows respond to GetWorkspaceID() and
MoveToWorkspace(); neither is part of the WebExtensions API but look as if they’ve been implemented. FF is not restoring windows to their original virtual desktop. I’m speculating that the gtk calls underlying it don’t work properly with the KDE desktop I’m running.

I have tried making those calls against the window object I can access from the debug console; they weren’t recognized.

To get an environment where webextension APIs are available you need to debug a background page of an extension from about:debugging. Note that you will only have the permissions that the extension has. See https://extensionworkshop.com/documentation/develop/debugging/ for how to get an environment for specific parts of an extension.

Note that extensions do not have access to the window API you likely were probing in the browser console.

Thanks for the info. So if I want to use the window API with GetWorkspaceID() and I can’t use it from an extension, what are my options? It is used in SessionStore.jsm, but it would be nice not to have to rebuild FF to use it.

By the way, I think I have identified the source of the problem restoring windows to the right workspace: the code in various places, including SessionStore.jsm, treats a workspace ID of 0 as a failure code. It (and -1) are perfectly legitimate values on my KDE desktop, and probably most X desktops.