Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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"?>
5 <!--
6 tree element - query syntax recursive multiple rules
7 -->
9 <window title="XUL Template Tests" width="500" height="600"
10 onload="test_template();"
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>
15 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
17 <data id="output">
18 <treecols id="treecols" orient="horizontal">
19 <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
20 <treecol label="Species" ordinal="3"/>
21 </treecols>
22 <treechildren>
23 <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah">
24 <treerow>
25 <treecell label="Sarah"/>
26 <treecell/>
27 </treerow>
28 </treeitem>
29 <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
30 <treerow>
31 <treecell/>
32 <treecell label="Is this cool: Mammals?"/>
33 </treerow>
34 </treeitem>
35 <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" open="true">
36 <treerow>
37 <treecell/>
38 <treecell label="Is this cool: Mammals?"/>
39 </treerow>
40 <treechildren>
41 <treeitem id="http://www.some-fictitious-zoo.com/mammals/lion">
42 <treerow>
43 <treecell/>
44 <treecell label="Is this cool: Lion?"/>
45 </treerow>
46 </treeitem>
47 <treeitem id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">
48 <treerow>
49 <treecell label="HIPPOPOTAMUS"/>
50 <treecell/>
51 </treerow>
52 </treeitem>
53 <treeitem id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
54 <treerow>
55 <treecell/>
56 <treecell label="Is this cool: African Elephant?"/>
57 </treerow>
58 </treeitem>
59 <treeitem step="2" id="http://www.some-fictitious-zoo.com/mammals/koala">
60 <treerow>
61 <treecell/>
62 <treecell label="Is this cool: Koala?"/>
63 </treerow>
64 </treeitem>
65 <treeitem id="http://www.some-fictitious-zoo.com/mammals/llama">
66 <treerow>
67 <treecell/>
68 <treecell label="Is this cool: LLAMA?"/>
69 </treerow>
70 </treeitem>
71 <treeitem id="http://www.some-fictitious-zoo.com/mammals/polarbear">
72 <treerow>
73 <treecell/>
74 <treecell label="Is this cool: Polar Bear?"/>
75 </treerow>
76 </treeitem>
77 <treeitem id="http://www.some-fictitious-zoo.com/mammals/aardvark">
78 <treerow>
79 <treecell label="aardvark"/>
80 <treecell/>
81 </treerow>
82 </treeitem>
83 <treeitem id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
84 <treerow>
85 <treecell/>
86 <treecell label="Is this cool: Nine-banded Armadillo?"/>
87 </treerow>
88 </treeitem>
89 <treeitem id="http://www.some-fictitious-zoo.com/mammals/gorilla">
90 <treerow>
91 <treecell/>
92 <treecell label="Is this cool: Gorilla?"/>
93 </treerow>
94 </treeitem>
95 </treechildren>
96 </treeitem>
97 <treeitem step="-3" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
98 <treerow>
99 <treecell label="Crustaceans"/>
100 <treecell/>
101 </treerow>
102 </treeitem>
103 <treeitem step="3,-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false">
104 <treerow>
105 <treecell label="Crustaceans"/>
106 <treecell/>
107 </treerow>
108 </treeitem>
109 <treeitem step="5" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false" open="true">
110 <treerow>
111 <treecell label="Crustaceans"/>
112 <treecell/>
113 </treerow>
114 <treechildren>
115 <treeitem id="http://www.some-fictitious-zoo.com/crustaceans/lobster">
116 <treerow>
117 <treecell/>
118 <treecell label="Is this cool: Lobster?"/>
119 </treerow>
120 </treeitem>
121 <treeitem id="http://www.some-fictitious-zoo.com/crustaceans/crayfish">
122 <treerow>
123 <treecell label="Crayfish"/>
124 <treecell/>
125 </treerow>
126 </treeitem>
127 </treechildren>
128 </treeitem>
129 <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
130 <treerow>
131 <treecell label="Emu"/>
132 <treecell/>
133 </treerow>
134 </treeitem>
135 </treechildren>
136 </data>
138 <script src="templates_shared.js"/>
140 <script>
141 <![CDATA[
142 SimpleTest.waitForExplicitFinish();
144 var testid ="tree element - query syntax recursive multiple rules";
145 var queryType = "rdf";
146 var isTreeBuilder = false;
147 var needsOpen = false;
148 var notWorkingYet = false;
149 var notWorkingYetDynamic = true;
150 var expectedOutput = document.getElementById("output");
152 var changes = [
153 // step 1
154 function(targetds, root) {
155 if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
156 root.view.toggleOpenState(1);
157 expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/lion', true, true,
158 '1 matching rule 1');
159 expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/hippopotamus', true, true,
160 '1 matching rule 2');
161 expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/africanelephant', true, true,
162 '1 matching rule 1');
163 expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/llama', true, true,
164 '1 matching rule 1');
165 expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/polarbear', true, true,
166 '1 matching rule 1');
167 expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/aardvark', true, true,
168 '1 matching rule 2');
169 expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/ninebandedarmadillo', true, true,
170 '1 matching rule 1');
171 expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/gorilla', true, true,
172 '1 matching rule 1');
173 },
174 // step 2
175 function(targetds, root) {
176 var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
177 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
178 RDF.GetLiteral('Koala'), true);
179 var container = ContainerUtils.MakeSeq(targetds,
180 RDF.GetResource(ZOO_NS + 'mammals'));
181 container.InsertElementAt(newnode, '4', true);
182 expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/koala', true, true,
183 '1 matching rule 1');
184 },
185 // step 3
186 function(targetds, root) {
187 var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster');
188 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
189 RDF.GetLiteral('Lobster'), true);
190 var container = ContainerUtils.MakeSeq(targetds,
191 RDF.GetResource(ZOO_NS + 'crustaceans'));
192 container.AppendElement(newnode);
193 },
194 // step 4
195 function(targetds, root) {
196 var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/crayfish');
197 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
198 RDF.GetLiteral('Crayfish'), true);
199 var container = ContainerUtils.MakeSeq(targetds,
200 RDF.GetResource(ZOO_NS + 'crustaceans'));
201 container.AppendElement(newnode);
202 },
203 // step 5
204 function(targetds, root) {
205 if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
206 root.view.toggleOpenState(11);
207 expectConsoleMessage(ZOO_NS + 'crustaceans', ZOO_NS + 'crustaceans/lobster', true, true,
208 '1 matching rule 1');
209 expectConsoleMessage(ZOO_NS + 'crustaceans', ZOO_NS + 'crustaceans/crayfish', true, true,
210 '1 matching rule 2');
211 },
212 // step 6
213 function(targetds, root) {
214 if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
215 root.view.toggleOpenState(11);
216 },
217 // step 7
218 function(targetds, root) {
219 if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
220 root.view.toggleOpenState(1);
221 }
222 ];
223 ]]>
224 </script>
226 <tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true"
227 flags="logging" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" id="root">
228 <treecols orient="horizontal" id="treecols">
229 <treecol id="treecol" primary="true" label="Name"/>
230 <treecol label="Species"/>
231 </treecols>
232 <template id="template">
233 <query>
234 <content uri="?uri"/>
235 <member container="?uri" child="?child"/>
236 <triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
237 </query>
238 <rule>
239 <conditions>
240 <where subject="?name" rel="contains" value="l" ignorecase="true"/>
241 </conditions>
242 <action>
243 <treechildren>
244 <treeitem uri="?child">
245 <treerow>
246 <treecell/>
247 <treecell label="Is this cool: ?name^??"/>
248 </treerow>
249 </treeitem>
250 </treechildren>
251 </action>
252 </rule>
253 <rule>
254 <action>
255 <treechildren>
256 <treeitem uri="?child">
257 <treerow>
258 <treecell label="?name"/>
259 <treecell/>
260 </treerow>
261 </treeitem>
262 </treechildren>
263 </action>
264 </rule>
265 </template>
266 </tree>
268 </window>