content/xul/templates/tests/chrome/test_tmpl_querywithemptyconditions.xul

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

mercurial