Closed Bug 408268 Opened 17 years ago Closed 16 years ago

Closing the browser without dismissing the Customize Toolbar dialog leads to loss of all toolbar items

Categories

(Firefox :: Address Bar, defect, P2)

x86
Windows Vista
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: ehsan.akhgari, Assigned: sicking)

References

Details

(Keywords: regression)

Attachments

(2 files, 2 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9b1) Gecko/2007110904 Firefox/3.0b1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9b1) Gecko/2007110904 Firefox/3.0b1

This is major.  Accidentally closing the browser during customization of the toolbar could lead to loss of everything on the toolbars, including any previous customizations.  (That's how I found this bug...)

Reproducible: Always

Steps to Reproduce:
1. Open a single browser window.
2. Right-click on the toolbar, and click Customize.
3. In the customization dialog, make a change (I removed the home button, but the actual change is not important.  This happens with any sort of change here).
4. Without dismissing the Customize Toolbar dialog, close the main browser window (which should be the only browser window).  Firefox exits.
5. Restart the browser.  Note that all toolbars are emptied, except from the menu bar.  This includes the throbber, location bar, search bar, toolbar buttons, and bookmarks toolbar items, if visible.
6. Invoke the Customize Toolbar again.  The removed items are there: start adding them again to make your browser more useful.
Actual Results:  
*All* toolbar items are removed.

Expected Results:  
The closing of browser window should be dealt with gratefully, and the changes made in step 3 should get saved, which is the same as the behavior of the case where the Customize Toolbar dialog is closed without clicking Done.

about:buildconfig

Build platform
target
i686-pc-mingw32

Build tools
Compiler 	Version 	Compiler flags
cl 	14.00.50727 	-TC -nologo -W3 -Gy -Fd$(PDBFILE)
cl 	14.00.50727 	-GR- -TP -nologo -Zc:wchar_t- -W3 -Gy -Fd$(PDBFILE)

Configure arguments
--enable-application=browser --enable-update-channel=nightly --enable-optimize --disable-debug --disable-tests --enable-update-packaging
This is a regression from Firefox 2, which handles this gently by discarding the customizations made to the toolbars.
Flags: in-litmus?
Flags: blocking-firefox3?
Keywords: regression
Please add dependencies when suspecting a regression. That makes it less likely to get lost.
Blocks: 348156
BTW, it was tested on Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9b3pre) Gecko/2007121305 Minefield/3.0b3pre, which I mis-entered into the URL field when reporting.
Assignee: nobody → jonas
Flags: blocking-firefox3? → blocking-firefox3+
Jonas, what's the status here?  Are you working on this regression?  Is there something specific the front end needs to do to deal with your changes?
Whiteboard: [needs status update]
Most likely the fix here is purely frontend. I'm walking through the frontend code right now with venkman to see where things fail.

I did run in to an unrelated crash while trying to reproduce. I'll attach a patch for that one in case someone wants to help me out with the frontend code.
Attached patch Fix crash (obsolete) — Splinter Review
This is an unrelated problem, but it fixes a crash that prevents reproducing the bug (at least in debug builds).
Attached patch Fix frontend code (obsolete) — Splinter Review
So here's what happens:

1. The user closes the window
2. We tear down all the XBL bindings as part of the teardown code
   (this has always happened)
3. The customize-toolbar window is closed
4. The customize-toolbar code tries to read the data on the customized toolbars
   to persist them. However, since the XBL bindings are gone the data read is
   gone and we just get undefined values and/or empty strings
5. The customize-toolbar code tries to persist these bogus values.

It is in step 5 where things start behaving differently with the nsDocument::Destroy patch. It used to be that after we had closed a window (and called nsDocument::Destroy) you couldn't persist anything. So the fact that we tried to persist the bogus values was ok since persisting didn't work anyway.

After the nsDocument::Destroy fix persisting works fine and so we end up persisting the bogus values resulting in empty toolbars.

I can fix this 2 ways.
A) Make persist not work after a window has been closed
B) Make the customize-toolbar code not attempt to persist after a window has been closed since it can't get to the correct values to persist anyway.

Fix A would probably get us mostly back to how things were before nsDocument::Destroy was fixed. However it would also needlessly cripple the platform. This bug seems to be the only one filed on nsDocument::Destroy breaking things, so maybe this is the only instance of where this badness happens.

The attached patch does B.

I'd be grateful for input from the toolkit/frontend folks about if A or B is what we want to do.
Attachment #312352 - Flags: superreview?(enndeakin)
Attachment #312352 - Flags: review?(enndeakin)
Attachment #312107 - Flags: superreview?(jst)
Attachment #312107 - Flags: review?(jst)
> Fix A would probably get us mostly back to how things were before
> nsDocument::Destroy was fixed. However it would also needlessly cripple the
> platform.

In what way? Are they cases where we want persist() to work on a document in a closed window?

The patch looks ok though for this bug.
Attachment #312107 - Flags: superreview?(jst)
Attachment #312107 - Flags: superreview+
Attachment #312107 - Flags: review?(jst)
Attachment #312107 - Flags: review+
I agree that we should do B), I think that patch looks fine. I don't really have any opinion about A).
(In reply to comment #9)
> Are they cases where we want persist() to work on a document in a
> closed window?

I'd imagine so. For example it would be quite possible to make dismissing the browser window while customizing actually save the current toolbars (this patch effectively cancels the customization), if we weren't relying on XBL bindings being there. However that does require persist to work.
Whiteboard: [needs status update] → [has patch][needs review enn]
Attachment #312352 - Flags: superreview?(neil)
Attachment #312352 - Flags: superreview?(enndeakin)
Attachment #312352 - Flags: review?(enndeakin)
Attachment #312352 - Flags: review+
Comment on attachment 312352 [details] [diff] [review]
Fix frontend code

>+  if (!gToolboxChanged || gToolboxDocument.window.closed)
Don't you mean defaultView?
Not sure, when is one or the other preferable? .defaultView I guess has an official spec, but .window should work as well in reality, no?
(In reply to comment #13)
> Not sure, when is one or the other preferable? .defaultView I guess has an
> official spec, but .window should work as well in reality, no?
> 

Should have caught that. Documents don't have a window property, so defaultView would be preferred.
Sorry guys, not sure where I got the document.window idea from.
Attachment #312352 - Attachment is obsolete: true
Attachment #313239 - Flags: superreview?(neil)
Attachment #313239 - Flags: review?(enndeakin)
Attachment #312352 - Flags: superreview?(neil)
Attachment #313239 - Flags: superreview?(neil) → superreview+
Attachment #313239 - Flags: review?(enndeakin) → review+
Comment on attachment 312107 [details] [diff] [review]
Fix crash

Neil, you seemed to have some opinions here.

Note that we currently crash on a debug build if you close the window while customizing the toolbar without this change.
Attachment #312107 - Flags: review?(enndeakin)
(In reply to comment #16)
> (From update of attachment 312107 [details] [diff] [review])
> Neil, you seemed to have some opinions here.
> 
> Note that we currently crash on a debug build if you close the window while
> customizing the toolbar without this change.
> 

Yes, the patch looks ok, except that the condition block around the observer removal should include a check for aIsFinal == PR_TRUE
Attached patch Fix crash v2Splinter Review
Attachment #312107 - Attachment is obsolete: true
Attachment #313729 - Flags: superreview?(enndeakin)
Attachment #313729 - Flags: review?(enndeakin)
Attachment #312107 - Flags: review?(enndeakin)
Neil, I assumed you wanted a new patch? It wasn't really clear from your comment.
Attachment #313729 - Flags: review?(enndeakin) → review+
Comment on attachment 313729 [details] [diff] [review]
Fix crash v2

Neal, did you mean to sr this patch too?
(In reply to comment #20)
> (From update of attachment 313729 [details] [diff] [review])
> Neal, did you mean to sr this patch too?

I'm not a superreviewer. Maybe you meant the other Neil?
Attachment #313729 - Flags: superreview?(enndeakin) → superreview?(jst)
Whiteboard: [has patch][needs review enn] → [has patch][needs sr jst]
Attachment #313729 - Flags: superreview?(jst) → superreview+
All patches are checked in. Thanks for reviews!
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Blocks: 428329
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9pre) Gecko/2008050718 Minefield/3.0pre

Verified.
Status: RESOLVED → VERIFIED
Whiteboard: [has patch][needs sr jst]
https://litmus.mozilla.org/show_test.cgi?id=5396 added to Litmus FFT.
Flags: in-litmus? → in-litmus+
Flags: in-testsuite?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: