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