test_toolbarbutton_ctrl_click.xhtml (1671B)
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" type="text/css"?> 4 <!-- 5 XUL Widget Test for the toolbarbutton element 6 --> 7 <window title="Titlebar" width="200" height="200" 8 onload="setTimeout(test_resizer_ctrl_click, 0);" 9 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 11 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 12 13 <toolbarbutton id="toolbarbutton" width="16" height="16"/> 14 15 <!-- test code goes here --> 16 <script type="application/javascript"><![CDATA[ 17 18 SimpleTest.waitForExplicitFinish(); 19 20 function test_resizer_ctrl_click() 21 { 22 let toolbarbutton = document.getElementById("toolbarbutton"); 23 let isCommandFired = false; 24 25 toolbarbutton.addEventListener("click", function(aEvent) { 26 // Delay check for command event, because it is fired after click event. 27 setTimeout(() => { 28 ok(isCommandFired, "Check if command event is fired"); 29 SimpleTest.finish(); 30 }, 0); 31 }); 32 toolbarbutton.addEventListener("command", function(aEvent) { 33 isCommandFired = true; 34 ok(aEvent.ctrlKey, "Check ctrlKey for command event"); 35 ok(!aEvent.shiftKey, "Check shiftKey for command event"); 36 ok(!aEvent.altKey, "Check altKey for command event"); 37 ok(!aEvent.metaKey, "Check metaKey for command event"); 38 is(aEvent.inputSource, MouseEvent.MOZ_SOURCE_MOUSE, 39 "Check inputSource for command event"); 40 }); 41 synthesizeMouseAtCenter(toolbarbutton, { ctrlKey: true }); 42 } 43 44 ]]> 45 </script> 46 47 </window>