content/xul/templates/tests/chrome/test_tmpl_treeelementtreecelltreebuilder.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_treeelementtreecelltreebuilder.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,133 @@
     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 +  tree element - treecell tree builder
    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 +    <treecols id="treecols" orient="horizontal">
    1.22 +      <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
    1.23 +      <treecol label="Species" ordinal="3"/>
    1.24 +    </treecols>
    1.25 +    <treechildren>
    1.26 +      <treeitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
    1.27 +        <treerow>
    1.28 +          <treecell label="Wren"/>
    1.29 +          <treecell/>
    1.30 +        </treerow>
    1.31 +      </treeitem>
    1.32 +      <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
    1.33 +        <treerow>
    1.34 +          <treecell label="Emu"/>
    1.35 +          <treecell label="Dromaius novaehollandiae"/>
    1.36 +        </treerow>
    1.37 +      </treeitem>
    1.38 +      <treeitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
    1.39 +        <treerow>
    1.40 +          <treecell label="Barn Owl"/>
    1.41 +          <treecell label="Tyto alba"/>
    1.42 +        </treerow>
    1.43 +      </treeitem>
    1.44 +      <treeitem id="http://www.some-fictitious-zoo.com/birds/raven">
    1.45 +        <treerow>
    1.46 +          <treecell label="Raven"/>
    1.47 +          <treecell label="Corvus corax"/>
    1.48 +        </treerow>
    1.49 +      </treeitem>
    1.50 +      <treeitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
    1.51 +        <treerow>
    1.52 +          <treecell label="Archaeopteryx"/>
    1.53 +          <treecell/>
    1.54 +        </treerow>
    1.55 +      </treeitem>
    1.56 +      <treeitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
    1.57 +        <treerow>
    1.58 +          <treecell label="Emperor Penguin"/>
    1.59 +          <treecell/>
    1.60 +        </treerow>
    1.61 +      </treeitem>
    1.62 +    </treechildren>
    1.63 +  </data>
    1.64 +
    1.65 +<script src="templates_shared.js"/>
    1.66 +
    1.67 +<script>
    1.68 +<![CDATA[
    1.69 +SimpleTest.waitForExplicitFinish();
    1.70 +
    1.71 +var testid ="tree element - treecell tree builder";
    1.72 +var queryType = "rdf";
    1.73 +var isTreeBuilder = true;
    1.74 +var needsOpen = false;
    1.75 +var notWorkingYet = false;
    1.76 +var notWorkingYetDynamic = true;
    1.77 +var expectedOutput = document.getElementById("output");
    1.78 +
    1.79 +var changes = [
    1.80 +  // step 1
    1.81 +  function(targetds, root) {
    1.82 +    var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
    1.83 +    targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
    1.84 +                    RDF.GetLiteral('Emperor Penguin'), true);
    1.85 +    var container = ContainerUtils.MakeSeq(targetds,
    1.86 +                      RDF.GetResource(ZOO_NS + 'birds'));
    1.87 +    container.AppendElement(newnode);
    1.88 +  },
    1.89 +  // step 2
    1.90 +  function(targetds, root) {
    1.91 +    var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
    1.92 +    targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
    1.93 +                    RDF.GetLiteral('Archaeopteryx'), true);
    1.94 +    var container = ContainerUtils.MakeSeq(targetds,
    1.95 +                      RDF.GetResource(ZOO_NS + 'birds'));
    1.96 +    container.InsertElementAt(newnode, '4', true);
    1.97 +  },
    1.98 +  // step 3
    1.99 +  function(targetds, root) {
   1.100 +    var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
   1.101 +    targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
   1.102 +                    RDF.GetLiteral('Wren'), true);
   1.103 +    var container = ContainerUtils.MakeSeq(targetds,
   1.104 +                      RDF.GetResource(ZOO_NS + 'birds'));
   1.105 +    container.InsertElementAt(newnode, '1', true);
   1.106 +  },
   1.107 +  // step 4
   1.108 +  function(targetds, root) {
   1.109 +    var container = ContainerUtils.MakeSeq(targetds,
   1.110 +                      RDF.GetResource(ZOO_NS + 'birds'));
   1.111 +    var removednode = container.RemoveElementAt('3', true);
   1.112 +    targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
   1.113 +                      RDF.GetLiteral('Barn Owl'), true);
   1.114 +  }
   1.115 +];
   1.116 +]]>
   1.117 +</script>
   1.118 +
   1.119 +<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" flags="dont-build-content" id="root" ref="http://www.some-fictitious-zoo.com/birds">
   1.120 +<treecols orient="horizontal" id="treecols">
   1.121 +<treecol id="treecol" primary="true" label="Name" ordinal="1"/>
   1.122 +<treecol label="Species" ordinal="3"/>
   1.123 +</treecols>
   1.124 +<template id="template">
   1.125 +<treechildren id="treechildren">
   1.126 +<treeitem uri="rdf:*">
   1.127 +<treerow>
   1.128 +<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
   1.129 +<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#species"/>
   1.130 +</treerow>
   1.131 +</treeitem>
   1.132 +</treechildren>
   1.133 +</template>
   1.134 +</tree>
   1.135 +
   1.136 +</window>

mercurial