Closed Bug 1702633 Opened 4 years ago Closed 4 years ago

Make test_context_click_action pass with native context menus

Categories

(Core :: Widget: Cocoa, task, P3)

All
macOS
task

Tracking

()

RESOLVED FIXED
89 Branch
Tracking Status
firefox89 --- fixed

People

(Reporter: mstange, Assigned: mstange)

References

Details

(Whiteboard: [proton-context-menus][mac:mr1])

Attachments

(1 file)

Bug 1533786 added a test_context_click_action Marionette unit test: https://searchfox.org/mozilla-central/rev/402802eb42ba7d905531fd8e3b089fc8b2292f66/testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py#98

It opens the content area context menu with a synthesized right click, checks that the popup's state is "open", and then synthesizes an ESC key event to close the menu.

With native context menus, closing the menu with a synthesized key event is not going to be possible. Is this a required capability for WebDriver? How do other browsers expose the ability to open and close context menus?

Flags: needinfo?(hskupin)
Priority: -- → P3

(In reply to Markus Stange [:mstange] from comment #0)

It opens the content area context menu with a synthesized right click, checks that the popup's state is "open", and then synthesizes an ESC key event to close the menu.

Markus, what's the way how Browser Chrome tests will close these native context menus? Does the ESC key needs to be synthesized against the window instead?

With native context menus, closing the menu with a synthesized key event is not going to be possible. Is this a required capability for WebDriver? How do other browsers expose the ability to open and close context menus?

Context menus aren't handled by the WebDriver spec.

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+1] from comment #1)

(In reply to Markus Stange [:mstange] from comment #0)

It opens the content area context menu with a synthesized right click, checks that the popup's state is "open", and then synthesizes an ESC key event to close the menu.

Markus, what's the way how Browser Chrome tests will close these native context menus?

Browser chrome tests can now close the native context menu by calling menupopupElement.hidePopup(). (This now works as of bug 1703333, it wasn't working when I filed this bug.)

Does the ESC key needs to be synthesized against the window instead?

From what I can tell, synthesized key events are ignored by native context menus, and they are also consumed in such a way that Firefox doesn't see them. So I think we just cannot synthesize any events (mouse or key) while the menu is open and expect it to work. Instead, we need to open the menu, inspect the contents, maybe call menuitem.doCommand() to execute a menu item, and then close the menu with .hidePopup().

With native context menus, closing the menu with a synthesized key event is not going to be possible. Is this a required capability for WebDriver? How do other browsers expose the ability to open and close context menus?

Context menus aren't handled by the WebDriver spec.

Ah ok good, so we just need to find a solution that works for us internally then.

Henrik, is it possible to call hidePopup() from test_context_click_action?

(In reply to Markus Stange [:mstange] from comment #2)

Markus, what's the way how Browser Chrome tests will close these native context menus?

Browser chrome tests can now close the native context menu by calling menupopupElement.hidePopup(). (This now works as of bug 1703333, it wasn't working when I filed this bug.)

This is fine. Marionette tests should use that too to close the native context menu then given that the ESC key doesn't work anymore.

Flags: needinfo?(hskupin)

(In reply to Markus Stange [:mstange] from comment #3)

Henrik, is it possible to call hidePopup() from test_context_click_action?

You can re-use the already retrieved context menu cm_el:

with self.marionette.using_context("chrome"):
     cm_el = self.marionette.find_element(By.ID, "contentAreaContextMenu")
     self.marionette.execute_script("arguments[0].hidePopup()", script_args=(cm_el,))

Thanks a lot, that works!

Blocks: 1700724
Summary: Figure out if and how the switch to native context menus on macOS affects the WebDriver actions API → Make test_context_click_action pass with native context menus
Assignee: nobody → mstange.moz
Status: NEW → ASSIGNED
Pushed by mstange@themasta.com: https://hg.mozilla.org/integration/autoland/rev/0b389ad6617a In test_context_click_action, close context menu with .hidePopup() which works with native context menus, too. r=whimboo,marionette-reviewers
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: