Menu race condition when setting Hidden attribute




14 years ago
11 years ago


(Reporter: mozilla, Unassigned)



Firefox Tracking Flags

(Not tracked)



(1 attachment)

1017 bytes, application/vnd.mozilla.xul+xml


14 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913

XUL menus stop working (probably due to a race condition) if you set their
"hidden" attribute via a menuitem.  See the complete source example below, then
read "Steps To Reproduce."

<?xml version="1.0"?>
<?xml-stylesheet href="esp.css" type="text/css"?>

<script type="application/x-JavaScript">
function ShowMenuOne() {"UniversalXPConnect");
    document.getElementById("Two").setAttribute('hidden', 'true');

function ShowMenuTwo() {"UniversalXPConnect");
    document.getElementById("One").setAttribute('hidden', 'true');

<menubar id="One">
 <menu label="FileOne">
   <menuitem label="ItemOne" oncommand='ShowMenuTwo();'/>

<menubar id="Two">
 <menu label="FileTwo">
   <menuitem label="ItemTwo" oncommand="ShowMenuOne();"/>


Reproducible: Always
Steps to Reproduce:
1. Load the included XUL example into Mozilla. You will see a single XUL menu
named "FileOne".
2. In the "FileOne" menu, select the menu item "ItemOne." You will see FileOne
disappear and be replaced by FileTwo.
3. In the FileTwo menu, select the menu item "Item Two." The original menu
"FileOne" will reappear.
4. Try to select the FileOne menu. You can't. No dropdown menu appears. It seems
to think it's already selected: notice how its enclosing box looks concave
instead of convex.

Actual Results:  
The menu "FileOne" cannot be selected.

Expected Results:  
Menu "FileOne" should operate normally.

Comment 1

14 years ago
If you call a simple time-wasting function (such as alert("foo")) before each
setAttribute('hidden', 'true'), the problem goes away. That's why I think it's a
race condition.
presumably the menu believes it's still open... 
Yes, what happens is that the menu frame hides the menu, fires the command event
and then closes the menu. Unfortunately it can't do that if you destroy the
frame (by setting the hidden attribute) first.
So is it documented anywhere how menus _should_ work?  I can't figure out half
the insanity they do (setting attributes from layout, firing events from layout,
This is an automated message, with ID "auto-resolve01".

This bug has had no comments for a long time. Statistically, we have found that
bug reports that have not been confirmed by a second user after three months are
highly unlikely to be the source of a fix to the code.

While your input is very important to us, our resources are limited and so we
are asking for your help in focussing our efforts. If you can still reproduce
this problem in the latest version of the product (see below for how to obtain a
copy) or, for feature requests, if it's not present in the latest version and
you still believe we should implement it, please visit the URL of this bug
(given at the top of this mail) and add a comment to that effect, giving more
reproduction information if you have it.

If it is not a problem any longer, you need take no action. If this bug is not
changed in any way in the next two weeks, it will be automatically resolved.
Thank you for your help in this matter.

The latest beta releases can be obtained from:

Comment 6

14 years ago
Behavior is even worse in Firefox (1.0.6) on Linux.  Initially BOTH menus appear
(i.e., the hidden attribute is ignored). Selecting the two menus makes both of
them disappear (i.e., deletion of the hidden attribute doesn't work).

Comment 7

14 years ago
I just checked Mozilla 1.7.8 for Linux, and the bug is still present there too.
Comment 5 explicitly requested that you use a current build, and gave links...
both builds you tested use a layout engine from April 2004.

In a current build, the steps in comment 0 work fine for me, though I do see
both menus at first load for some reason.

Comment 9

14 years ago
Thanks. I have tested the bug with firefox 1.5 beta 1, and the "hidden"
misbehavior is fixed.

However, like you, I see two menus initially, which would indicate another bug I
Basically this is one of the bugs like 212625 that were fixed by bug 282359.

The initial menus bug is caused by the missing css confusing the load group?
OK, I'm going to mark this worksforme.  I've filed bug 310319 on the fact that
onload doesn't fire for this testcase when loaded from file://
Last Resolved: 14 years ago
Resolution: --- → WORKSFORME


11 years ago
Component: XP Toolkit/Widgets: Menus → XUL
QA Contact: xptoolkit.widgets
You need to log in before you can comment on or make changes to this bug.