Closed Bug 694378 Opened 13 years ago Closed 13 years ago

session restore fails when selectedWindow > number of windows

Categories

(Firefox :: Session Restore, defect)

defect
Not set
major

Tracking

()

RESOLVED FIXED
Firefox 10

People

(Reporter: wsmwk, Assigned: zpao)

References

Details

(Keywords: regression)

Attachments

(1 file, 1 obsolete file)

+++ This bug was initially created as a clone of Bug #567646 +++

I'm seeing this again - precisely the same steps and symptoms. I had deselected all tabs and windows in the restore list except tab 1 (which was a previous/nested session list)

Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:10.0a1) Gecko/20111006 Firefox/10.0a1

1. killed firefox 
2. started firefox 
3. unselected several windows and tabs from restore:session window
4. clicked Restore
results: restore button dims, and tabs were not restored

5. select all the tabs in "windows 1" 
results: restore works

error console contains ....

Error: uncaught exception: [Exception... "'[JavaScript Error: "winData is undefined" {file: "resource:///components/nsSessionStore.js" line: 2579}]' when calling method: [nsISessionStore::setWindowState]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: chrome://browser/content/aboutSessionRestore.js :: restoreSession :: line 140"  data: yes]
Hardware: x86 → x86_64
This is a regression from bug 669272. This happens when selectedWindow is > windows.length. we then unshift undefined to the front of the windows array and puts us in this case.
Keywords: testcaseregression
OS: Windows 7 → All
Hardware: x86_64 → All
Blocks: 669272
Attached patch Patch v0.1 (obsolete) — Splinter Review
I should probably write a test for this, but this does fix it. Trust me, I'm a doctor (or something)
Assignee: nobody → paul
Attachment #566917 - Flags: review?(dietrich)
Attached patch Patch v0.2Splinter Review
Now with a test.
Attachment #566917 - Attachment is obsolete: true
Attachment #566917 - Flags: review?(dietrich)
Attachment #567631 - Flags: review?(dietrich)
Comment on attachment 567631 [details] [diff] [review]
Patch v0.2

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

r=me

::: browser/components/sessionstore/src/nsSessionStore.js
@@ +2564,5 @@
>      if (root._closedWindows)
>        this._closedWindows = root._closedWindows;
>  
>      var winData;
> +    if (!root.selectedWindow || root.selectedWindow > root.windows.length) {

would dig seeing selectedWindow renamed to selectedWindowIndex or something more self-descriptive like that. but that's a nice-to-have.
Attachment #567631 - Flags: review?(dietrich) → review+
(In reply to Dietrich Ayala (:dietrich) from comment #4)
> would dig seeing selectedWindow renamed to selectedWindowIndex or something
> more self-descriptive like that. but that's a nice-to-have.

I'm going to keep it for now. I've resisted the strong urge to change any of the existing keys for a while. There are other changes to the format I want to make (for example, not have the indexes be 1-based). I think it might make sense to just do all the changes at once (though that's going to be fun for Sync)
Summary: sessions not restored if some tabs deselected in sessionrestore list → session restore fails when selectedWindow > number of windows
https://hg.mozilla.org/mozilla-central/rev/5d7c2550a61e
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 10
Blocks: 698267
You need to log in before you can comment on or make changes to this bug.