|
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 <!-- |
|
6 menu element recursive |
|
7 --> |
|
8 |
|
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> |
|
14 |
|
15 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> |
|
16 |
|
17 <data id="output"> |
|
18 <menupopup> |
|
19 <menuitem id="http://www.some-fictitious-zoo.com/arachnids" label="Arachnids" container="true" empty="false"/> |
|
20 <menu step="-2" id="http://www.some-fictitious-zoo.com/birds" label="Birds" container="true" empty="false"/> |
|
21 <menu step="2" id="http://www.some-fictitious-zoo.com/birds" label="Birds" container="true" empty="false" open="true"> |
|
22 <menupopup> |
|
23 <menuitem step="4" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/> |
|
24 <menuitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/> |
|
25 <menuitem step="-5" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/> |
|
26 <menuitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/> |
|
27 <menuitem step="3" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/> |
|
28 <menuitem id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/> |
|
29 </menupopup> |
|
30 </menu> |
|
31 <menuitem id="http://www.some-fictitious-zoo.com/crustaceans" label="Crustaceans" container="true" empty="true"/> |
|
32 <menuitem id="http://www.some-fictitious-zoo.com/fish" label="Fish" container="true" empty="false"/> |
|
33 <menuitem id="http://www.some-fictitious-zoo.com/mammals" label="Mammals" container="true" empty="false"/> |
|
34 <menuitem id="http://www.some-fictitious-zoo.com/reptiles" label="Reptiles" container="true" empty="false"/> |
|
35 </menupopup> |
|
36 </data> |
|
37 |
|
38 <script src="templates_shared.js"/> |
|
39 |
|
40 <script> |
|
41 <![CDATA[ |
|
42 SimpleTest.waitForExplicitFinish(); |
|
43 |
|
44 var testid ="menu element recursive"; |
|
45 var queryType = "rdf"; |
|
46 var isTreeBuilder = false; |
|
47 var needsOpen = true; |
|
48 var notWorkingYet = false; |
|
49 var notWorkingYetDynamic = false; |
|
50 var expectedOutput = document.getElementById("output"); |
|
51 |
|
52 var changes = [ |
|
53 // step 1 |
|
54 function(targetds, root) { |
|
55 // nothing should change at this step as the submenu is not open |
|
56 var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin'); |
|
57 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
58 RDF.GetLiteral('Emperor Penguin'), true); |
|
59 var container = ContainerUtils.MakeSeq(targetds, |
|
60 RDF.GetResource(ZOO_NS + 'birds')); |
|
61 container.AppendElement(newnode); |
|
62 }, |
|
63 // step 2 |
|
64 function(targetds, root) { |
|
65 // open the submenu |
|
66 root.lastChild.firstChild.nextSibling.open = true; |
|
67 }, |
|
68 // step 3 |
|
69 function(targetds, root) { |
|
70 var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'); |
|
71 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
72 RDF.GetLiteral('Archaeopteryx'), true); |
|
73 var container = ContainerUtils.MakeSeq(targetds, |
|
74 RDF.GetResource(ZOO_NS + 'birds')); |
|
75 container.InsertElementAt(newnode, '4', true); |
|
76 root.lastChild.firstChild.nextSibling.open = true; |
|
77 }, |
|
78 // step 4 |
|
79 function(targetds, root) { |
|
80 var newnode = RDF.GetResource(ZOO_NS + 'birds/wren'); |
|
81 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
82 RDF.GetLiteral('Wren'), true); |
|
83 var container = ContainerUtils.MakeSeq(targetds, |
|
84 RDF.GetResource(ZOO_NS + 'birds')); |
|
85 container.InsertElementAt(newnode, '1', true); |
|
86 root.lastChild.firstChild.nextSibling.open = true; |
|
87 }, |
|
88 // step 5 |
|
89 function(targetds, root) { |
|
90 var container = ContainerUtils.MakeSeq(targetds, |
|
91 RDF.GetResource(ZOO_NS + 'birds')); |
|
92 var removednode = container.RemoveElementAt('3', true); |
|
93 targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
94 RDF.GetLiteral('Barn Owl'), true); |
|
95 root.lastChild.firstChild.nextSibling.open = true; |
|
96 } |
|
97 ]; |
|
98 ]]> |
|
99 </script> |
|
100 |
|
101 <button xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" type="menu" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/all-animals"> |
|
102 <template> |
|
103 <rule iscontainer="true" zoo:name="Birds" xmlns:zoo="http://www.some-fictitious-zoo.com/rdf#"> |
|
104 <menupopup> |
|
105 <menu uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/> |
|
106 </menupopup> |
|
107 </rule> |
|
108 <rule parent="button"> |
|
109 <menupopup> |
|
110 <menuitem uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/> |
|
111 </menupopup> |
|
112 </rule> |
|
113 <rule parent="menu"> |
|
114 <menupopup> |
|
115 <menuitem uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/> |
|
116 </menupopup> |
|
117 </rule> |
|
118 </template> |
|
119 </button> |
|
120 |
|
121 </window> |