Closed Bug 868486 Opened 7 years ago Closed 6 years ago

Session restore logic appears broken in Browser preference pane

Categories

(SeaMonkey :: Preferences, defect)

defect
Not set

Tracking

(seamonkey2.21 fixed, seamonkey2.22 fixed, seamonkey2.23 fixed)

RESOLVED FIXED
seamonkey2.23
Tracking Status
seamonkey2.21 --- fixed
seamonkey2.22 --- fixed
seamonkey2.23 --- fixed

People

(Reporter: rsx11m.pub, Assigned: neil)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

There is a "When restoring sessions and windows" groupbox in the Edit > Preferences > Browser main tab. The dial in the "Restore [__] tab(s) at a time" box is apparently tied too directly into the respective preference.

Observed behavior:

Default:
  ( ) Restore immediately
  (*) Restore [ 3] tab(s)
  ( ) Restore when needed

Now, if you change to a different option, you see this:
  ( ) Restore immediately
  ( ) Restore [ 0] tab(s)
  (*) Restore when needed

or even this:
  (*) Restore immediately
  ( ) Restore [-1] tab(s)
  ( ) Restore when needed

and you need to click twice on the center option to get back to the "n tab(s)" selection. On the other hand, the dial allows you to go to "0" or "-1" as well, thus implicitly selecting the other options without even touching the radiobuttons.

This feature was introduced with bug 731140 and amended per bug 737260.
That's weird, bug 731140 is still open while parts of it are already available in the regular releases (behavior seen on 2.17.1 as well). Thus, I'm blocking that bug as well in case you want to keep this a separate issue. Otherwise, we can close this "Fixed as part of..." if and when it has been taken care of in the main bug.
Blocks: 731140
Because it's not clear what a setting of -1 or 0 means, I added the radiogroup to show what was going on. However a side-effect of that is that the radiogroup has to update the pref to -1 or 0 to take effect, thus setting the textbox. (Although, now that I think about it, it might be possible to avoid that by creative use of onsyncfrompreference.)
I switched from explicitly testing against 0 and -1 to a simple > 0 comparison as I thought it looked clearer, however it breaks people setting the pref to -2 (but then, setting the pref to 2147483647 probably breaks anyway).

Updating the radiogroup from the pref works the same as before, values of 0 and -1 select the appropriate radiobutton while positive values are mapped to 3 which is an arbitrary value for the other radiobutton (arbitrary in the sense that the only reason I chose 3 is that it's the default value of the pref).

Updating the textbox from the pref cheats - the textbox does *not* update if the value is 0 or -1, by way of a hack that reads the current value as the value to write. The default value of the textbox is also set to 3, again because this is the default value of the pref, so that if the pref is currently 0 or -1 then it is conveniently simple to set it back to 3.

Changing the textbox sets the preference which automatically updates the radiogroup. It's therefore possible that I didn't need to change the code that updates the preference from the textbox, but that's not necessary for your feedback. (Note that clicking the textbox to change it focuses the radiogroup. That is probably a radiogroup bug.)

Changing the selected radiobutton also sets the preference, but nothing changes because the textbox doesn't update to 0 or -1 and if you select the third radiobutton then the textbox is already the correct value.
Assignee: nobody → neil
Status: NEW → ASSIGNED
Attachment #746068 - Flags: feedback?(rsx11m.pub)
Comment on attachment 746068 [details] [diff] [review]
Creative use of onsyncfrompreference

Yes, this works better than before, but I'm seeing the following error in the Error Console whenever I change a radiobutton of that group:

> Error: document.getElementById(...) is null
> Source File: chrome://communicator/content/pref/pref-navigator.js
> Line: 270

You are looking for maxConcurrentTabsGroup there which seems nowhere defined.

In one instance I saw also those, but couldn't reproduce later:

> Error: document.getElementById(...).ReadConcurrentTabsRadio is not a function
> Source File: chrome://global/content/bindings/preferences.xml
> Line: 402

> Error: document.getElementById(...).ReadConcurrentTabsTextbox is not a function
> Source File: chrome://global/content/bindings/preferences.xml
> Line: 402

The textbox remains enabled even if I chose one of the other options, but it does no longer show "0" or "-1" values (and I can't select them manually). Thus, it's definitely going in the right direction.
Attachment #746068 - Flags: feedback?(rsx11m.pub)
Attached patch Working patchSplinter Review
So, it turns out that the second time you open the Preferences window, onsyncfrompreference attributes in the default pane (depending on which window opened the Preferences window) cannot access any of the scripts for that pane. Everything works fine if you open another pane first and then switch.

As there's no easy fix for that, I've had to embed the code in the attribute, which does unfortunately make for a rather unwieldy line...
Attachment #746068 - Attachment is obsolete: true
Attachment #774215 - Flags: feedback?(rsx11m.pub)
Comment on attachment 774215 [details] [diff] [review]
Working patch

(In reply to neil@parkwaycc.co.uk from comment #5)
> onsyncfrompreference attributes in the default pane (...)
> cannot access any of the scripts for that pane.

This reminds me of bug 835134 comment #25 where Firefox held the functions in a global variable to be able to access them to be able to use those, assuming that's the same scoping issue you are running into here.

Anyway, works fine for me now on both Linux and Windows platforms.

>+          <textbox id="maxConcurrentTabs" type="number" size="2"
>+                   min="1" value="3"

I'd define max="999" for that textbox. While 4 digits barely fit on Windows, I don't think there is much of a practical use case to keep 1000+ tabs open at a time.
Attachment #774215 - Flags: feedback?(rsx11m.pub) → feedback+
(In reply to rsx11m from comment #6)
> (In reply to comment #5)
> > onsyncfrompreference attributes in the default pane (...)
> > cannot access any of the scripts for that pane.
> 
> This reminds me of bug 835134 comment #25 where Firefox held the functions
> in a global variable to be able to access them to be able to use those,
> assuming that's the same scoping issue you are running into here.

No, it's slightly different, in that the functions get called before they have been loaded, because of a race condition in the order that elements get constructed.
Comment on attachment 774215 [details] [diff] [review]
Working patch

Looks like I forgot to request review for this. Oops.
Attachment #774215 - Flags: review?(iann_bugzilla)
Attachment #774215 - Flags: review?(iann_bugzilla) → review+
Comment on attachment 774215 [details] [diff] [review]
Working patch

[Approval Request Comment]
Regression caused by (bug #): 731140/737260
User impact if declined: User confusion
Testing completed (on m-c, etc.): Landed on c-c
Risk to taking this patch (and alternatives if risky): Low
String changes made by this patch: None
Attachment #774215 - Flags: approval-comm-beta?
Attachment #774215 - Flags: approval-comm-aurora?
Attachment #774215 - Flags: approval-comm-aurora? → approval-comm-aurora+
Blocks: 903865
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → seamonkey2.23
Attachment #774215 - Flags: approval-comm-beta? → approval-comm-beta+
You need to log in before you can comment on or make changes to this bug.