The documentation for browser.windows.remove() (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows/remove) explains how to remove a window created from a background script in response to the user installing or updating an extension.
However, it does not show an example and my attempts to close an update window in response to its Cancel button fail. I can close the window from the background script, but that does not work for me because I cannot figure out how to send a command message from the update window to the background script.
I use the following code (determined by experiment) to obtain the window id integer when creating it:
browser.windows.create({url:url, type: “detached_panel”}).then(E2);
function E2(info)
{
g.uwid=info.id;
} // E2
I use a listener to detect when the Cancel button in the update window is clicked.
Can anyone provide a tested answer? I’ll update the documentation.
Stuff like this baffles me.