1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/xul/templates/tests/chrome/test_tmpl_parentsimplesyntax.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,110 @@ 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 + parent - simple syntax 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 + <hbox step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false"> 1.22 + <label value="Birds"/> 1.23 + <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/> 1.24 + <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/> 1.25 + <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/> 1.26 + </hbox> 1.27 + <hbox step="1" id="http://www.some-fictitious-zoo.com/insects"> 1.28 + <label value="Insects"/> 1.29 + </hbox> 1.30 + <hbox id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true"> 1.31 + <label value="Crustaceans"/> 1.32 + </hbox> 1.33 + <hbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false"> 1.34 + <label value="Mammals"/> 1.35 + <button id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/> 1.36 + <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/> 1.37 + <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/> 1.38 + <button step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" label="Koala"/> 1.39 + <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/> 1.40 + <button id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/> 1.41 + <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/> 1.42 + <button id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/> 1.43 + <button id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/> 1.44 + </hbox> 1.45 + </data> 1.46 + 1.47 +<script src="templates_shared.js"/> 1.48 + 1.49 +<script> 1.50 +<![CDATA[ 1.51 +SimpleTest.waitForExplicitFinish(); 1.52 + 1.53 +var testid ="parent - simple syntax"; 1.54 +var queryType = "rdf"; 1.55 +var isTreeBuilder = false; 1.56 +var needsOpen = false; 1.57 +var notWorkingYet = false; 1.58 +var notWorkingYetDynamic = false; 1.59 +var expectedOutput = document.getElementById("output"); 1.60 + 1.61 +var changes = [ 1.62 + // step 1 1.63 + function(targetds, root) { 1.64 + var newnode = RDF.GetResource(ZOO_NS + 'insects'); 1.65 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.66 + RDF.GetLiteral('Insects'), true); 1.67 + var container = ContainerUtils.MakeSeq(targetds, 1.68 + RDF.GetResource(ZOO_NS + 'all-animals')); 1.69 + container.InsertElementAt(newnode, '3', true); 1.70 + }, 1.71 + // step 2 1.72 + function(targetds, root) { 1.73 + var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala'); 1.74 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.75 + RDF.GetLiteral('Koala'), true); 1.76 + var container = ContainerUtils.MakeSeq(targetds, 1.77 + RDF.GetResource(ZOO_NS + 'mammals')); 1.78 + container.InsertElementAt(newnode, '4', true); 1.79 + }, 1.80 + // step 3 1.81 + function(targetds, root) { 1.82 + var container = ContainerUtils.MakeSeq(targetds, 1.83 + RDF.GetResource(ZOO_NS + 'all-animals')); 1.84 + var removednode = container.RemoveElementAt('2', true); 1.85 + targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.86 + RDF.GetLiteral('Birds'), true); 1.87 + } 1.88 +]; 1.89 +]]> 1.90 +</script> 1.91 + 1.92 +<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/all-animals"> 1.93 +<template member="?parent"> 1.94 +<rule parent="hbox"> 1.95 +<button uri="?parent" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/> 1.96 +</rule> 1.97 +<rule> 1.98 +<conditions> 1.99 +<content uri="?uri"/> 1.100 +<member container="?uri" child="?parent"/> 1.101 +<triple subject="?parent" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/> 1.102 +<where subject="?name" rel="equals" multiple="true" value="Mammals,Crustaceans,Birds,Insects"/> 1.103 +</conditions> 1.104 +<action> 1.105 +<hbox uri="?parent"> 1.106 +<label value="?name"/> 1.107 +</hbox> 1.108 +</action> 1.109 +</rule> 1.110 +</template> 1.111 +</vbox> 1.112 + 1.113 +</window>