Bug 505562, use synthesizeMouse properly, r=dolske
authorNeil Deakin <neil@mozilla.com>
Tue, 04 Aug 2009 14:03:42 -0400
changeset 31116 bfd1c5a81e37bd21d3faa07c39bd3e6cef170056
parent 31115 5cb576a2923ac609da65a0bfba1f154c7a34d970
child 31117 c116e4a364c859c2257b1c8934e4992d0a9d8018
push id8377
push userneil@mozilla.com
push dateTue, 04 Aug 2009 18:04:37 +0000
treeherdermozilla-central@bfd1c5a81e37 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs505562
milestone1.9.2a1pre
Bug 505562, use synthesizeMouse properly, r=dolske
browser/base/content/test/test_contextmenu.html
--- a/browser/base/content/test/test_contextmenu.html
+++ b/browser/base/content/test/test_contextmenu.html
@@ -23,38 +23,18 @@ netscape.security.PrivilegeManager.enabl
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 function openContextMenuFor(element) {
     // Context menu should be closed before we open it again.
     is(contextMenu.state, "closed", "checking if popup is closed");
 
-    // XXX this doesn't work:
-    // var eventDetails = { type : "contextmenu", button : 2 }
-    // synthesizeMouse(element, 50, 90, eventDetails);
-    //
-    // It triggers the popup, but then we fail in nsContextMenu when
-    // initializing: ine 565: this.target.ownerDocument is null
-    // |this.target| was assigned there from |document.popupNode|, but it's a
-    // HTMLDocument instead of the node we supposedly fired the event at.
-    // I think the event's |target| is never being set, and we're hitting the
-    // fallback case in nsXULPopupListener::PreLaunchPopup.
-    //
-    // Also interesting is that just firing a mousedown+mouseup doesn't seem
-    // to do anything. Not clear why we'd specifically have to fire a
-    // contextmenu event instead of just a right-click.
-
-    // This seems to work, as long as we explicitly set the popupNode first.
-    // For frames, the popupNode needs to be set to inside the frame.
-    if (element.localName == "iframe")
-        chromeWin.document.popupNode = element.contentDocument.body;
-    else
-        chromeWin.document.popupNode = element;
-    contextMenu.openPopup(element, "overlap", 5, 5, true, false);
+    var eventDetails = { type : "contextmenu", button : 2 }
+    synthesizeMouse(element, 2, 2, eventDetails, element.ownerDocument.defaultView);
 }
 
 function closeContextMenu() {
     contextMenu.hidePopup();
 }
 
 function getVisibleMenuItems(aMenu) {
     var items = [];