Open Bug 1747397 Opened 4 years ago Updated 1 year ago

Last tab closed by `window.close()` in the webpage's context is restored on restart

Categories

(Firefox :: Session Restore, defect)

Firefox 97
defect

Tracking

()

Tracking Status
firefox97 --- affected

People

(Reporter: gwarser, Unassigned)

References

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0

Steps to reproduce:

uBlock Origin (and maybe AdGuard) now have window-close-if scriptlet https://github.com/gorhill/uBlock/commit/c198b9a748265c0e1ce7f5bad4528d5bf6ce8161
which should be used to close tabs opened from other applications. It works by calling window.close() in page context, so it works only on fresh tabs.

If you add example.com##+js(window-close-if) to uBO "My filters", close all tabs (and browser), then use command line like this:

 ~/firefox-nightly/firefox -P "nightly-test" https://example.com/

there will not be possible to manually launch Firefox again, because it will restore example.com on each startup and this tab will be closed by add-on which in turn will close whole browser.

There is no issue in Chrome because on next manual start Chrome launches "New tab" - does not restore example.com.

Component: Untriaged → Session Restore
See Also: → 490136
Flags: needinfo?(gijskruitbosch+bugs)

I don't know what the needinfo is about, as there doesn't appear to be a question in comment 0?

It's also worth pointing out this isn't new behaviour with bug 490136 - that bug just made it so that if users specifically close the tab (using tab-closing entrypoints like the tab close button, shortcut, context menu item or middle-click), rather than the window, the tab is not restored - but closing the browser window (including a single tab) will restore that tab, as it has done for years. It looks like the complaint in this bug is that window.close inside the web context for the tab should behave the same as closing the tab from the tab UI. That's perhaps fair, but I expect it won't be trivial to implement.

This could be separately addressed by the add-on which clearly must know that something is the initial tab on startup, and could first open a blank tab for the user before deleting the last tab.

I also expect that end users could work around by disabling browser.tabs.closeWindowWithLastTab.

Flags: needinfo?(gijskruitbosch+bugs)
Summary: Last tab closed by `window.close()` is restored on restart → Last tab closed by `window.close()` in the webpage's context is restored on restart

(In reply to :Gijs (he/him) from comment #1)

I don't know what the needinfo is about, as there doesn't appear to be a question in comment 0?

You responded rather fast in bug 490136 I thought it's important, did not expect this attract attention so fast. This bug was created on your request, so I just called you.

This could be separately addressed by the add-on which clearly must know that something is the initial tab on startup, and could first open a blank tab for the user before deleting the last tab.

Whole point is to close undesirable window opened by other application.

I also expect that end users could work around by disabling browser.tabs.closeWindowWithLastTab.

This cannot be a workaround when user want to close undesirable windows.

(In reply to gwarser from comment #2)

(In reply to :Gijs (he/him) from comment #1)

This could be separately addressed by the add-on which clearly must know that something is the initial tab on startup, and could first open a blank tab for the user before deleting the last tab.

Whole point is to close undesirable window opened by other application.

Sure, but (a) the add-on can tell that this is the ONLY tab and the ONLY window open, and just not close it in that case (it's pretty difficult for this to be not user-intentional, surely - unless this other app is opening the browser when it is closed, without the user's permission or something? That just sounds like malware, why not uninstall it?), and (b) if this is the only window and only tab, the add-on could open a blank tab instead of closing the window. That still accomplishes the goal of not opening this site, without trashing the saved session in the process.

I can confirm that the steps detailed in comment 0 are reproducing consistently, however, it appears that the issue is more complicated than it seems. I will confirm this report and let more technical people decide if it's worth addressing or not.

Severity: -- → S4
Status: UNCONFIRMED → NEW
Ever confirmed: true
You need to log in before you can comment on or make changes to this bug.