test_menu.xhtml (3777B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 4 type="text/css"?> 5 6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 7 title="Hit testing for XUL menus"> 8 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> 10 11 <script type="application/javascript" 12 src="../common.js" /> 13 <script type="application/javascript" 14 src="../role.js" /> 15 <script type="application/javascript" 16 src="../states.js" /> 17 <script type="application/javascript" 18 src="../layout.js" /> 19 <script type="application/javascript" 20 src="../events.js" /> 21 22 <script type="application/javascript"> 23 <![CDATA[ 24 function openMenu(aMenuID, aMenuPopupID, aMenuItemID) 25 { 26 this.menuNode = getNode(aMenuID); 27 28 this.eventSeq = [ 29 new invokerChecker(EVENT_FOCUS, this.menuNode) 30 ]; 31 32 this.invoke = function openMenu_invoke() 33 { 34 this.menuNode.open = true; 35 } 36 37 this.finalCheck = function openMenu_finalCheck() 38 { 39 hitTest(aMenuPopupID, aMenuItemID, aMenuItemID); 40 } 41 42 this.getID = function openMenu_invoke() 43 { 44 return "open menu '" + aMenuID + "' and do hit testing"; 45 } 46 } 47 48 function closeMenu(aID, aSubID, aSub2ID) 49 { 50 this.menuNode = getNode(aID); 51 52 this.eventSeq = [ 53 new invokerChecker(EVENT_FOCUS, document) 54 ]; 55 56 this.invoke = function openMenu_invoke() 57 { 58 this.menuNode.open = false; 59 } 60 61 this.finalCheck = function openMenu_finalCheck() 62 { 63 testStates(aID, 0, 0, STATE_INVISIBLE | STATE_OFFSCREEN); 64 testStates(aSubID, STATE_INVISIBLE, 0, STATE_OFFSCREEN); 65 testStates(aSub2ID, STATE_INVISIBLE, 0, STATE_OFFSCREEN); 66 } 67 68 this.getID = function openMenu_invoke() 69 { 70 return "open menu and test states"; 71 } 72 } 73 74 var gQueue = null; 75 function doTest() 76 { 77 if (LINUX) { 78 ok(true, "No tests is running on Linux"); 79 SimpleTest.finish(); 80 return; 81 } 82 83 getNode("mi_file1").scrollIntoView(true); 84 85 gQueue = new eventQueue(); 86 gQueue.push(new openMenu("mi_file1", "mp_file1", "mi_file1.1")); 87 gQueue.push(new openMenu("mi_file1.2", "mp_file1.2", "mi_file1.2.1")); 88 gQueue.push(new closeMenu("mi_file1", "mi_file1.1", "mi_file1.2.1")); 89 gQueue.invoke(); // Will call SimpleTest.finish(); 90 } 91 92 SimpleTest.waitForExplicitFinish(); 93 addA11yLoadEvent(doTest); 94 ]]> 95 </script> 96 97 <hbox flex="1" style="overflow: auto;"> 98 <body xmlns="http://www.w3.org/1999/xhtml"> 99 <a target="_blank" 100 href="https://bugzilla.mozilla.org/show_bug.cgi?id=670087" 101 title="AccessibleObjectFromPoint returns incorrect accessible for popup menus"> 102 Bug 670087 103 </a> 104 105 <p id="display"></p> 106 <div id="content" style="display: none"> 107 </div> 108 <pre id="test"> 109 </pre> 110 </body> 111 112 <vbox flex="1"> 113 114 <menubar> 115 <menu label="File" id="mi_file1"> 116 <menupopup id="mp_file1"> 117 <menuitem label="SubFile" id="mi_file1.1"/> 118 <menu label="SubFile2" id="mi_file1.2"> 119 <menupopup style="max-height: 5em;" id="mp_file1.2"> 120 <menuitem label="SubSubFile" id="mi_file1.2.1"/> 121 <menuitem label="SubSubFile2" id="mi_file1.2.2"/> 122 <menuitem label="SubSubFile3" id="mi_file1.2.3"/> 123 <menuitem label="SubSubFile4" id="mi_file1.2.4"/> 124 </menupopup> 125 </menu> 126 </menupopup> 127 </menu> 128 </menubar> 129 </vbox> 130 </hbox> 131 132 </window>