Closed Bug 490136 Opened 16 years ago Closed 4 years ago

When firefox is exited by closing the last tab, that tab is restored on restart

Categories

(Firefox :: Session Restore, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
92 Branch
Tracking Status
firefox92 --- fixed

People

(Reporter: vulcanb, Assigned: pyjacpp)

References

(Blocks 1 open bug)

Details

(Keywords: parity-chrome)

Attachments

(1 file)

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.9) Gecko/2009042113 Ubuntu/8.10 (intrepid) Firefox/3.0.9 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.9) Gecko/2009042113 Ubuntu/8.10 (intrepid) Firefox/3.0.9 If I close Firefox by closing the last open tab, and Firefox is set to restore the last open tabs on restart, it reopens the tab that I've explicitly closed. To me, closing a tab is a signal that I am done with it - if Firefox is exited this way, I would rather that my homepage be the page that is opened on the next Firefox startup. Reproducible: Always Steps to Reproduce: 1. Set Firefox's startup behaviour to "Show my windows and tabs from last time". 2. Exit Firefox by closing the last open tab. 3. Open Firefox again Actual Results: The tab I explicitly closed is opened again. Expected Results: A tab I explicitly closed should stay closed - my homepage would be a good alternative to bring up on restart.
When the last open tab is closed, it leaves firefox with nothing, so firefox closes as well. 3.5 has some modifications with how tab closing works. At least with 3.6, but I believe with 3.5 as well, it is impossible to close the last tab, you must close the window.
Here is perhaps an illustrative use scenario. I open Google Reader, and spawn anything that looks interesting in new tabs. If I have to shut down before I've read all the articles, I'd like them to be restored when I re-open Firefox. If I finish them all, when I close Firefox by closing the last article's tab, I don't want that article (which I've already read) to be restored when I restart Firefox.
Component: General → Session Restore
OS: Linux → All
QA Contact: general → session.restore
Hardware: x86 → All
Version: unspecified → Trunk
AFAICT there's no longer any way to close the last open tab without obviously closing the window as well (at least the tab's close button has been removed), which would make this bug either INVALID or WONTFIX (if reworded as enhancement request to be able to close the last open tab).
Whiteboard: [invalid?]
I would like to second on this issue. It is acceptable for closing the last tab to close Firefox. However the closed tab should not be loaded the next time Firefox is started, but the users homepage instead. If the last tab is explicitly closed (I use ctrl-w) It should not be retained for the next loading of the browser.
Blocks: cuts-cruft
No longer blocks: cuts-cruft
I don't think the bug is invalid, but I could see "won't fix". I get the behavior as described in the initial report, and I understand the point from the bug report. When there is only one tab left (and the browser is set to exit when the last tab is closed), the tab menu (right-click on the tab) has "Close Tab" disabled and pressing "c" does nothing. This avoids the problem. But there are still many ways to exit. Some are: o menu/quit, Ctrl+Shift+W, Alt+F4 : These are exit or close window and should save the tabs for the next Firefox start. o Kill the process. This will save the session to be restored next time. o Ctrl-W, Ctrl-F4 : These are Close Tab. For consistency with the tab menu they should be disabled. If they aren't disabled they should close the tab, then exit since Firefox has nothing to do. When Firefox restarts it should not restore that last tab. While I think disabling control-w would be consistent, I think it would be more confusing to me than the current behavior (but then, my preference is to get a blank tab when I close the last open tab).
I believe this should be WONTFIX if it is indeed invalid. Leaving the final call up to Paul.
Whiteboard: [invalid?] → [invalid?][session-store-testday]
This is a duplicate of #343876.
Sorry, bug 343876 is not really a duplicate. It seems that as Tyler wrote, Firefox 3.6 and later do not allow just closing the last tab, you need to close the window. That seems to cause this ambiguity on what should happen when you close the last tab. This bug appears to replace bug 343876, with the new tabs behavior.
I just realize that Chromium seems to do this correctly. If you have one window with one tab and close the window, the tab is reopened, however if you "just close the tab" (Ctrl+W or clicking on the tab's X icon), it is not reopened when relaunching. It's arguable that even closing the window shouldn't bring back the window's tabs. Sometimes, you do close a window meaning to get rid of all its tabs because you're done with a certain activity. But we should probably first solve this then see how it feels...
I often see that problem, especially under Linux (I don't use MS-Windows as much). But, what looks really "funny" is when I restart FireFox (or SeaMonkey) and it asks me whether I want to open an empty tab. Yes. If you close all your tabs, and all that's left is an empty tab, then you close FireFox, on next restart, quite often, I get the Restore Session request with "Do you want to restart with an empty tab?"
(In reply to Alexis Wilke from comment #10) > I often see that problem, especially under Linux (I don't use MS-Windows as > much). But, what looks really "funny" is when I restart FireFox (or > SeaMonkey) and it asks me whether I want to open an empty tab. Yes. If you > close all your tabs, and all that's left is an empty tab, then you close > FireFox, on next restart, quite often, I get the Restore Session request > with "Do you want to restart with an empty tab?" I'm sorry to say, that is expected behavior for Firefox. See the resolution of https://bugzilla.mozilla.org/show_bug.cgi?id=631882 No, I have no idea why about:blank is so complicated that it can't be restored.

It's 2019, and I still have this issue. :)

  1. Version

Firefox Quantum 67.0.4 (64-bit),
on NixOS 19.03 (VERSION="19.03.172979.8634c3b6199 (Koi)")

  1. Relevant options

browser.tabs.closeWindowWithLastTab: true (default)
browser.startup.page: 3 (modified)

  1. Steps to reproduce

A. Open Firefox
B. Navigate to https://bugzilla.mozilla.org/show_bug.cgi?id=490136
C. Close the tab with Ctrl-w
D. (Firefox exits)
E. Re-open Firefox

  1. Expected behavior

When I reopen Firefox, I expect to see my homepage (browser.startup.homepage)

  1. Actual behavior

When I reopen Firefox, I am taken to https://bugzilla.mozilla.org/show_bug.cgi?id=490136

By the way, the same problem exists if you replace step C with "Close the tab by clicking on the 'x' in the tab bar"

Still there in 73.0.1 (64-bit) on Ubuntu.

Keywords: parity-chrome

Per the reporter's STR, this feels more like a bug to me. In addition, this works correctly in Firefox macOS, likely because there is an explicit quit action which is somehow combined in other OSes.

Status: UNCONFIRMED → NEW
Type: enhancement → defect
Has STR: --- → yes
Ever confirmed: true
Whiteboard: [invalid?][session-store-testday]

(In reply to Asif Youssuff from comment #15)

Per the reporter's STR, this feels more like a bug to me. In addition, this works correctly in Firefox macOS, likely because there is an explicit quit action which is somehow combined in other OSes.

Thanks for the activity!

This bug affects me dozens of times per day.

I have gotten quite adept at pressing Escape to cancel loading whatever unwanted page pops up when I start Firefox.

I can explain the expected behavior in greater detail if it helps.

We confirm this issue on our forum https://forum.mozillaitalia.org/index.php?topic=74638.0
I tried to replicate the issue but as I have a pinned tab always I don't have that issue at all.

I just reproduced it in Nightly, the behavior still differs from Chrome where if you close the window the page is restored, but if you close the tab it's not.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Status: REOPENED → NEW

Thank Asif for closing some duplicate issues, including mine. I had no idea this had been an issue for 12 years already. I'm kind of amazed, because I run into this issue every time I close my last tab. It's not like "Restore previous session" is an obscure feature.

Hopefully it will now get some attention from the developers. I haven't personally worked with the code, but it seems likely to be a straightforward implementation.

There is obviously a function that runs when a tab is closed (I'll call it "closeTab") which removes it from the session, and another function that closes the window (e.g. "closeFF"). They obviously can run independently in the case of browser.tabs.closeWindowWithLastTab: false. So it seems that in the case of closeWindowWithLastTab: true, when the last tab is closed, all that would be needed to solve this is to run "closeTab" first (as if closeWindowWithLastTab is false), and then immediately run "closeFF".

osakawebbie, yes, it seems that it would be that simple to achieve the desired bahaviour already observed in Chrome.
It could be more complex than we expect, but it would appear that so far the biggest challenge has been to explain the issue to the developers.

I'd like to add that on Mac it works okay: when I close the last tab, it doesn't get restored on next startup.

But not on my PC and this is really frustrating.

Summary from my point of view
(Cross-platform FF user, Fedora/Ubuntu/../Windows, used to GNOME shortcuts)
Power-Users love keyboard shortcuts, but they need to be consistently over platforms, otherwise the user will curse you!
I'd like to reference https://developer.gnome.org/hig/stable/keyboard-input.html.en, although Linux Distros are no showcase either.

Ctrl+W

  • closes current Tab (default for tabbed windows), similar to the X on the tab
  • if it is the last tab, it should be up to the application to close the window or not
  • having an application with multiple windows ( having open tabs), it is good to close the window with its last tab
  • but for closing the last tab of the last window, my personal preference would be open a fresh new tab

Ctrl+F4

  • seems to be equal to Ctrl+W, e.g. close document in MS Word, but I've never used that

Alt+F4

  • similar to the X on a window
  • especially Windows users would expect this to close a focused window, no matter of tabs

Ctrl+Q

  • quit the application, including all windows
  • more similar to File > Quit and 'Close all windows' on right click the application in the collapsed Windows taskbar

Ctrl+Shift+W

  • should not be the same as Ctrl+Q, because the logical conclusion should be to close all tabs of a window
  • regardless of the behavior on Ctrl+W for the last tab, I would expect that application is not terminated, otherwise I would have done Ctrl+Q
  • pinned tabs should be excluded from closing
  • currently it has the same behavior than quit and even with browser.tabs.closeWindowWithLastTab: false it closes the window

'Restore previous session' on startup is the uppermost setting and my personal default. I quit my day with Ctrl+Q or 'suspend hungry FF' if I need some more RAM for other applications. I just found Ctrl+Shift+D to bookmark all tabs of a window to a custom folder, which is btw. not documented here: https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly

I would love to see Ctrl+Shift+D and Ctrl+Shift+W as a local privacy preserving alternative to the OneTab AddOn, which has 100k users and about 100 reviews complaining about favicons generated with G.

Finally, the only way to bring up an explicitly closed tab should be explicitly restore it, e.g. with Ctrl+Shift+T. Even with the option 'Restore previous session', opening the browser should never bring up an explicitly closed tab nor it should open a session cleared with Ctrl+Shift+W.

Thank you!

If one closes the last tab with the session restores enabled, it will re-open after restart.
Fix that by closing completely the tab before the stop of the browser.

Assignee: nobody → antonin.loubiere
Status: NEW → ASSIGNED
Attachment #9227885 - Attachment description: Bug 490136 - fix last tab re-opening after the close with session restore. r?jaws → Bug 490136 - fix last tab re-opening after the close with session restore. r?mstriemer
Attachment #9227885 - Attachment description: Bug 490136 - fix last tab re-opening after the close with session restore. r?mstriemer → WIP: Bug 490136 - fix last tab re-opening after the close with session restore.
Attachment #9227885 - Attachment description: WIP: Bug 490136 - fix last tab re-opening after the close with session restore. → Bug 490136 - fix last tab re-opening after the close with session restore.
Blocks: 1719757

Will the fix for this issue affect bug 1321406 where restarting with only pinned tabs doesn't restore the final session but instead loads the Homepage?

This issue doesn't affect bug 1321406. Because tabs are remaining, and the patch is only affecting when one closes all the remaining tabs.

Pushed by gijskruitbosch@gmail.com: https://hg.mozilla.org/integration/autoland/rev/da1412413022 fix last tab re-opening after the close with session restore. r=Gijs
Status: ASSIGNED → RESOLVED
Closed: 5 years ago4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 92 Branch

Backed out for causing bc failures in browser/components/sessionstore/test/browser_625016.js

Backout link: https://hg.mozilla.org/integration/autoland/rev/4ea53a97727b6d1c6d35449b824ed5ad69fde344

Push with failures

Failure log

Status: RESOLVED → REOPENED
Flags: needinfo?(pyjacpp)
Resolution: FIXED → ---
Target Milestone: 92 Branch → ---
Status: REOPENED → ASSIGNED
Flags: needinfo?(pyjacpp)
Pushed by gijskruitbosch@gmail.com: https://hg.mozilla.org/integration/autoland/rev/d50f9d0cd6db fix last tab re-opening after the close with session restore. r=Gijs
Status: ASSIGNED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 92 Branch

Just ran into this issue again and wondered: "Would there be an update?"
Incredibly happy to see a fix is planned for the very next version! Can't wait. Dank je wel, Gijs!

This is not fully fixed. To still reproduce:
· open regular tab
· open private window
· close regular tab
· close private window
· start Firefox again
The regular tab will be back. Reopen or new report?

Hey, I'm glad this was fixed. :)

Unfortunately I am now experiencing a bug that seems related.

How to reproduce:

  1. Create a new empty directory as a new empty profile, tmp_profile=$(mktemp -d)
  2. Start firefox (use same profile for every following start): firefox --profile $tmp_profile
  3. Turn on session restoring in Settings.
  4. Open a few tabs.
  5. Close firefox and restart.
  6. (Tabs are restored, as expected)
  7. Close each tab individually with Ctrl+w, including the last tab
  8. Restart Firefox
  9. (No tabs are restored, as expected!)
  10. Open a few tabs.
  11. Close firefox and restart.
  12. Tabs are not restored! This is not expected.

I have found that I need to toggle the Session Restore setting in order to re-enable session restores. I'm not exactly sure what it takes, yet.

[b@bryan-laptop:~/tmp]$ firefox --version
Mozilla Firefox 92.0

I am unable to reproduce the behavior reported by Bryan in comment 38. Also on Firefox 92.0. Ubuntu with XFCE.

Bryan, this issue is closed. New problem reports need to be in new bug. Please recheck your steps to reproduce and click the "NewBug" link at the top of the page.

(In reply to B.J. Herbison from comment #40)

New problem reports need to be in new bug. Please recheck your steps to reproduce and click the "NewBug" link at the top of the page.

What about mine? Is that considered a case of this bug or a separate one?

(In reply to fabianroeling from comment #41)

(In reply to B.J. Herbison from comment #40)

New problem reports need to be in new bug. Please recheck your steps to reproduce and click the "NewBug" link at the top of the page.

What about mine? Is that considered a case of this bug or a separate one?

I can reproduce the case described in comment 37, with the clarification that the "regular tab" is the last tab in the non-private window when it is closed and it reappears.

While technically Firefox isn't exited by closing the regular tab it does seem like it could be a case of this bug. Should this bug be reopened or a new report created?

Flags: needinfo?(pyjacpp)

Thank you for your report fabianroeling. I'm able to reproduce it

(In reply to B.J. Herbison from comment #42)

Should this bug be reopened or a new report created?

I don't know, I'm not an employee of Mozilla and I'm not too much experienced with bugzilla.
To me, in one hand, it could be reopened because it partially fixes the issue, but on the other hand, the bug only applies to private windows so in my opinion, we could create a new bug (please note that I'm not very experienced with these sorts of things).
I will try to get more information about what we should do.

In any case, if we decide to create a new bug about this new issue, could someone needinfo me or contact me so I could try to make a patch please?

Flags: needinfo?(pyjacpp)
See Also: → 1732366

After discussing with Gijs, he said that I should fill a new bug, so I created bug 1732366 to track this issue.

(In reply to Antonin LOUBIERE from comment #44)

After discussing with Gijs, he said that I should fill a new bug, so I created bug 1732366 to track this issue.

Thanks Antonin! Yes, I think this is the right call. I've copied Fabian in on that issue.

(In reply to Bryan from comment #38)

Hey, I'm glad this was fixed. :)

Unfortunately I am now experiencing a bug that seems related.

How to reproduce:
<snip>

Bryan, if you're still seeing this, as noted in comment #40 it would be useful to file a separate bug with some more details (also e.g. whether you're using a distro build or an official build, and given that other people couldn't reproduce, perhaps a screencast could help with working out what we're doing differently?).

Hi Bryan, I think your observation in comment 38 has been filed in bug 1730021, which was reported by a Windows user. In my opinion, it deserves a higher priority due to unpredictable/invisible data loss.

For now, if you end a session by closing the last tab (Ctrl+w), and have Firefox set to restore your session, I suggest treating the initial window as fundamentally broken. Immediately create a new window for your new session and forget about that initial one.

Regressions: 1730021

Last tab is still restored if it was closed by window.close().

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.

(In reply to gwarser from comment #47)

Last tab is still restored if it was closed by window.close().

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.

Hey,

That sounds like it's working as intended if tabs are set to be restored. Closing a window with one tab is different than closing the last tab on a window, if you get what I mean. Should the scriptlet be closing the tab instead?

(In reply to gwarser from comment #47)

Last tab is still restored if it was closed by window.close().

Please file a new bug instead of commenting here.

Blocks: 343876
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: