1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/xul/templates/tests/chrome/test_tmpl_menuelementrecursive.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,121 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 + 1.8 +<!-- 1.9 + menu element recursive 1.10 +--> 1.11 + 1.12 +<window title="XUL Template Tests" width="500" height="600" 1.13 + onload="test_template()" 1.14 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.15 + <script type="application/javascript" 1.16 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.17 + 1.18 + <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> 1.19 + 1.20 + <data id="output"> 1.21 + <menupopup> 1.22 + <menuitem id="http://www.some-fictitious-zoo.com/arachnids" label="Arachnids" container="true" empty="false"/> 1.23 + <menu step="-2" id="http://www.some-fictitious-zoo.com/birds" label="Birds" container="true" empty="false"/> 1.24 + <menu step="2" id="http://www.some-fictitious-zoo.com/birds" label="Birds" container="true" empty="false" open="true"> 1.25 + <menupopup> 1.26 + <menuitem step="4" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/> 1.27 + <menuitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/> 1.28 + <menuitem step="-5" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/> 1.29 + <menuitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/> 1.30 + <menuitem step="3" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/> 1.31 + <menuitem id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/> 1.32 + </menupopup> 1.33 + </menu> 1.34 + <menuitem id="http://www.some-fictitious-zoo.com/crustaceans" label="Crustaceans" container="true" empty="true"/> 1.35 + <menuitem id="http://www.some-fictitious-zoo.com/fish" label="Fish" container="true" empty="false"/> 1.36 + <menuitem id="http://www.some-fictitious-zoo.com/mammals" label="Mammals" container="true" empty="false"/> 1.37 + <menuitem id="http://www.some-fictitious-zoo.com/reptiles" label="Reptiles" container="true" empty="false"/> 1.38 + </menupopup> 1.39 + </data> 1.40 + 1.41 +<script src="templates_shared.js"/> 1.42 + 1.43 +<script> 1.44 +<![CDATA[ 1.45 +SimpleTest.waitForExplicitFinish(); 1.46 + 1.47 +var testid ="menu element recursive"; 1.48 +var queryType = "rdf"; 1.49 +var isTreeBuilder = false; 1.50 +var needsOpen = true; 1.51 +var notWorkingYet = false; 1.52 +var notWorkingYetDynamic = false; 1.53 +var expectedOutput = document.getElementById("output"); 1.54 + 1.55 +var changes = [ 1.56 + // step 1 1.57 + function(targetds, root) { 1.58 + // nothing should change at this step as the submenu is not open 1.59 + var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin'); 1.60 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.61 + RDF.GetLiteral('Emperor Penguin'), true); 1.62 + var container = ContainerUtils.MakeSeq(targetds, 1.63 + RDF.GetResource(ZOO_NS + 'birds')); 1.64 + container.AppendElement(newnode); 1.65 + }, 1.66 + // step 2 1.67 + function(targetds, root) { 1.68 + // open the submenu 1.69 + root.lastChild.firstChild.nextSibling.open = true; 1.70 + }, 1.71 + // step 3 1.72 + function(targetds, root) { 1.73 + var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'); 1.74 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.75 + RDF.GetLiteral('Archaeopteryx'), true); 1.76 + var container = ContainerUtils.MakeSeq(targetds, 1.77 + RDF.GetResource(ZOO_NS + 'birds')); 1.78 + container.InsertElementAt(newnode, '4', true); 1.79 + root.lastChild.firstChild.nextSibling.open = true; 1.80 + }, 1.81 + // step 4 1.82 + function(targetds, root) { 1.83 + var newnode = RDF.GetResource(ZOO_NS + 'birds/wren'); 1.84 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.85 + RDF.GetLiteral('Wren'), true); 1.86 + var container = ContainerUtils.MakeSeq(targetds, 1.87 + RDF.GetResource(ZOO_NS + 'birds')); 1.88 + container.InsertElementAt(newnode, '1', true); 1.89 + root.lastChild.firstChild.nextSibling.open = true; 1.90 + }, 1.91 + // step 5 1.92 + function(targetds, root) { 1.93 + var container = ContainerUtils.MakeSeq(targetds, 1.94 + RDF.GetResource(ZOO_NS + 'birds')); 1.95 + var removednode = container.RemoveElementAt('3', true); 1.96 + targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.97 + RDF.GetLiteral('Barn Owl'), true); 1.98 + root.lastChild.firstChild.nextSibling.open = true; 1.99 + } 1.100 +]; 1.101 +]]> 1.102 +</script> 1.103 + 1.104 +<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"> 1.105 +<template> 1.106 +<rule iscontainer="true" zoo:name="Birds" xmlns:zoo="http://www.some-fictitious-zoo.com/rdf#"> 1.107 +<menupopup> 1.108 +<menu uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/> 1.109 +</menupopup> 1.110 +</rule> 1.111 +<rule parent="button"> 1.112 +<menupopup> 1.113 +<menuitem uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/> 1.114 +</menupopup> 1.115 +</rule> 1.116 +<rule parent="menu"> 1.117 +<menupopup> 1.118 +<menuitem uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/> 1.119 +</menupopup> 1.120 +</rule> 1.121 +</template> 1.122 +</button> 1.123 + 1.124 +</window>