1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/chrome/test_bug557987.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 +<!-- 1.8 + XUL Widget Test for bug 557987 1.9 + --> 1.10 +<window title="Bug 557987" width="400" height="400" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.14 + 1.15 + <toolbarbutton id="button" type="menu-button" label="Test bug 557987" 1.16 + onclick="eventReceived('click');" 1.17 + oncommand="eventReceived('command');"> 1.18 + <menupopup onpopupshowing="eventReceived('popupshowing'); return false;" /> 1.19 + </toolbarbutton> 1.20 + <menulist id="menulist" editable="true" value="Test bug 557987" 1.21 + onfocus="eventReceived('focus')" /> 1.22 + <!-- test results are displayed in the html:body --> 1.23 + <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> 1.24 + 1.25 +<script type="application/javascript"> 1.26 +<![CDATA[ 1.27 + 1.28 +SimpleTest.waitForExplicitFinish(); 1.29 + 1.30 +SimpleTest.waitForFocus(test); 1.31 + 1.32 +// Tests that mouse events are correctly dispatched to <toolbarbutton type="menu-button"/> 1.33 +function test() { 1.34 + 1.35 + disableNonTestMouseEvents(true); 1.36 + 1.37 + let button = $("button"); 1.38 + let rightEdge = button.getBoundingClientRect().width - 2; 1.39 + let centerX = button.getBoundingClientRect().width / 2; 1.40 + let centerY = button.getBoundingClientRect().height / 2; 1.41 + 1.42 + synthesizeMouse(button, rightEdge, centerY, {}, window); 1.43 + synthesizeMouse(button, centerX, centerY, {}, window); 1.44 + 1.45 + let menulist = $("menulist"); 1.46 + let centerX = menulist.getBoundingClientRect().width / 2; 1.47 + let centerY = menulist.getBoundingClientRect().height / 2; 1.48 + synthesizeMouse(menulist, centerX, centerY, {}, window); 1.49 + 1.50 + synthesizeMouse(document.getElementsByTagName("body")[0], 0, 0, {}, window); 1.51 + 1.52 + disableNonTestMouseEvents(false); 1.53 + SimpleTest.executeSoon(finishTest); 1.54 + 1.55 +} 1.56 + 1.57 +function finishTest() { 1.58 + is(eventCount.command, 1, "Correct number of command events received"); 1.59 + is(eventCount.popupshowing, 1, "Correct number of popupshowing events received"); 1.60 + is(eventCount.click, 2, "Correct number of click events received"); 1.61 + is(eventCount.focus, 1, "Correct number of focus events received"); 1.62 + 1.63 + SimpleTest.finish(); 1.64 +} 1.65 + 1.66 +let eventCount = { 1.67 + command: 0, 1.68 + popupshowing: 0, 1.69 + click: 0, 1.70 + focus: 0 1.71 +}; 1.72 + 1.73 +function eventReceived(eventName) { 1.74 + eventCount[eventName]++; 1.75 +} 1.76 + 1.77 +]]> 1.78 +</script> 1.79 +</window>