Bug 682618 - Explicitly blur and focus elements to ensure IsCommandEnabled calls are dispatched to correct element. r=gavin
authorGraeme McCutcheon <graememcc_firefox@graeme-online.co.uk>
Sat, 10 Sep 2011 17:17:36 +0100
changeset 77200 812cea5c372e80d75f983d6cd0138ac1ccd6706e
parent 77199 b80b4d52cd14da737d775738c395ec13f17c26b1
child 77201 028baeb2ca2125590df8cae87beabf91b25e2117
push id21187
push usermak77@bonardo.net
push dateWed, 21 Sep 2011 08:36:41 +0000
treeherdermozilla-central@3178f1c42505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs682618
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 682618 - Explicitly blur and focus elements to ensure IsCommandEnabled calls are dispatched to correct element. r=gavin
browser/base/content/test/test_contextmenu.html
--- a/browser/base/content/test/test_contextmenu.html
+++ b/browser/base/content/test/test_contextmenu.html
@@ -22,16 +22,20 @@ netscape.security.PrivilegeManager.enabl
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 function openContextMenuFor(element, shiftkey) {
     // Context menu should be closed before we open it again.
     is(contextMenu.state, "closed", "checking if popup is closed");
 
+    if (lastElement)
+      lastElement.blur();
+    element.focus();
+    lastElement = element;
     var eventDetails = { type : "contextmenu", button : 2, shiftKey : shiftkey };
     synthesizeMouse(element, 2, 2, eventDetails, element.ownerDocument.defaultView);
 }
 
 function closeContextMenu() {
     contextMenu.hidePopup();
 }
 
@@ -550,17 +554,17 @@ function runTest(testNum) {
         SimpleTest.finish();
         return;
   }
 
 }
 
 
 var testNum = 1;
-var subwindow, chromeWin, contextMenu;
+var subwindow, chromeWin, contextMenu, lastElement;
 var text, link, mailto, input, img, canvas, video_ok, video_bad, video_bad2,
     iframe, textarea, contenteditable, inputspell, pagemenu;
 
 function startTest() {
     netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
     chromeWin = subwindow
                     .QueryInterface(Ci.nsIInterfaceRequestor)
                     .getInterface(Ci.nsIWebNavigation)
@@ -572,16 +576,18 @@ function startTest() {
     contextMenu = chromeWin.document.getElementById("contentAreaContextMenu");
     ok(contextMenu, "Got context menu XUL");
 
     if (chromeWin.document.getElementById("Browser:Stop").getAttribute("disabled") != "true") {
       SimpleTest.executeSoon(startTest);
       return;
     }
 
+    lastElement = null;
+
     text   = subwindow.document.getElementById("test-text");
     link   = subwindow.document.getElementById("test-link");
     mailto = subwindow.document.getElementById("test-mailto");
     input  = subwindow.document.getElementById("test-input");
     img    = subwindow.document.getElementById("test-image");
     canvas = subwindow.document.getElementById("test-canvas");
     video_ok   = subwindow.document.getElementById("test-video-ok");
     video_bad  = subwindow.document.getElementById("test-video-bad");