Closed Bug 320295 Opened 19 years ago Closed 14 years ago

popupshowing gets called twice in some situations

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: mossop, Unassigned)

Details

(Keywords: testcase)

Attachments

(1 file)

The popupshowing event for a context menu can be called twice in succession for a single popup in certain circumstances. The popuphiding event is only called once correctly.

The trigger for this appears related to how the context menu is added to the XUL element. I observed this first on Firefox's content area context menu where it happens on all but the first tab. The difference here is that the first tab has its contextmenu attribute inherited through the XBL binding, while the others have the contextmenu attribute set through javascript.

The upcoming testcase demonstrates this issue though for reasons that escape me right now it shows the situation reversed to that of the tabbrowser.
This testcase shows the problem. There are two boxes, red and blue. The blue has its context menu set by attributes. The red has it set by javascript.

The popupshowing event for the popup adds a single menu item to the menu.
The popuphiding event for the popup empties the menu.

Right clicking the red box shows correctly that one menu item, so popupshowing was only called once.
Right clicking the blue box shows two menu items so popupshowing was called twice.

This has been tested on current trunk and Firefox 1.5 on Windows and Linux.
Forgot to add that the popupshown event appears to suffer the same problem.
Blocks: 319315
As best I can tell this is being caused by popup listeners not being removed from XUL elements. Certainly removing then re-adding the contextmenu attribute in the example causes the menu size to increase by one for each time you remove the attribute.

There is a somewhat telling line in the source: http://lxr.mozilla.org/mozilla/source/content/xul/content/src/nsXULElement.cpp#1425
Keywords: testcase
Assignee: nobody → events
Component: XP Toolkit/Widgets: XUL → Event Handling
QA Contact: xptoolkit.xul → ian
[Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.9a1) Gecko/20060204 SeaMonkey/1.5a] (nightly) (W98SE)

The testcase is WorksForMe.
(This is, at least, a reminder for myself: for bug 302050 comment 69)
Just confirming that. This appears to be working in the latest Seamonkey build, but still not working in the latest Firefox build.
No longer blocks: 319315
Assignee: events → nobody
QA Contact: ian → events
Seems to work ok for me. Certainly fixed by popup work long ago.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → WORKSFORME
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: