|
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 basic properties - this test checks that the basic |
|
6 properties defined in general.xml and inherited by a number of elements |
|
7 work properly. |
|
8 --> |
|
9 <window title="Basic Properties Test" |
|
10 onload="setTimeout(test_props, 0);" |
|
11 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
12 <script type="application/javascript" |
|
13 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
14 <script type="application/javascript" |
|
15 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
16 |
|
17 <command id="cmd_nothing"/> |
|
18 <command id="cmd_action"/> |
|
19 |
|
20 <button id="button" label="Button" accesskey="B" |
|
21 crop="end" image="happy.png" command="cmd_nothing"/> |
|
22 <checkbox id="checkbox" label="Checkbox" accesskey="B" |
|
23 crop="end" image="happy.png" command="cmd_nothing"/> |
|
24 <radiogroup> |
|
25 <radio id="radio" label="Radio Button" value="rb1" accesskey="B" |
|
26 crop="end" image="happy.png" command="cmd_nothing"/> |
|
27 </radiogroup> |
|
28 |
|
29 <!-- test results are displayed in the html:body --> |
|
30 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> |
|
31 |
|
32 <!-- test code goes here --> |
|
33 <script type="application/javascript"><![CDATA[ |
|
34 |
|
35 SimpleTest.waitForExplicitFinish(); |
|
36 |
|
37 function test_props() |
|
38 { |
|
39 test_props_forelement($("button"), "Button", null); |
|
40 test_props_forelement($("checkbox"), "Checkbox", null); |
|
41 test_props_forelement($("radio"), "Radio Button", "rb1"); |
|
42 |
|
43 SimpleTest.finish(); |
|
44 } |
|
45 |
|
46 function test_props_forelement(element, label, value) |
|
47 { |
|
48 // check the initial values |
|
49 is(element.label, label, "element label"); |
|
50 if (value) |
|
51 is(element.value, value, "element value"); |
|
52 is(element.accessKey, "B", "element accessKey"); |
|
53 is(element.crop, "end", "element crop"); |
|
54 is(element.image, "happy.png", "element image"); |
|
55 is(element.command, "cmd_nothing", "element command"); |
|
56 ok(element.tabIndex === 0, "element tabIndex"); |
|
57 |
|
58 synthesizeMouseExpectEvent(element, 4, 4, { }, $("cmd_nothing"), "command", "element"); |
|
59 |
|
60 // make sure that setters return the value |
|
61 is(element.label = "Label", "Label", "element label setter return"); |
|
62 if (value) |
|
63 is(element.value = "lb", "lb", "element value setter return"); |
|
64 is(element.accessKey = "L", "L", "element accessKey setter return"); |
|
65 is(element.crop = "start", "start", "element crop setter return"); |
|
66 is(element.image = "sad.png", "sad.png", "element image setter return"); |
|
67 is(element.command = "cmd_action", "cmd_action", "element command setter return"); |
|
68 |
|
69 // check the value after it was changed |
|
70 is(element.label, "Label", "element label after set"); |
|
71 if (value) |
|
72 is(element.value, "lb", "element value after set"); |
|
73 is(element.accessKey, "L", "element accessKey after set"); |
|
74 is(element.crop, "start", "element crop after set"); |
|
75 is(element.image, "sad.png", "element image after set"); |
|
76 is(element.command, "cmd_action", "element command after set"); |
|
77 |
|
78 synthesizeMouseExpectEvent(element, 4, 4, { }, $("cmd_action"), "command", "element"); |
|
79 |
|
80 // check that clicks on disabled items don't fire a command event |
|
81 ok((element.disabled = true) === true, "element disabled setter return"); |
|
82 ok(element.disabled === true, "element disabled after set"); |
|
83 synthesizeMouseExpectEvent(element, 4, 4, { }, $("cmd_action"), "!command", "element"); |
|
84 |
|
85 element.disabled = false; |
|
86 } |
|
87 |
|
88 ]]> |
|
89 </script> |
|
90 |
|
91 </window> |