Menu race condition when setting Hidden attribute

RESOLVED WORKSFORME

Status

()

Core
XUL
RESOLVED WORKSFORME
13 years ago
9 years ago

People

(Reporter: Daniel Barrett, Unassigned)

Tracking

Trunk
x86
All
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

13 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"?>
<window
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    onload="ShowMenuOne();">

<script type="application/x-JavaScript">
function ShowMenuOne() {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    document.getElementById("Two").setAttribute('hidden', 'true');
    document.getElementById("One").removeAttribute('hidden');
}

function ShowMenuTwo() {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    document.getElementById("One").setAttribute('hidden', 'true');
    document.getElementById("Two").removeAttribute('hidden');
}
</script>

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

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

</window>


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.
(Reporter)

Comment 1

13 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... 

Comment 3

13 years ago
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,
etc).
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:
Firefox:     http://www.mozilla.org/projects/firefox/
Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html
Seamonkey:   http://www.mozilla.org/projects/seamonkey/
(Reporter)

Comment 6

12 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).
(Reporter)

Comment 7

12 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.
(Reporter)

Comment 9

12 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
suppose.

Comment 10

12 years ago
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?
Created attachment 197700 [details]
The testcase
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://
Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → WORKSFORME

Updated

9 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.