Closed Bug 610339 Opened 14 years ago Closed 12 years ago

Close last one-blank-tab-only window with "X" button will lose the session

Categories

(Firefox :: Session Restore, defect)

x86
All
defect
Not set
critical

Tracking

()

VERIFIED WORKSFORME

People

(Reporter: tabutils+bugzilla, Unassigned)

References

Details

(Keywords: dataloss, Whiteboard: [testday-20120831])

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 (.NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 (.NET CLR 3.5.30729)

This is very old a bug, but I cannot find a bug no.

Reproducible: Always

Steps to Reproduce:
1. Set browser.tabs.closeWindowWithLastTab = false.
2. Open 3 tabs and close them one by one until you have one blank tab only.
3. Close the window with "X" button.
4. Start Firefox from the desktop.

Actual Results:  
The last session is lost. No more tabs restorable in History > Recently Closed Tabs. 
If you have other recently closed windows, the 2nd last one may be restored.

Expected Results:  
The last closed window with one blank tab only should be restored.
Severity: normal → major
Close the window with "File > Exit" is OK.
Severity: major → critical
OS: Windows XP → All
Hardware: x86 → All
After some digging, I have learned more about the app quit sequence.

Via "File > Exit", it calls goQuitApplication directly, and nsSessionRestore receives the following notifications (in the receiving order, correct me if some error):
quit-application-requested
quit-application-granted
browser-lastwindow-close-granted
domwindowclosed
quit-application

Via "X" button, it calls WindowIsClosing, closeWindow, and nsSessionRestore receives the following notifications (correct me if some error):
quit-application-requested
browser-lastwindow-close-granted
domwindowclosed
quit-application-granted
quit-application

nsSessionRestore sets _loadSate to STATE_QUITTING when receiving "quit-application-granted". Maybe we can do the same thing when receiving "browser-lastwindow-close-granted"?
Otherwise, we may check whether the closed window is the last browser window when receiving "domwindowclosed", and save it even if it has only one blank tab (but has closed tabs).
I notice that, "quit-application-granted" does not always appear after "domwindowclosed". Sometimes it comes earlier, so the session is saved properly. Firefox needs to keep a more consistent behavior.
> Actual Results:  
> The last session is lost. No more tabs restorable in History > Recently Closed
> Tabs. 

What did you set to be displayed at startup? 

Your last session will be restored if you choose "Show my windows and tabs from last time" in Options->General.
(In reply to comment #5)
> What did you set to be displayed at startup? 
> 
> Your last session will be restored if you choose "Show my windows and tabs from
> last time" in Options->General.

Yes, it's "Show my windows and tabs from last time" indeed. The last session is lost. This problem is still reproduciable on Firefox 4.0 final.
Version: unspecified → Trunk
OS: All → Windows XP
Hardware: All → x86
Keywords: dataloss
Attached patch patchSplinter Review
Attachment #536855 - Flags: review?(paul)
(In reply to comment #7)
> Created attachment 536855 [details] [diff] [review] [review]
> patch

I will look at this tomorrow when I have a Linux/Windows machine available (OSX is special cased too much for window closing behavior to be sure).
Comment on attachment 536855 [details] [diff] [review]
patch

Review of attachment 536855 [details] [diff] [review]:
-----------------------------------------------------------------

Doesn't fix the problem for me on Linux. I'm also not sure I'd agree that this should be fixed. In fact I might argue that if you quit Firefox with no tabs open, we should just start a new session.
Attachment #536855 - Flags: review?(paul) → review-
How do you think of "File > Exit" and "X" have different behaviors then? Is it intended?
> In fact I might argue that if you quit Firefox with no tabs open, we should just start a new session.

I'm not sure I completely agree with that. What about Recently Closed Tabs/Windows? or does that not count as part of a session?
OS: Windows XP → All
This seems to be fixed in the 18 branch at least.

Tried to reproduce: 
Set browser.tabs.closeWindowWithLastTab to false
Set Show Windows and Tabs from last time on start
Open three tabs
Close them all so one new tab is the only thing up
Close Firefox
Restart Firefox

Results: Firefox starts with a new tab up, can find the closed tabs under History > Recently Closed Tabs

I think this might have been fixed when "restore previous session" was introduced.

Suggestion: Close as Fixed
Closing then. Thanks, David.
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → WORKSFORME
Whiteboard: [testday-20120831]
Last good nightly: 2012-02-02
First bad nightly: 2012-02-03

Pushlog:
http://hg.mozilla.org/mozilla-central/pushloghtml?startdate=2012-02-02&enddate=2
012-02-03

It's not clear which bug fixed it.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: