1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/xul/templates/tests/chrome/test_tmpl_wherecontainstwo.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 + where - contains two 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 + <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/> 1.22 + <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/> 1.23 + <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/> 1.24 + <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/> 1.25 + <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/> 1.26 + </data> 1.27 + 1.28 +<script src="templates_shared.js"/> 1.29 + 1.30 +<script> 1.31 +<![CDATA[ 1.32 +SimpleTest.waitForExplicitFinish(); 1.33 + 1.34 +var testid ="where - contains two"; 1.35 +var queryType = "rdf"; 1.36 +var isTreeBuilder = false; 1.37 +var needsOpen = false; 1.38 +var notWorkingYet = false; 1.39 +var notWorkingYetDynamic = false; 1.40 +var expectedOutput = document.getElementById("output"); 1.41 + 1.42 +var changes = [ 1.43 + // step 1 1.44 + function(targetds, root) { 1.45 + var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare'); 1.46 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.47 + RDF.GetLiteral('Arctic Hare'), true); 1.48 + var container = ContainerUtils.MakeSeq(targetds, 1.49 + RDF.GetResource(ZOO_NS + 'mammals')); 1.50 + container.AppendElement(newnode); 1.51 + }, 1.52 + // step 2 1.53 + function(targetds, root) { 1.54 + var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala'); 1.55 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.56 + RDF.GetLiteral('Koala'), true); 1.57 + var container = ContainerUtils.MakeSeq(targetds, 1.58 + RDF.GetResource(ZOO_NS + 'mammals')); 1.59 + container.InsertElementAt(newnode, '4', true); 1.60 + }, 1.61 + // step 3 1.62 + function(targetds, root) { 1.63 + var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra'); 1.64 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.65 + RDF.GetLiteral('Zebra'), true); 1.66 + var container = ContainerUtils.MakeSeq(targetds, 1.67 + RDF.GetResource(ZOO_NS + 'mammals')); 1.68 + container.InsertElementAt(newnode, '1', true); 1.69 + }, 1.70 + // step 4 1.71 + function(targetds, root) { 1.72 + var container = ContainerUtils.MakeSeq(targetds, 1.73 + RDF.GetResource(ZOO_NS + 'mammals')); 1.74 + var removednode = container.RemoveElementAt('4', true); 1.75 + targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.76 + RDF.GetLiteral('African Elephant'), true); 1.77 + }, 1.78 + // step 5 1.79 + function(targetds, root) { 1.80 + var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant'); 1.81 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.82 + RDF.GetLiteral('African Elephant'), true); 1.83 + var container = ContainerUtils.MakeSeq(targetds, 1.84 + RDF.GetResource(ZOO_NS + 'mammals')); 1.85 + container.AppendElement(newnode); 1.86 + }, 1.87 + // step 6 1.88 + function(targetds, root) { 1.89 + targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'), 1.90 + RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'), 1.91 + RDF.GetLiteral('8'), true); 1.92 + } 1.93 +]; 1.94 +]]> 1.95 +</script> 1.96 + 1.97 +<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals"> 1.98 +<template id="template"> 1.99 +<query id="query"> 1.100 +<content uri="?uri"/> 1.101 +<member container="?uri" child="?animal"/> 1.102 +<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/> 1.103 +</query> 1.104 +<rule> 1.105 +<conditions id="conditions"> 1.106 +<where subject="?name" rel="contains" value="i"/> 1.107 +<where subject="?name" rel="contains" value="r"/> 1.108 +</conditions> 1.109 +<action id="action"> 1.110 +<label uri="?animal" value="?name"/> 1.111 +</action> 1.112 +</rule> 1.113 +</template> 1.114 +</vbox> 1.115 + 1.116 +</window>