Closed Bug 583379 Opened 14 years ago Closed 11 years ago

Can't get dynamic access to menus with an 'allowevents' attribute set to false

Categories

(Testing Graveyard :: Mozmill, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ahal, Assigned: balazs)

References

Details

(Whiteboard: [mozmill-2.0.1][mentor=whimboo][lang=js])

Attachments

(1 file, 2 obsolete files)

We got around the dynamic menu access problem for most menus by sending a fake 'popupshowing' event to the menupopup elements (see Bug 474486).  Unfortunately some menus, such as the 'History' menu, have an 'allowevents' attribute set to false which causes cryptic asserts.

We'll either need a way to send events to these menus without causing asserts, or find a completely different solution to the dynamic menu problem that doesn't involve sending fake events.
See Also: → 474486
Whiteboard: [mozmill-2.0?]
Marco, Dietrich, or Mano, has one of you an idea why that particular faked event does not work for menupopups with allowevents set to false? What alse can we do to let the menu populate with dynamic entries?
I'd take a look at a patch that implements this, but I'd not hold 2.0 for it.  We've gotten by this long...
Whiteboard: [mozmill-2.0?] → [mozmill-2.0-wanted]
Whiteboard: [mozmill-2.0-wanted] → [mozmill-2.0-][mozmill-next?]
This issue blocking bug 474313
Flags: needinfo?(mak77)
In bug 474313 we want to verify if a Bookmark was really created in Bookmarks menu by clicking on it.

The dynamic menu is generated by calling:
  controller.mainMenu.open("#bookmarksMenu");

which would call FakeOpenPopup method:
  https://github.com/mozilla/mozmill/blob/master/mozmill/mozmill/extension/resource/driver/controller.js#L224


This method is based on
  http://hg.mozilla.org/mozilla-central/rev/d70ef56fdca6

Unfortunately, popup.allowevents always return with "false" value, so the fake clicking never called - the dynamic menu is not generated.

Marco: do you have any idea what could be the problem?
off-hand, looks like mozmill is checking allowevents on a menupopup, why does that check exist?
If you read https://developer.mozilla.org/en-US/docs/XUL/Attribute/allowevents you see that in menus the behavior is special, it is usually false but may be set to true on a descendant, and in such a case the event is consumed by the descendant (if I read that correctly). So it seems like a miscomprehension about what the attribute is doing?
Flags: needinfo?(mak77)
It was added from https://bugzilla.mozilla.org/show_bug.cgi?id=474486#c35

Don't ask me to remember what either of these bugs are about though, I only have a vague recollection of them :). I'd say don't be afraid of changing things around.
Sounds good. Balazs, could you try without this if condition? Does it make a difference for you? Do dynamically populated sub menus work then?
I tried removing checking of popup.allowevents

The dynamic menu populated now and the new bookmark is working using:
  controller.mainMenu.open("#bookmarksMenu");
  controller.mainMenu.click("[label='Mozilla']");
That are great news. Would you mind to also do a quick spotcheck for the history menu?
Calling of controller.mainMenu.open("#history-menu"); does not give any error.

Moreover, from my experience it is not matter #bookmarksMenu, #history-menu is given as argument, because the entire menu is re-populated by _buildMenu.

For example, the new bookmark is clickable also if #history-menu is called instead of #bookmarksMenu:
  controller.mainMenu.open("#history-menu");
  controller.mainMenu.click("[label='Mozilla']");
Sorry, but my question wasn't asked well enough. Can you please check if you select a dynamic menuitem from the history menu, i.e. a formerly closed tab. Also for your example above, the open call should not be necessary.
Yes, selecting a dynamic menuitem from history menu also works.

I created a patch for mozmill2/controller.js which:
  - remove checking of allowevents attribute
  - calls menu:_buildmenu automatically when menu:getItem called to get dynamic menu entries

With this modification it is possible to directly click on a dynamic menu entry.
Attachment #819388 - Flags: review?(hskupin)
Comment on attachment 819388 [details] [diff] [review]
Remove allowevents checking. Add dynamic menu generation in menu:getItem.

Review of attachment 819388 [details] [diff] [review]:
-----------------------------------------------------------------

That's great Balazs! I like that we can remove this if condition. Beside the nit I have mentioned inline can you please add a Mutt test, which exercises this path for Firefox?

r=me already for the patch.

::: mozmill/mozmill/extension/resource/driver/controller.js
@@ +147,5 @@
>     * @throws Error If menu element has not been found
>     */
>    getItem: function Menu_getItem(itemSelector) {
> +    // Run through the entire menu and populate with dynamic entries
> +    this._buildMenu(this._menu.getNode());   

nit: please remove the trailing white-spaces.
Attachment #819388 - Flags: review?(hskupin) → review+
Assignee: nobody → juhaszbal
Status: NEW → ASSIGNED
Whiteboard: [mozmill-2.0-][mozmill-next?] → [mozmill-2.0-][mozmill-2.1?][mentor=whimboo][lang=js]
Trailing white-spaces removed.
Attachment #819388 - Attachment is obsolete: true
Attachment #821984 - Flags: review?(hskupin)
For Mutt test I will work on. I think about a test which opens a local page, and then checks if the history-menu contains the new menu entry via mainMenu.getItem('label').
That sounds like the right approach. Please combine the test patch with the existent one.
Attachment #821984 - Flags: review?(hskupin)
Combined previous patch with new Mutt test patch.
Attachment #821984 - Attachment is obsolete: true
Attachment #822493 - Flags: review?(hskupin)
Comment on attachment 822493 [details] [diff] [review]
Remove allowevents checking. Add dynamic menu generation in menu:getItem. Add new Mutt test.

Review of attachment 822493 [details] [diff] [review]:
-----------------------------------------------------------------

Absolutely nothing I have to comment on. That looks great and I will get it landed in a bit. Thanks Balazs!
Attachment #822493 - Flags: review?(hskupin) → review+
Landed on master for Mozmill 2.1:
https://github.com/mozilla/mozmill/compare/4b5218b01c44...e89223e10a8f
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [mozmill-2.0-][mozmill-2.1?][mentor=whimboo][lang=js] → [mozmill-2.0-][mozmill-2.1][mentor=whimboo][lang=js]
Whiteboard: [mozmill-2.0-][mozmill-2.1][mentor=whimboo][lang=js] → [mozmill-2.1][mentor=whimboo][lang=js]
Given that this is actually a bug fix I should have it ported back to our hotfix-2.0 branch. I did that now and the fix will be part of the upcoming Mozmill 2.0.1.

https://github.com/mozilla/mozmill/commit/60be401b877f321e47d0950a6b88a413ad4dfb9c
Blocks: 931828
Whiteboard: [mozmill-2.1][mentor=whimboo][lang=js] → [mozmill-2.0.1][mentor=whimboo][lang=js]
Product: Testing → Testing Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: