Bug 615189 - tests for menu events, r=fer, a=test
authorAlexander Surkov <surkov.alexander@gmail.com>
Fri, 03 Dec 2010 18:49:20 +0800
changeset 58540 eb4d2a3dc388cac70d1dcf9b0c3900063d430c97
parent 58539 d25494ae4c3b3a3a63c96f96078ec1e9a3908ecc
child 58541 d9f03972cad82cbfe2efe9f54299e64ec265d68c
push id17342
push usersurkov.alexander@gmail.com
push dateFri, 03 Dec 2010 10:49:57 +0000
treeherdermozilla-central@eb4d2a3dc388 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfer, test
bugs615189
milestone2.0b8pre
first release with
nightly win64
eb4d2a3dc388 / 4.0b8pre / 20101203044708 / files
nightly linux32
nightly linux64
nightly mac
nightly win32
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly win64
Bug 615189 - tests for menu events, r=fer, a=test
accessible/tests/mochitest/events.js
accessible/tests/mochitest/events/Makefile.in
accessible/tests/mochitest/events/test_aria_menu.html
accessible/tests/mochitest/events/test_menu.xul
--- a/accessible/tests/mochitest/events.js
+++ b/accessible/tests/mochitest/events.js
@@ -3,16 +3,18 @@
 
 const EVENT_ALERT = nsIAccessibleEvent.EVENT_ALERT;
 const EVENT_DOCUMENT_LOAD_COMPLETE = nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_COMPLETE;
 const EVENT_DOCUMENT_RELOAD = nsIAccessibleEvent.EVENT_DOCUMENT_RELOAD;
 const EVENT_DOCUMENT_LOAD_STOPPED = nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_STOPPED;
 const EVENT_HIDE = nsIAccessibleEvent.EVENT_HIDE;
 const EVENT_FOCUS = nsIAccessibleEvent.EVENT_FOCUS;
 const EVENT_NAME_CHANGE = nsIAccessibleEvent.EVENT_NAME_CHANGE;
+const EVENT_MENU_START = nsIAccessibleEvent.EVENT_MENU_START;
+const EVENT_MENU_END = nsIAccessibleEvent.EVENT_MENU_END;
 const EVENT_MENUPOPUP_START = nsIAccessibleEvent.EVENT_MENUPOPUP_START;
 const EVENT_MENUPOPUP_END = nsIAccessibleEvent.EVENT_MENUPOPUP_END;
 const EVENT_REORDER = nsIAccessibleEvent.EVENT_REORDER;
 const EVENT_SCROLLING_START = nsIAccessibleEvent.EVENT_SCROLLING_START;
 const EVENT_SELECTION_ADD = nsIAccessibleEvent.EVENT_SELECTION_ADD;
 const EVENT_SELECTION_WITHIN = nsIAccessibleEvent.EVENT_SELECTION_WITHIN;
 const EVENT_SHOW = nsIAccessibleEvent.EVENT_SHOW;
 const EVENT_STATE_CHANGE = nsIAccessibleEvent.EVENT_STATE_CHANGE;
@@ -648,32 +650,33 @@ function sequence()
   this.idx = -1;
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // Event queue invokers
 
 /**
- * Invokers defined below take a checker object implementing 'check' method
- * which will be called when proper event is handled. Invokers listen default
- * event type registered in event queue object until it is passed explicetly.
+ * Invokers defined below take a checker object (or array of checker objects)
+ * implementing 'check' method which will be called when proper event is
+ * handled. Invokers listen default event type registered in event queue object
+ * until it is passed explicetly.
  *
- * Note, checker object is optional.
+ * Note, checker object or array of checker objects is optional.
  * Note, you don't need to initialize 'target' and 'type' members of checker
  * object. The 'target' member will be initialized by invoker object and you are
  * free to use it in 'check' method.
  */
 
 /**
  * Click invoker.
  */
-function synthClick(aNodeOrID, aChecker, aEventType)
+function synthClick(aNodeOrID, aCheckerOrEventSeq, aEventType)
 {
-  this.__proto__ = new synthAction(aNodeOrID, aChecker, aEventType);
+  this.__proto__ = new synthAction(aNodeOrID, aCheckerOrEventSeq, aEventType);
 
   this.invoke = function synthClick_invoke()
   {
     // Scroll the node into view, otherwise synth click may fail.
     if (this.DOMNode instanceof nsIDOMNSHTMLElement)
       this.DOMNode.scrollIntoView(true);
 
     synthesizeMouse(this.DOMNode, 1, 1, {});
@@ -683,38 +686,38 @@ function synthClick(aNodeOrID, aChecker,
   {
     return prettyName(aNodeOrID) + " click"; 
   }
 }
 
 /**
  * Mouse move invoker.
  */
-function synthMouseMove(aNodeOrID, aChecker, aEventType)
+function synthMouseMove(aNodeOrID, aCheckerOrEventSeq, aEventType)
 {
-  this.__proto__ = new synthAction(aNodeOrID, aChecker, aEventType);
+  this.__proto__ = new synthAction(aNodeOrID, aCheckerOrEventSeq, aEventType);
 
   this.invoke = function synthMouseMove_invoke()
   {
     synthesizeMouse(this.DOMNode, 1, 1, { type: "mousemove" });
     synthesizeMouse(this.DOMNode, 2, 2, { type: "mousemove" });
   }
 
   this.getID = function synthMouseMove_getID()
   {
     return prettyName(aNodeOrID) + " mouse move"; 
   }
 }
 
 /**
  * General key press invoker.
  */
-function synthKey(aNodeOrID, aKey, aArgs, aChecker, aEventType)
+function synthKey(aNodeOrID, aKey, aArgs, aCheckerOrEventSeq, aEventType)
 {
-  this.__proto__ = new synthAction(aNodeOrID, aChecker, aEventType);
+  this.__proto__ = new synthAction(aNodeOrID, aCheckerOrEventSeq, aEventType);
 
   this.invoke = function synthKey_invoke()
   {
     synthesizeKey(this.mKey, this.mArgs);
   }
 
   this.getID = function synthKey_getID()
   {
@@ -723,126 +726,126 @@ function synthKey(aNodeOrID, aKey, aArgs
 
   this.mKey = aKey;
   this.mArgs = aArgs ? aArgs : {};
 }
 
 /**
  * Tab key invoker.
  */
-function synthTab(aNodeOrID, aChecker, aEventType)
+function synthTab(aNodeOrID, aCheckerOrEventSeq, aEventType)
 {
   this.__proto__ = new synthKey(aNodeOrID, "VK_TAB", { shiftKey: false },
-                                aChecker, aEventType);
+                                aCheckerOrEventSeq, aEventType);
 
   this.getID = function synthTab_getID() 
   { 
     return prettyName(aNodeOrID) + " tab";
   }
 }
 
 /**
  * Shift tab key invoker.
  */
-function synthShiftTab(aNodeOrID, aChecker, aEventType)
+function synthShiftTab(aNodeOrID, aCheckerOrEventSeq, aEventType)
 {
   this.__proto__ = new synthKey(aNodeOrID, "VK_TAB", { shiftKey: true },
-                                aChecker, aEventType);
+                                aCheckerOrEventSeq, aEventType);
 
   this.getID = function synthTabTest_getID() 
   { 
     return prettyName(aNodeOrID) + " shift tab";
   }
 }
 
 /**
  * Down arrow key invoker.
  */
-function synthDownKey(aNodeOrID, aChecker, aEventType)
+function synthDownKey(aNodeOrID, aCheckerOrEventSeq, aEventType)
 {
-  this.__proto__ = new synthKey(aNodeOrID, "VK_DOWN", null, aChecker,
+  this.__proto__ = new synthKey(aNodeOrID, "VK_DOWN", null, aCheckerOrEventSeq,
                                 aEventType);
 
   this.getID = function synthDownKey_getID()
   {
     return prettyName(aNodeOrID) + " key down";
   }
 }
 
 /**
  * Right arrow key invoker.
  */
-function synthRightKey(aNodeOrID, aChecker, aEventType)
+function synthRightKey(aNodeOrID, aCheckerOrEventSeq, aEventType)
 {
-  this.__proto__ = new synthKey(aNodeOrID, "VK_RIGHT", null, aChecker,
+  this.__proto__ = new synthKey(aNodeOrID, "VK_RIGHT", null, aCheckerOrEventSeq,
                                 aEventType);
 
   this.getID = function synthRightKey_getID()
   {
     return prettyName(aNodeOrID) + " key right";
   }
 }
 
 /**
  * Home key invoker.
  */
-function synthHomeKey(aNodeOrID, aChecker, aEventType)
+function synthHomeKey(aNodeOrID, aCheckerOrEventSeq, aEventType)
 {
-  this.__proto__ = new synthKey(aNodeOrID, "VK_HOME", null, aChecker,
+  this.__proto__ = new synthKey(aNodeOrID, "VK_HOME", null, aCheckerOrEventSeq,
                                 aEventType);
   
   this.getID = function synthHomeKey_getID()
   {
     return prettyName(aNodeOrID) + " key home";
   }
 }
 
 /**
  * Focus invoker.
  */
-function synthFocus(aNodeOrID, aChecker, aEventType)
+function synthFocus(aNodeOrID, aCheckerOrEventSeq, aEventType)
 {
-  this.__proto__ = new synthAction(aNodeOrID, aChecker, aEventType);
+  this.__proto__ = new synthAction(aNodeOrID, aCheckerOrEventSeq, aEventType);
 
   this.invoke = function synthFocus_invoke()
   {
     this.DOMNode.focus();
   }
 
   this.getID = function synthFocus_getID() 
   { 
     return prettyName(aNodeOrID) + " focus";
   }
 }
 
 /**
  * Focus invoker. Focus the HTML body of content document of iframe.
  */
-function synthFocusOnFrame(aNodeOrID, aChecker, aEventType)
+function synthFocusOnFrame(aNodeOrID, aCheckerOrEventSeq, aEventType)
 {
   this.__proto__ = new synthAction(getNode(aNodeOrID).contentDocument,
-                                   aChecker, aEventType);
+                                   aCheckerOrEventSeq, aEventType);
   
   this.invoke = function synthFocus_invoke()
   {
     this.DOMNode.body.focus();
   }
   
   this.getID = function synthFocus_getID() 
   { 
     return prettyName(aNodeOrID) + " frame document focus";
   }
 }
 
 /**
  * Select all invoker.
  */
-function synthSelectAll(aNodeOrID, aChecker, aEventType)
+function synthSelectAll(aNodeOrID, aCheckerOrEventSeq, aEventType)
 {
-  this.__proto__ = new synthAction(aNodeOrID, aChecker, aEventType);
+  this.__proto__ = new synthAction(aNodeOrID, aCheckerOrEventSeq, aEventType);
 
   this.invoke = function synthSelectAll_invoke()
   {
     if (this.DOMNode instanceof Components.interfaces.nsIDOMHTMLInputElement)
       this.DOMNode.select();
     else
       window.getSelection().selectAllChildren(this.DOMNode);
   }
@@ -1139,25 +1142,33 @@ function sequenceItem(aProcessor, aEvent
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Event queue invokers
 
 /**
  * Invoker base class for prepare an action.
  */
-function synthAction(aNodeOrID, aChecker, aEventType)
+function synthAction(aNodeOrID, aCheckerOrEventSeq, aEventType)
 {
   this.DOMNode = getNode(aNodeOrID);
-  if (aChecker)
-    aChecker.target = this.DOMNode;
+
+  this.checker = null;
+  if (aCheckerOrEventSeq) {
+    if (aCheckerOrEventSeq instanceof Array) {
+      this.eventSeq = aCheckerOrEventSeq;
+    } else {
+      this.checker = aCheckerOrEventSeq;
+      this.checker.target = this.DOMNode;
+    }
+  }
 
   if (aEventType)
     this.eventSeq = [ new invokerChecker(aEventType, this.DOMNode) ];
 
   this.check = function synthAction_check(aEvent)
   {
-    if (aChecker)
-      aChecker.check(aEvent);
+    if (this.checker)
+      this.checker.check(aEvent);
   }
 
   this.getID = function synthAction_getID() { return aNodeOrID + " action"; }
 }
--- a/accessible/tests/mochitest/events/Makefile.in
+++ b/accessible/tests/mochitest/events/Makefile.in
@@ -60,16 +60,17 @@ include $(topsrcdir)/config/rules.mk
 		test_docload.html \
 		test_docload.xul \
 		test_dragndrop.html \
 		test_flush.html \
 		test_focus.html \
 		test_focus.xul \
 		test_focus_name.html \
 		test_focusdoc.html \
+		test_menu.xul \
 		test_mutation.html \
 		test_scroll.xul \
 		test_selection.html \
 		test_statechange.html \
 		test_text.html \
 		test_textattrchange.html \
 		test_tree.xul \
 		test_valuechange.html \
--- a/accessible/tests/mochitest/events/test_aria_menu.html
+++ b/accessible/tests/mochitest/events/test_aria_menu.html
@@ -5,36 +5,56 @@
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
 
   <script type="application/javascript">
     const kViaDisplayStyle = 0;
     const kViaVisibilityStyle = 1;
 
-    function showMenu(aMenuID, aHow)
+    function focusMenu(aMenuBarID, aMenuID)
+    {
+      this.eventSeq = [
+        new invokerChecker(EVENT_MENU_START, getNode(aMenuBarID)),
+        new invokerChecker(EVENT_FOCUS, getNode(aMenuID)),
+      ];
+
+      this.invoke = function focusMenu_invoke()
+      {
+        getNode(aMenuID).focus();
+      }
+
+      this.getID = function focusMenu_getID()
+      {
+        return "focus menu '" + aMenuID + "'";
+      }
+    }
+
+    function showMenu(aMenuID, aParentMenuID, aHow)
     {
       this.menuNode = getNode(aMenuID);
 
       this.eventSeq = [
         new invokerChecker(EVENT_SHOW, this.menuNode),
         new invokerChecker(EVENT_MENUPOPUP_START, this.menuNode),
-        new invokerChecker(EVENT_REORDER, document)
+        new invokerChecker(EVENT_REORDER, getNode(aParentMenuID))
       ];
 
       this.invoke = function showMenu_invoke()
       {
         if (aHow == kViaDisplayStyle)
           this.menuNode.style.display = "block";
         else
           this.menuNode.style.visibility = "visible";
@@ -43,25 +63,25 @@
       this.getID = function showMenu_getID()
       {
         return "Show ARIA menu " + aMenuID + " by " +
           (aHow == kViaDisplayStyle ? "display" : "visibility") +
           " style tricks";
       };
     }
 
-    function closeMenu(aMenuID, aHow)
+    function closeMenu(aMenuID, aParentMenuID, aHow)
     {
       this.menuNode = getNode(aMenuID);
       this.menu = null;
 
       this.eventSeq = [
         new invokerChecker(EVENT_MENUPOPUP_END, getMenu, this),
         new invokerChecker(EVENT_HIDE, getMenu, this),
-        new invokerChecker(EVENT_REORDER, document),
+        new invokerChecker(EVENT_REORDER, getNode(aParentMenuID))
       ];
 
       this.invoke = function closeMenu_invoke()
       {
         // Store menu accessible reference while menu is still open.
         this.menu = getAccessible(this.menuNode);
 
         // Hide menu.
@@ -79,31 +99,71 @@
       }
 
       function getMenu(aThisObj)
       {
         return aThisObj.menu;
       }
     }
 
+    function focusInsideMenu(aMenuID, aMenuBarID)
+    {
+      this.eventSeq = [
+        new invokerChecker(EVENT_FOCUS, getNode(aMenuID))
+      ];
+
+      this.unexpectedEventSeq = [
+        new invokerChecker(EVENT_MENU_END, getNode(aMenuBarID))
+      ];
+
+      this.invoke = function focusInsideMenu_invoke()
+      {
+        getNode(aMenuID).focus();
+      }
+
+      this.getID = function focusInsideMenu_getID()
+      {
+        return "focus menu '" + aMenuID + "'";
+      }
+    }
+
+    function blurMenu(aMenuBarID)
+    {
+      var eventSeq = [
+        new invokerChecker(EVENT_MENU_END, getNode(aMenuBarID)),
+        new invokerChecker(EVENT_FOCUS, getNode("outsidemenu"))
+      ];
+
+      this.__proto__ = new synthClick("outsidemenu", eventSeq);
+
+      this.getID = function blurMenu_getID()
+      {
+        return "blur menu";
+      }
+    }
+
     ////////////////////////////////////////////////////////////////////////////
     // Do tests
 
     var gQueue = null;
 
     //gA11yEventDumpID = "eventdump";
+    //gA11yEventDumpToConsole = true;
 
     function doTests()
     {
       gQueue = new eventQueue();
 
-      gQueue.push(new showMenu("menu1", kViaDisplayStyle));
-      gQueue.push(new closeMenu("menu1", kViaDisplayStyle));
-      gQueue.push(new showMenu("menu2", kViaVisibilityStyle));
-      gQueue.push(new closeMenu("menu2", kViaVisibilityStyle));
+      gQueue.push(new focusMenu("menubar", "menu-file"));
+      gQueue.push(new showMenu("menupopup-file", "menu-file", kViaDisplayStyle));
+      gQueue.push(new closeMenu("menupopup-file", "menu-file", kViaDisplayStyle));
+      gQueue.push(new showMenu("menupopup-edit", "menu-edit", kViaVisibilityStyle));
+      gQueue.push(new closeMenu("menupopup-edit", "menu-edit", kViaVisibilityStyle));
+      gQueue.push(new focusInsideMenu("menu-edit", "menubar"));
+      gQueue.push(new blurMenu("menubar"));
 
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTests);
   </script>
 </head>
@@ -115,27 +175,41 @@
      title="Dojo dropdown buttons are broken">
     Mozilla Bug 606207
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=614829"
      title="Menupopup end event isn't fired for ARIA menus">
     Mozilla Bug 614829
   </a>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=615189"
+     title="Clean up FireAccessibleFocusEvent">
+    Mozilla Bug 615189
+  </a>
 
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
-  <div id="menu1" role="menu" style="display: none;">
-    <div role="menuitem">menuitem1.1</div>
-    <div role="menuitem">menuitem1.2</div>
+  <div id="menubar" role="menubar">
+    <div id="menu-file" role="menuitem" tabindex="0">
+      File
+      <div id="menupopup-file" role="menu" style="display: none;">
+        <div id="menuitem-newtab" role="menuitem" tabindex="0">New Tab</div>
+        <div id="menuitem-newwindow" role="menuitem" tabindex="0">New Window</div>
+      </div>
+    </div>
+    <div id="menu-edit" role="menuitem" tabindex="0">
+      Edit
+      <div id="menupopup-edit" role="menu" style="visibility: hidden;">
+        <div id="menuitem-undo" role="menuitem" tabindex="0">Undo</div>
+        <div id="menuitem-redo" role="menuitem" tabindex="0">Redo</div>
+      </div>
+    </div>
   </div>
-  <div id="menu2" role="menu" style="visibility: hidden;">
-    <div role="menuitem">menuitem2.1</div>
-    <div role="menuitem">menuitem2.2</div>
-  </div>
+  <div tabindex="0" id="outsidemenu">outsidemenu</div>
 
   <div id="eventdump"></div>
 
 </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/events/test_menu.xul
@@ -0,0 +1,204 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+                 type="text/css"?>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        title="Accessible menu events testing for XUL menu">
+
+  <script type="application/javascript" 
+          src="chrome://mochikit/content/MochiKit/packed.js" />
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+  <script type="application/javascript"
+          src="../common.js" />
+  <script type="application/javascript"
+          src="../events.js" />
+
+  <script type="application/javascript">
+    function openFileMenu()
+    {
+      this.eventSeq = [
+        new invokerChecker(EVENT_MENU_START, getNode("menubar")),
+        new invokerChecker(EVENT_MENUPOPUP_START, getNode("menupopup-file"))
+        // new invokerChecker(EVENT_FOCUS, getNode("menuitem-newtab")) intermitent failure
+      ];
+
+      this.invoke = function openFileMenu_invoke()
+      {
+        synthesizeKey("F", { altKey: true, shiftKey: true });
+      }
+
+      this.getID = function openFileMenu_getID()
+      {
+        return "open file menu by alt+F press";
+      }
+    }
+
+    function openEditMenu()
+    {
+      this.eventSeq = [
+        new invokerChecker(EVENT_MENUPOPUP_END, getNode("menupopup-file")),
+        new invokerChecker(EVENT_MENUPOPUP_START, getNode("menupopup-edit"))
+        // new invokerChecker(EVENT_FOCUS, getNode("menuitem-undo")) intermitent failure
+      ];
+
+      this.invoke = function openEditMenu_invoke()
+      {
+        synthesizeKey("VK_RIGHT", { });
+      }
+
+      this.getID = function openEditMenu_getID()
+      {
+        return "open edit menu by lef arrow press";
+      }
+    }
+
+    function closeEditMenu()
+    {
+      this.eventSeq = [
+        //new invokerChecker(EVENT_FOCUS, document), intermitent failure
+        new invokerChecker(EVENT_MENUPOPUP_END, getNode("menupopup-edit")),
+        new invokerChecker(EVENT_MENU_END, getNode("menubar"))
+      ];
+
+      this.invoke = function closeEditMenu_invoke()
+      {
+        synthesizeKey("VK_ESCAPE", { });
+      }
+
+      this.getID = function closeEditMenu_getID()
+      {
+        return "close edit menu, leave menubar";
+      }
+    }
+
+    function focusFileMenu()
+    {
+      this.eventSeq = [
+        new invokerChecker(EVENT_MENU_START, getNode("menubar")),
+        new invokerChecker(EVENT_FOCUS, getNode("menuitem-file"))
+      ];
+
+      this.invoke = function focusFileMenu_invoke()
+      {
+        synthesizeKey("VK_ALT", { });
+      }
+
+      this.getID = function focusFileMenu_getID()
+      {
+        return "activate menubar, focus file menu (atl press)";
+      }
+    }
+
+    function focusEditMenu()
+    {
+      this.eventSeq = [
+        new invokerChecker(EVENT_FOCUS, getNode("menuitem-edit"))
+      ];
+
+      this.invoke = function focusEditMenu_invoke()
+      {
+        synthesizeKey("VK_RIGHT", { });
+      }
+
+      this.getID = function focusEditMenu_getID()
+      {
+        return "focus edit menu";
+      }
+    }
+
+    function leaveMenubar()
+    {
+      this.eventSeq = [
+        //new invokerChecker(EVENT_FOCUS, document), intermitent failure
+        new invokerChecker(EVENT_MENU_END, getNode("menubar"))
+      ];
+
+      this.invoke = function leaveMenubar_invoke()
+      {
+        synthesizeKey("VK_ESCAPE", { });
+      }
+
+      this.getID = function leaveMenubar_getID()
+      {
+        return "leave menubar";
+      }
+    }
+
+    /**
+     * Do tests.
+     */
+
+    //gA11yEventDumpID = "eventdump";
+    gA11yEventDumpToConsole = true;
+
+    var gQueue = null;
+
+    function doTests()
+    {
+      if (!WIN) {
+        todo(false, "Enable this test on other platforms.");
+        SimpleTest.finish();
+        return;
+      }
+
+      todo(false,
+           "Fix intermitent failures. Focus may randomly occur before or after menupopup events!");
+
+      gQueue = new eventQueue();
+
+      gQueue.push(new openFileMenu());
+      gQueue.push(new openEditMenu());
+      gQueue.push(new closeEditMenu());
+
+      // Alt key is used to active menubar and focus menu item on Windows,
+      // other platforms requires setting a ui.key.menuAccessKeyFocuses
+      // preference.
+      if (WIN) {
+        gQueue.push(new focusFileMenu());
+        gQueue.push(new focusEditMenu());
+        gQueue.push(new leaveMenubar());
+      }
+
+      gQueue.invoke(); // Will call SimpleTest.finish();
+    }
+
+    SimpleTest.waitForExplicitFinish();
+    addA11yLoadEvent(doTests);
+  </script>
+
+  <hbox flex="1" style="overflow: auto;">
+    <body xmlns="http://www.w3.org/1999/xhtml">
+      <a target="_blank"
+         href="https://bugzilla.mozilla.org/show_bug.cgi?id=615189"
+         title="Clean up FireAccessibleFocusEvent">
+        Mozilla Bug 615189
+      </a>
+      <p id="display"></p>
+      <div id="content" style="display: none"></div>
+      <pre id="test">
+      </pre>
+    </body>
+
+    <vbox flex="1">
+      <menubar id="menubar">
+        <menu id="menuitem-file" label="File" accesskey="F">
+          <menupopup id="menupopup-file">
+            <menuitem id="menuitem-newtab" label="New Tab"/>
+          </menupopup>
+        </menu>
+        <menu id="menuitem-edit" label="Edit" accesskey="E">
+          <menupopup id="menupopup-edit">
+            <menuitem id="menuitem-undo" label="Undo"/>
+          </menupopup>
+        </menu>
+      </menubar>
+
+      <vbox id="eventdump" role="log"/>
+    </vbox>
+  </hbox>
+</window>