Bug 1704211 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

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 the new APIs introduced in bug 1704206.

Example:

```diff
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.openSubmenu();
   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();
 }
```
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
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();
 }
```

Back to Bug 1704211 Comment 0