Last Comment Bug 694378 - session restore fails when selectedWindow > number of windows
: session restore fails when selectedWindow > number of windows
Status: RESOLVED FIXED
: regression
Product: Firefox
Classification: Client Software
Component: Session Restore (show other bugs)
: Trunk
: All All
: -- major (vote)
: Firefox 10
Assigned To: Paul O'Shannessy [:zpao] (not reading much bugmail, email directly)
:
Mentors:
Depends on:
Blocks: 669272 698267 729281
  Show dependency treegraph
 
Reported: 2011-10-13 11:58 PDT by Wayne Mery (:wsmwk, NI for questions)
Modified: 2012-02-21 13:32 PST (History)
8 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch v0.1 (1.18 KB, patch)
2011-10-13 13:21 PDT, Paul O'Shannessy [:zpao] (not reading much bugmail, email directly)
no flags Details | Diff | Review
Patch v0.2 (2.99 KB, patch)
2011-10-17 17:40 PDT, Paul O'Shannessy [:zpao] (not reading much bugmail, email directly)
dietrich: review+
Details | Diff | Review

Description Wayne Mery (:wsmwk, NI for questions) 2011-10-13 11:58:12 PDT
+++ 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]
Comment 1 Paul O'Shannessy [:zpao] (not reading much bugmail, email directly) 2011-10-13 12:55:54 PDT
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.
Comment 2 Paul O'Shannessy [:zpao] (not reading much bugmail, email directly) 2011-10-13 13:21:46 PDT
Created attachment 566917 [details] [diff] [review]
Patch v0.1

I should probably write a test for this, but this does fix it. Trust me, I'm a doctor (or something)
Comment 3 Paul O'Shannessy [:zpao] (not reading much bugmail, email directly) 2011-10-17 17:40:27 PDT
Created attachment 567631 [details] [diff] [review]
Patch v0.2

Now with a test.
Comment 4 Dietrich Ayala (:dietrich) 2011-10-18 14:36:51 PDT
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.
Comment 5 Paul O'Shannessy [:zpao] (not reading much bugmail, email directly) 2011-10-18 14:43:58 PDT
(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)
Comment 6 Paul O'Shannessy [:zpao] (not reading much bugmail, email directly) 2011-10-25 15:16:14 PDT
pushed to fx-team: https://hg.mozilla.org/integration/fx-team/rev/5d7c2550a61e
Comment 7 :Margaret Leibovic 2011-10-27 11:39:16 PDT
https://hg.mozilla.org/mozilla-central/rev/5d7c2550a61e

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