|
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 <?xml-stylesheet href="data:text/css,window > |people { display: none }" type="text/css"?> |
|
5 <!-- |
|
6 XUL Widget Test for tabindex |
|
7 --> |
|
8 <window title="tabindex" width="500" height="600" |
|
9 onfocus="runTest()" |
|
10 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
11 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
12 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
13 |
|
14 <people id="famouspeople" xmlns=""> |
|
15 <person name="Napoleon Bonaparte" gender="male"/> |
|
16 <person name="Cleopatra" gender="female"/> |
|
17 <person name="Julius Caesar" gender="male"/> |
|
18 <person name="Ferdinand Magellan" gender="male"/> |
|
19 <person name="Laura Secord" gender="female"/> |
|
20 </people> |
|
21 |
|
22 <tree id="tree" datasources="#famouspeople" ref="*" querytype="xml" flex="1"> |
|
23 <treecols> |
|
24 <treecol label="Name" flex="1" sort="?name"/> |
|
25 <treecol label="Gender" flex="1" sort="?gender"/> |
|
26 </treecols> |
|
27 <template> |
|
28 <query/> |
|
29 <rule> |
|
30 <action> |
|
31 <treechildren id="treechildren-strings"> |
|
32 <treeitem uri="?"> |
|
33 <treerow> |
|
34 <treecell label="?name"/> |
|
35 <treecell label="?gender"/> |
|
36 </treerow> |
|
37 </treeitem> |
|
38 </treechildren> |
|
39 </action> |
|
40 </rule> |
|
41 </template> |
|
42 </tree> |
|
43 |
|
44 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
45 <p id="display"></p> |
|
46 <div id="content" style="display: none"> |
|
47 </div> |
|
48 <pre id="test"> |
|
49 </pre> |
|
50 </body> |
|
51 |
|
52 <script> |
|
53 <![CDATA[ |
|
54 |
|
55 SimpleTest.waitForExplicitFinish(); |
|
56 |
|
57 function runTest() |
|
58 { |
|
59 var tree = $("tree"); |
|
60 var col = tree.columns[0].element; |
|
61 synthesizeMouse(col, 12, 2, { }); |
|
62 checkRowOrder(tree, ["Cleopatra", "Ferdinand Magellan", "Julius Caesar", "Laura Secord", "Napoleon Bonaparte"], "acsending"); |
|
63 |
|
64 synthesizeMouse(col, 12, 2, { }); |
|
65 checkRowOrder(tree, ["Napoleon Bonaparte", "Laura Secord", "Julius Caesar", "Ferdinand Magellan", "Cleopatra"], "descending"); |
|
66 |
|
67 synthesizeMouse(col, 12, 2, { }); |
|
68 checkRowOrder(tree, ["Napoleon Bonaparte", "Laura Secord", "Julius Caesar", "Ferdinand Magellan", "Cleopatra"], "natural"); |
|
69 |
|
70 SimpleTest.finish(); |
|
71 } |
|
72 |
|
73 function checkRowOrder(tree, expected, testid) |
|
74 { |
|
75 var index = 0; |
|
76 var item = tree.firstChild.nextSibling.nextSibling.firstChild; |
|
77 while (item && index < expected.length) { |
|
78 if (item.firstChild.firstChild.getAttribute("label") != expected[index++]) |
|
79 break; |
|
80 item = item.nextSibling; |
|
81 } |
|
82 ok(index == expected.length && !item, testid + " row order"); |
|
83 } |
|
84 |
|
85 ]]> |
|
86 |
|
87 </script> |
|
88 |
|
89 </window> |