toolkit/content/tests/chrome/test_sorttemplate.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial