Closed Bug 312308 Opened 19 years ago Closed 19 years ago

tabbrowser: closing tab throws exception when no "autocompletepopup" attribute is set

Categories

(Toolkit :: UI Widgets, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: gdavis, Unassigned)

Details

(Keywords: fixed1.8)

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7 (ax)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7 (ax)

Using the tabbrowser widget without the "autocompletepopup" attribute set, will
cause an exception to be thrown in the "detachFormFill()" method of the browser
widget when a tab is closed.

When the tabbrowser is opening a tab, it creates a browser widget and copies
some if its attributes along to the browser widget. One attribute that it is
passing blindly is the "autocompletepopup" attribute. When the tabbrowser widget
doesn't have this attribute set, it will call setAttribute on the browser
passing the result of the getAttribute from itself. This will result in an
"autocompletepopup" attribute that exists in the browser widget, but is empty.
The browser widget's "attachFormFill()" method simply checks for the existence
of the attribute, tries to retrieve the element with an empty string for an ID,
fails, does not call nsIFormFillController::attachToBrowser(...), yet still sets
a flag indicating that it did call attachToBrowser.  When the tab is closed, the
browser widget tries to call nsIFormFillController::detachFromBrowser(...) which
throws an exception if attachToBrowser hasn't been called.

Reproducible: Always

Steps to Reproduce:
1. Write a XULRunner application that uses the tabbrowser widget.
2. Open a tab in the widget.
3. Close the tab.

Actual Results:  
Get the following debug messages in the console indicating an exception:

###!!! ASSERTION: getElementById(""), fix caller?: '!aId.IsEmpty()', file
d:/Mozilla/dev/trunk/mozilla/content/xul/document/src/nsXULDocument.cpp, line
1660 WARNING: NS_ENSURE_TRUE(index >= 0) failed, file
d:/Mozilla/dev/trunk/mozilla/toolkit/components/satchel/src/nsFormFillController.cpp,
line 195
*** uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIFormFillController.detachFromBrowser]" 
nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
chrome://global/content/bindings/browser.xml :: detachFormFill :: line 385" 
data: no]

Expected Results:  
No debug messages indicating an exception or failure.
Version: unspecified → Trunk
Attachment #199413 - Flags: first-review?(benjamin)
Comment on attachment 199413 [details] [diff] [review]
Patch for tabbrowser and browser widgets

In browser.xml please check for .hasAttribute("autocompletepopup") the same way
you do in tabbrowser.xml. Our internal code asserts if you try to do
getElementById(null).
Attachment #199413 - Flags: first-review?(benjamin) → first-review-
(In reply to comment #2)
> (From update of attachment 199413 [details] [diff] [review] [edit])
> In browser.xml please check for .hasAttribute("autocompletepopup") the same way
> you do in tabbrowser.xml. Our internal code asserts if you try to do
> getElementById(null).
> 

The attachFormFill method in browser.xml already has the
.hasAttribute("autocompletepopup") check.  The getElementById() will never get
called if the attribute doesn't exist.  Are you referring to another location in
browser.xml?  If so, where?
Comment on attachment 199413 [details] [diff] [review]
Patch for tabbrowser and browser widgets

Oh, I see.

Could you attach a version of this patch where the brace follows the if on the
same line (to match surrounding style).
Attachment #199413 - Flags: first-review- → first-review+
Attachment #199806 - Flags: first-review?(benjamin)
Comment on attachment 199806 [details] [diff] [review]
Patch with curly brackets at end of line

very low-risk patch fixes uses of tabbrowser in xulrunner apps
Attachment #199806 - Flags: first-review?(benjamin)
Attachment #199806 - Flags: first-review+
Attachment #199806 - Flags: approval1.8rc1?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attachment #199413 - Attachment is obsolete: true
Fixed on trunk.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Attachment #199806 - Flags: approval1.8rc1? → approval1.8rc1+
Fixed on 1.8 branch.
Keywords: fixed1.8
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: