Tabs are always restored at startup after closing in Private Browsing mode

VERIFIED FIXED in Firefox 8

Status

()

Firefox
Session Restore
VERIFIED FIXED
6 years ago
6 years ago

People

(Reporter: severinbreuer, Assigned: int3)

Tracking

Trunk
Firefox 8
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [testday-20110930])

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

6 years ago
User-Agent:       Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Build Identifier: Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1

If you exit FF in Private Browsing mode, restarting has the same effect as exiting Private Browsing from the menu: pre-Private Browsing tabs are restored. This occurs even if a user has selected "Show a blank page" or "Show my home page" (as opposed to "Show my windows and tabs from last time") as the option for "When Firefox starts". 

Restoring tabs when exiting Private Browsing is sensible, but start-up behavior should be the same whether Firefox was closed in regular or Private Browsing mode. If a user has "Show my windows and tabs from last time" enabled, Firefox should (and does) restore the pre-Private session when Firefox is restarted. But if the user has enabled "Show my home page", the home page should be shown, not the tabs from the previous non-private session. Users can always restore tabs with "Restore Previous Session" in the History menu if they need to. But if a user closes the browser (rather than exiting Private Browsing via the menu), then Firefox should close both the private session and the suspended non-private session unless a user has selected to have sessions restored at each startup.

Reproducible: Always

Steps to Reproduce:
1) Start Firefox. Set start-up option to "Show my home page" and set a home page.
2) Switch to Private Browsing.
3) Close Firefox.
4) Start Firefox.

Actual Results:  
Firefox restores the tabs that were open before switching to Private Browsing.

Expected Results:  
Firefox should display the home page.
This behavior is by design, because otherwise those tabs would be lost forever.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → INVALID
(Reporter)

Comment 2

6 years ago
Where do you get the idea that they'd be lost forever? They're listed plain as day in the History menu. And if the suspended non-private session was simply closed as expected when Firefox was closed, the Restore Previous Session menu option in that same menu should restore them just fine.
Alex, comment 2 doesn't seem like a bad idea to me.  How would you feel about us treating these types of sessions as any other session, and show a Restore Previous Session button in about:home in the cases that we do now for regular sessions?

zpao: I actually don't know how the sessionstore code triggers this new way of restoring sessions.  How hard would it be for us to get this to work for private browsing mode too?
(In reply to comment #3)
> zpao: I actually don't know how the sessionstore code triggers this new way
> of restoring sessions.  How hard would it be for us to get this to work for
> private browsing mode too?

Should be easy (famous last words). I think we just need to stop setting browser.sessionstore.resume_session_once here: https://mxr.mozilla.org/mozilla-central/source/browser/components/sessionstore/src/nsSessionStore.js#635
(In reply to comment #4)
> (In reply to comment #3)
> > zpao: I actually don't know how the sessionstore code triggers this new way
> > of restoring sessions.  How hard would it be for us to get this to work for
> > private browsing mode too?
> 
> Should be easy (famous last words). I think we just need to stop setting
> browser.sessionstore.resume_session_once here:
> https://mxr.mozilla.org/mozilla-central/source/browser/components/sessionstore/src/nsSessionStore.js#635

FWIW, I had already tried that, but it doesn't seem to work.
We didn't want starting private browsing mode to be as destructive as closing the entire application.  Ideally we should have private windows running simultaneously, but until we get there I want us to keep this behavior in place so users can enter and leave private browsing with the least amount of extra overhead actions.

While your session is available in history, the assumption is that you want it back (just as when we crash the assumption is that you want it back, and we in that case also restore it automatically).
(In reply to comment #6)
> We didn't want starting private browsing mode to be as destructive as closing
> the entire application.  Ideally we should have private windows running
> simultaneously, but until we get there I want us to keep this behavior in place
> so users can enter and leave private browsing with the least amount of extra
> overhead actions.

This is not about whether or not to automatically get the original session back when you leave the private browsing mode.  It's about whether that should happen after a restart if you had closed Firefox without leaving the private browsing mode.
Oh, yeah then we should just follow normal startup behavior (whatever the user set that as).
OK, reopening then!  zpao, I'd assign this to you, except that I don't want to overload you if you don't have time!  But you may be the best person to fix this :-)
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: INVALID → ---
I'm going to have Jezreel start looking at this.
Assignee: nobody → jezreel
(Assignee)

Comment 11

6 years ago
Created attachment 539320 [details] [diff] [review]
Patch v1

I tried the fix in comment #4 and it seems to work fine.
(In reply to comment #11)
> Created attachment 539320 [details] [diff] [review] [review]
> Patch v1
> 
> I tried the fix in comment #4 and it seems to work fine.

Hmm, can you please describe your STRs?
(Assignee)

Comment 13

6 years ago
Steps to reproduce:

1. Apply patch in comment #11
2. Set pref to 'Show my home page'
3. Open up google.com, facebook.com
4. Enter private browsing mode
5. Quit Nightly
6. Reopen Nightly

Results:
Only the homepage is shown upon reopening.

I've tried the other two pref options in step #2 as well, and they both give the desired result upon reopening.
Hmm, then I don't know what I was doing wrong.  If zpao thinks that this patch is good, I think we should take it.
Comment on attachment 539320 [details] [diff] [review]
Patch v1

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

::: browser/components/sessionstore/src/nsSessionStore.js
@@ +632,5 @@
>  
>              this._saveStateObject(oState);
>            }
> +          // don't restore the non-private session automatically upon resuming (bug 660785)
> +          this._prefBranch.setBoolPref("sessionstore.resume_session_once", false);

Let's just not set the pref at all. If for some reason the user sets it (or an addon or whatever), we should respect that.

You can keep the comment (no need to have the bug number though) or say that we'll respect normal startup-related prefs and restore the session if applicable, otherwise it will be available under restore previous session.
Attachment #539320 - Flags: review-
(Assignee)

Comment 16

6 years ago
Created attachment 549629 [details] [diff] [review]
Patch v2

Updated patch as per the review.
Attachment #539320 - Attachment is obsolete: true
(Assignee)

Updated

6 years ago
Attachment #549629 - Flags: review?(paul)
Attachment #549629 - Flags: review?(paul) → review+
(Assignee)

Updated

6 years ago
Keywords: checkin-needed

Updated

6 years ago
Component: Private Browsing → Session Restore
QA Contact: private.browsing → session.restore
Landed on fx-team: http://hg.mozilla.org/integration/fx-team/rev/e9c579848ab6
Keywords: checkin-needed
Whiteboard: [fixed-in-fx-team]
http://hg.mozilla.org/mozilla-central/rev/e9c579848ab6
Status: REOPENED → RESOLVED
Last Resolved: 6 years ago6 years ago
OS: Windows XP → All
Hardware: x86 → All
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 8
Version: unspecified → Trunk
Mozilla/5.0 (X11; Linux x86_64; rv:10.0a1) Gecko/20110929 Firefox/10.0a1
Mozilla/5.0 (X11; Linux x86_64; rv:9.0a2) Gecko/20110929 Firefox/9.0a2
Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20100101 Firefox/8.0

Verified on Ubuntu 11.04, Windows XP, Windows 7 and Mac OS 10.6. 

The "When Firefox starts" preferences are remembered after the user quits Firefox while in Private browsing mode.
Status: RESOLVED → VERIFIED
Whiteboard: [testday-20110930]

Comment 20

6 years ago
is there any way to get the older "buggy" behaviour? I would like it back since surprisingly I was using it as a feature :)
(In reply to idealas from comment #20)
> is there any way to get the older "buggy" behaviour? I would like it back
> since surprisingly I was using it as a feature :)

You can set Firefox to restore your session automatically and your session should be restored following Firefox quitting from PB mode.

Comment 22

6 years ago
sure thing i can, unfortunately i want it to restore tabs only when i quite ff in private browsing, just like it was before fix with "dont restore tabs" selected.
You need to log in before you can comment on or make changes to this bug.