1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/xul/templates/tests/chrome/test_tmpl_querysettwo.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,117 @@ 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 + queryset - 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 + <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/> 1.22 + <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/> 1.23 + <checkbox step="-4" 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 + <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/> 1.26 + <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/> 1.27 + </data> 1.28 + 1.29 +<script src="templates_shared.js"/> 1.30 + 1.31 +<script> 1.32 +<![CDATA[ 1.33 +SimpleTest.waitForExplicitFinish(); 1.34 + 1.35 +var testid ="queryset - two"; 1.36 +var queryType = "rdf"; 1.37 +var isTreeBuilder = false; 1.38 +var needsOpen = false; 1.39 +var notWorkingYet = false; 1.40 +var notWorkingYetDynamic = false; 1.41 +var expectedOutput = document.getElementById("output"); 1.42 + 1.43 +var changes = [ 1.44 + // step 1 1.45 + function(targetds, root) { 1.46 + var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin'); 1.47 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.48 + RDF.GetLiteral('Emperor Penguin'), true); 1.49 + var container = ContainerUtils.MakeSeq(targetds, 1.50 + RDF.GetResource(ZOO_NS + 'birds')); 1.51 + container.AppendElement(newnode); 1.52 + expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/emperorpenguin', true, true, 1.53 + '2 matching rule 1'); 1.54 + }, 1.55 + // step 2 1.56 + function(targetds, root) { 1.57 + var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'); 1.58 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.59 + RDF.GetLiteral('Archaeopteryx'), true); 1.60 + var container = ContainerUtils.MakeSeq(targetds, 1.61 + RDF.GetResource(ZOO_NS + 'birds')); 1.62 + container.InsertElementAt(newnode, '4', true); 1.63 + expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/archaeopteryx', true, true, 1.64 + '2 matching rule 1'); 1.65 + }, 1.66 + // step 3 1.67 + function(targetds, root) { 1.68 + var newnode = RDF.GetResource(ZOO_NS + 'birds/wren'); 1.69 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.70 + RDF.GetLiteral('Wren'), true); 1.71 + var container = ContainerUtils.MakeSeq(targetds, 1.72 + RDF.GetResource(ZOO_NS + 'birds')); 1.73 + container.InsertElementAt(newnode, '1', true); 1.74 + expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/wren', true, true, 1.75 + '2 matching rule 1'); 1.76 + }, 1.77 + // step 4 1.78 + function(targetds, root) { 1.79 + var container = ContainerUtils.MakeSeq(targetds, 1.80 + RDF.GetResource(ZOO_NS + 'birds')); 1.81 + var removednode = container.RemoveElementAt('3', true); 1.82 + targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.83 + RDF.GetLiteral('Barn Owl'), true); 1.84 + expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/barnowl', false, false, 1.85 + '2 (active query is 1)'); 1.86 + expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/barnowl', false, true, 1.87 + '1 (no new active query)'); 1.88 + } 1.89 +]; 1.90 +]]> 1.91 +</script> 1.92 + 1.93 +<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" flags="logging" 1.94 + datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds"> 1.95 +<template> 1.96 +<queryset> 1.97 +<query> 1.98 +<content uri="?uri"/> 1.99 +<member container="?uri" child="?animal"/> 1.100 +<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="Barn Owl"/> 1.101 +<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/> 1.102 +</query> 1.103 +<action> 1.104 +<checkbox uri="?animal" label="?name"/> 1.105 +</action> 1.106 +</queryset> 1.107 +<queryset> 1.108 +<query> 1.109 +<content uri="?uri"/> 1.110 +<member container="?uri" child="?animal"/> 1.111 +<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/> 1.112 +</query> 1.113 +<action> 1.114 +<button uri="?animal" label="?name"/> 1.115 +</action> 1.116 +</queryset> 1.117 +</template> 1.118 +</vbox> 1.119 + 1.120 +</window>