Closed Bug 503299 Opened 16 years ago Closed 15 years ago

window.close() from a content tab closes Thunderbird window

Categories

(Thunderbird :: Toolbars and Tabs, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 3.0b4

People

(Reporter: jwkbugzilla, Assigned: standard8)

References

Details

Attachments

(1 file, 1 obsolete file)

I am opening a dialog in a Thunderbird tab of type "contentTab". Dialogs call window.close() by default when the accept button is pressed. No issues in Firefox, yet in Thunderbird (Shredder 20090708 build on Windows XP) this closes the entire Thunderbird window. The code preventing this in tabbrowser (and missing in tabmail) seems to be this: <handler event="DOMWindowClose" phase="capturing"> <![CDATA[ if (!event.isTrusted) return; const browsers = this.mPanelContainer.childNodes; if (browsers.length == 1) { // There's only one browser left. If a window is being // closed and the window is *not* the window in the // browser that's still around, prevent the event's default // action to prevent closing a window that's being closed // already. if (this.getBrowserAtIndex(0).contentWindow != event.target) event.preventDefault(); return; } var i = 0; for (; i < browsers.length; ++i) { if (this.getBrowserAtIndex(i).contentWindow == event.target) { this.removeTab(this.mTabContainer.childNodes[i]); event.preventDefault(); break; } } ]]> </handler> At the very least, Thunderbird should prevent propagation of this event. However, it can probably also query its tabs whether they "know" the event target - and close the one that does.
Good point, although I'd debate that a tab is not a dialog - a dialog is a special window to display information or get a response. A content tab is just a tab to display content. However I can port this code across as it sounds like a good idea to have anyway.
Assignee: nobody → bugzilla
Flags: wanted-thunderbird3+
The reason this bug strikes me as important is because it makes it harder for extensions targetted at both Firefox and Thunderbird to Just Work. It doesn't feel quite important enough to block Tb3, however.
Attached patch Possible fix (obsolete) — Splinter Review
I've not tested this yet (apart from running up TB with a tab), but I think this would potentially be enough, though it may need moving to tabmail.xml.
Confirmed, this patch fixes the issue for Adblock Plus.
Attached patch The fixSplinter Review
I reworked the previous fix for this a bit. I've now split out setting up the listeners into separate functions and reordered the openTab function - hopefully this makes things a bit clearer especially when it comes to editing.
Attachment #387848 - Attachment is obsolete: true
Attachment #396202 - Flags: review?(bugmail)
Attachment #396202 - Flags: review?(bugmail) → review+
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 3.0b4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: