Open Bug 1409375 Opened 5 years ago Updated 4 months ago

Should we support window.close() for closing extensions pages?

Categories

(WebExtensions :: General, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: mkaply, Unassigned)

References

Details

Sometimes extensions use a standard web page as their options page.

To do this, they display their page and then close the options page.

This is allows on Chrome. It should be allowed on Firefox.
It can call browser.tab.close() I believe? Presumably you want to call window.close()?
> It can call browser.tab.close() I believe?

Well there's browser.tabs.remove, but you have to pass a tab ID. There's not an easy way to just close the tab you are in.

> Presumably you want to call window.close()?

Yes. In migrating Chrome code, you have the ability to use window.close() to close your own options page.
The specific error is "Scripts may not close windows that were not opened by script." which is not correct.

This also happens when you try to close your own new tab page (which again works on Chrome).
So you are correct. Querying current tab and removing works. So I guess the question is should we support window.close or require that people change to tabs.remove.

Should this move to untriaged?
Component: WebExtensions: General → WebExtensions: Untriaged
Summary: A WebExtension should be able to close its own Options Page → Should we support window.close() for closing extensions pages?
See also bug 1301227, that lets you enable window.close() when creating a new window with browser.windows.create().  It doesn't handle the options page though.  Options pages are kind of a mess though, what do we do if an extension calls window.close() on an inline options page?
Priority: -- → P3
Actually, this is more about tabs created with browser.tabs.create() - closing these via window.close() still isn't possible as of current Firefox 57 nightly. The solution is sending a message to the background page that will give you your tabId back, then calling browser.tabs.remove().
Product: Toolkit → WebExtensions
Bulk move of bugs per https://bugzilla.mozilla.org/show_bug.cgi?id=1483958
Component: Untriaged → General
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.