|
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 bug 557987 |
|
6 --> |
|
7 <window title="Bug 557987" width="400" height="400" |
|
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
11 |
|
12 <toolbarbutton id="button" type="menu-button" label="Test bug 557987" |
|
13 onclick="eventReceived('click');" |
|
14 oncommand="eventReceived('command');"> |
|
15 <menupopup onpopupshowing="eventReceived('popupshowing'); return false;" /> |
|
16 </toolbarbutton> |
|
17 <menulist id="menulist" editable="true" value="Test bug 557987" |
|
18 onfocus="eventReceived('focus')" /> |
|
19 <!-- test results are displayed in the html:body --> |
|
20 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> |
|
21 |
|
22 <script type="application/javascript"> |
|
23 <![CDATA[ |
|
24 |
|
25 SimpleTest.waitForExplicitFinish(); |
|
26 |
|
27 SimpleTest.waitForFocus(test); |
|
28 |
|
29 // Tests that mouse events are correctly dispatched to <toolbarbutton type="menu-button"/> |
|
30 function test() { |
|
31 |
|
32 disableNonTestMouseEvents(true); |
|
33 |
|
34 let button = $("button"); |
|
35 let rightEdge = button.getBoundingClientRect().width - 2; |
|
36 let centerX = button.getBoundingClientRect().width / 2; |
|
37 let centerY = button.getBoundingClientRect().height / 2; |
|
38 |
|
39 synthesizeMouse(button, rightEdge, centerY, {}, window); |
|
40 synthesizeMouse(button, centerX, centerY, {}, window); |
|
41 |
|
42 let menulist = $("menulist"); |
|
43 let centerX = menulist.getBoundingClientRect().width / 2; |
|
44 let centerY = menulist.getBoundingClientRect().height / 2; |
|
45 synthesizeMouse(menulist, centerX, centerY, {}, window); |
|
46 |
|
47 synthesizeMouse(document.getElementsByTagName("body")[0], 0, 0, {}, window); |
|
48 |
|
49 disableNonTestMouseEvents(false); |
|
50 SimpleTest.executeSoon(finishTest); |
|
51 |
|
52 } |
|
53 |
|
54 function finishTest() { |
|
55 is(eventCount.command, 1, "Correct number of command events received"); |
|
56 is(eventCount.popupshowing, 1, "Correct number of popupshowing events received"); |
|
57 is(eventCount.click, 2, "Correct number of click events received"); |
|
58 is(eventCount.focus, 1, "Correct number of focus events received"); |
|
59 |
|
60 SimpleTest.finish(); |
|
61 } |
|
62 |
|
63 let eventCount = { |
|
64 command: 0, |
|
65 popupshowing: 0, |
|
66 click: 0, |
|
67 focus: 0 |
|
68 }; |
|
69 |
|
70 function eventReceived(eventName) { |
|
71 eventCount[eventName]++; |
|
72 } |
|
73 |
|
74 ]]> |
|
75 </script> |
|
76 </window> |