toolkit/content/tests/chrome/test_button.xul

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:d5471caeeb27
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 button
6 -->
7 <window title="Button Test"
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script type="application/javascript"
10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
11 <script type="application/javascript"
12 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
13
14 <button id="one" label="One" />
15 <button id="two" label="Two"/>
16 <hbox>
17 <button id="three" label="Three" open="true"/>
18 </hbox>
19 <hbox>
20 <button id="four" type="menu" label="Four"/>
21 <button id="five" type="panel" label="Five"/>
22 <button id="six" label="Six"/>
23 </hbox>
24
25 <!-- test results are displayed in the html:body -->
26 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
27
28 <script type="application/javascript">
29 <![CDATA[
30
31 SimpleTest.waitForExplicitFinish();
32
33 function test_button()
34 {
35 synthesizeMouseExpectEvent($("one"), 2, 2, {}, $("one"), "command", "button press");
36 $("one").focus();
37 synthesizeKeyExpectEvent("VK_SPACE", { }, $("one"), "command", "key press");
38 $("two").disabled = true;
39 synthesizeMouseExpectEvent($("two"), 2, 2, {}, $("two"), "!command", "button press command when disabled");
40 synthesizeMouseExpectEvent($("two"), 2, 2, {}, $("two"), "click", "button press click when disabled");
41
42 if (navigator.platform.indexOf("Mac") == -1) {
43 $("one").focus();
44 synthesizeKey("VK_DOWN", { });
45 is(document.activeElement, $("three"), "key cursor down on button");
46
47 synthesizeKey("VK_RIGHT", { });
48 is(document.activeElement, $("four"), "key cursor right on button");
49 synthesizeKey("VK_DOWN", { });
50 is(document.activeElement, $("four"), "key cursor down on menu button");
51 $("five").focus();
52 synthesizeKey("VK_DOWN", { });
53 is(document.activeElement, $("five"), "key cursor down on panel button");
54
55 $("three").focus();
56 synthesizeKey("VK_UP", { });
57 is(document.activeElement, $("one"), "key cursor up on button");
58 }
59
60 $("two").focus();
61 ok(document.activeElement != $("two"), "focus disabled button");
62
63 SimpleTest.finish();
64 }
65
66 SimpleTest.waitForFocus(test_button);
67
68 ]]>
69 </script>
70
71 </window>

mercurial