Closed Bug 1704211 Opened 4 years ago Closed 4 years ago

[meta] Stop synthesizing events on context menus in automated tests

Categories

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

task

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox-esr78 --- unaffected
firefox87 --- unaffected
firefox88 --- unaffected
firefox89 --- fixed
firefox90 --- fixed

People

(Reporter: mstange, Assigned: mstange)

References

Details

(Keywords: meta, Whiteboard: [proton-context-menus] [mac:mr1] [priority:2c])

On macOS, native context menus do not respond to synthesized events, such as mousemove, click, or key presses. However, we have many automated tests which use synthesized events to interact with context menus.

This bug tracks converting our existing tests to menu.openMenu(true) for opening submenus, and popup.activateItem(menuitem) (new from bug 1704206) for clicking items.

Example:

diff --git a/browser/components/extensions/test/browser/head.js b/browser/components/extensions/test/browser/head.js
--- a/browser/components/extensions/test/browser/head.js
+++ b/browser/components/extensions/test/browser/head.js
@@ -490,31 +490,31 @@ async function openExtensionContextMenu(
     return null;
   }
 
   let extensionMenu = topLevelMenu[0];
   let popupShownPromise = BrowserTestUtils.waitForEvent(
     contextMenu,
     "popupshown"
   );
-  EventUtils.synthesizeMouseAtCenter(extensionMenu, {});
+  extensionMenu.openMenu(true);
   await popupShownPromise;
   return extensionMenu;
 }
 
 async function closeExtensionContextMenu(itemToSelect, modifiers = {}) {
   let contentAreaContextMenu = document.getElementById(
     "contentAreaContextMenu"
   );
   let popupHiddenPromise = BrowserTestUtils.waitForEvent(
     contentAreaContextMenu,
     "popuphidden"
   );
   if (itemToSelect) {
-    EventUtils.synthesizeMouseAtCenter(itemToSelect, modifiers);
+    contentAreaContextMenu.activateItem(itemToSelect, modifiers);
   } else {
     contentAreaContextMenu.hidePopup();
   }
   await popupHiddenPromise;
 
   // Bug 1351638: parent menu fails to close intermittently, make sure it does.
   contentAreaContextMenu.hidePopup();
 }
Depends on: 1704569
Depends on: 1704691
Depends on: 1704870
Depends on: 1704875
Depends on: 1704837
Priority: -- → P2
Whiteboard: [proton-context-menus][mac:mr1] → [proton-context-menus] [mac:mr1] [priority:2c]

This is done. At least half of the patches under bugs blocking bug 1700724 fell under this category.

Assignee: nobody → mstange.moz
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
You need to log in before you can comment on or make changes to this bug.