|
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 562554 |
|
6 --> |
|
7 <window title="Bug 562554" width="400" height="400" |
|
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
9 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
11 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
12 |
|
13 <xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl"> |
|
14 <xbl:binding id="menu" display="xul:menu" |
|
15 extends="chrome://global/content/bindings/button.xml#button-base"> |
|
16 <xbl:content> |
|
17 <xbl:children includes="menupopup"/> |
|
18 <xul:stack> |
|
19 <xul:button width="100" left="0" top="0" height="30" allowevents="true" |
|
20 onclick="eventReceived('clickbutton1'); return false;"/> |
|
21 <xul:button width="100" left="70" top="0" height="30" |
|
22 onclick="eventReceived('clickbutton2'); return false;"/> |
|
23 </xul:stack> |
|
24 </xbl:content> |
|
25 </xbl:binding> |
|
26 </xbl:bindings> |
|
27 |
|
28 <toolbarbutton type="menu" id="toolbarmenu" height="200" style="-moz-binding: url(#menu);"> |
|
29 <menupopup id="menupopup" onpopupshowing="eventReceived('popupshowing'); return false;"/> |
|
30 </toolbarbutton> |
|
31 |
|
32 <!-- test results are displayed in the html:body --> |
|
33 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> |
|
34 |
|
35 <script type="application/javascript"> |
|
36 <![CDATA[ |
|
37 |
|
38 SimpleTest.waitForExplicitFinish(); |
|
39 SimpleTest.waitForFocus(test); |
|
40 |
|
41 // Tests that mouse events are correctly dispatched to <toolbarbutton type="menu"/> |
|
42 function test() { |
|
43 disableNonTestMouseEvents(true); |
|
44 nextTest(); |
|
45 } |
|
46 |
|
47 let tests = [ |
|
48 // Click on the toolbarbutton itself - should call popupshowing |
|
49 function() synthesizeMouse($("toolbarmenu"), 10, 50, {}, window), |
|
50 |
|
51 // Click on button1 which has allowevents="true" - should call clickbutton1 |
|
52 function() synthesizeMouse($("toolbarmenu"), 10, 15, {}, window), |
|
53 |
|
54 // Click on button2 where it intersects with button1 - should call popupshowing |
|
55 function() synthesizeMouse($("toolbarmenu"), 85, 15, {}, window), |
|
56 |
|
57 // Click on button2 outside of intersection - should call popupshowing |
|
58 function() synthesizeMouse($("toolbarmenu"), 150, 15, {}, window) |
|
59 ]; |
|
60 |
|
61 function nextTest() { |
|
62 if (tests.length) { |
|
63 let func = tests.shift(); |
|
64 func(); |
|
65 SimpleTest.executeSoon(nextTest); |
|
66 } else { |
|
67 disableNonTestMouseEvents(false); |
|
68 SimpleTest.executeSoon(finishTest); |
|
69 } |
|
70 } |
|
71 |
|
72 function finishTest() { |
|
73 is(eventCount.clickbutton1, 1, "Correct number of clicks on button 1"); |
|
74 is(eventCount.clickbutton2, 0, "Correct number of clicks on button 2"); |
|
75 is(eventCount.popupshowing, 3, "Correct number of popupshowing events received"); |
|
76 |
|
77 SimpleTest.finish(); |
|
78 } |
|
79 |
|
80 let eventCount = { |
|
81 popupshowing: 0, |
|
82 clickbutton1: 0, |
|
83 clickbutton2: 0 |
|
84 }; |
|
85 |
|
86 function eventReceived(eventName) { |
|
87 eventCount[eventName]++; |
|
88 } |
|
89 |
|
90 ]]> |
|
91 </script> |
|
92 </window> |