content/xul/templates/tests/chrome/test_tmpl_parentconditions.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <?xml version="1.0"?>
     2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     5 <!--
     6   parent - conditions
     7 -->
     9 <window title="XUL Template Tests" width="500" height="600"
    10         onload="test_template();"
    11         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    12   <script type="application/javascript"
    13           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    15   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
    17   <data id="output">
    18     <box step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
    19       <label value="Birds"/>
    20       <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
    21       <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
    22     </box>
    23     <box step="1" id="http://www.some-fictitious-zoo.com/insects">
    24       <label value="Insects"/>
    25     </box>
    26     <box id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
    27       <label value="Crustaceans"/>
    28     </box>
    29     <box id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
    30       <label value="Mammals"/>
    31       <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
    32       <button step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" label="Koala"/>
    33       <button id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
    34       <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
    35       <button id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
    36       <button id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
    37     </box>
    38   </data>
    40 <script src="templates_shared.js"/>
    42 <script>
    43 <![CDATA[
    44 SimpleTest.waitForExplicitFinish();
    46 var testid ="parent - conditions";
    47 var queryType = "rdf";
    48 var isTreeBuilder = false;
    49 var needsOpen = false;
    50 var notWorkingYet = false;
    51 var notWorkingYetDynamic = false;
    52 var expectedOutput = document.getElementById("output");
    54 var changes = [
    55   // step 1
    56   function(targetds, root) {
    57     var newnode = RDF.GetResource(ZOO_NS + 'insects');
    58     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
    59                     RDF.GetLiteral('Insects'), true);
    60     var container = ContainerUtils.MakeSeq(targetds,
    61                       RDF.GetResource(ZOO_NS + 'all-animals'));
    62     container.InsertElementAt(newnode, '3', true);
    63   },
    64   // step 2
    65   function(targetds, root) {
    66     var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
    67     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
    68                     RDF.GetLiteral('Koala'), true);
    69     var container = ContainerUtils.MakeSeq(targetds,
    70                       RDF.GetResource(ZOO_NS + 'mammals'));
    71     container.InsertElementAt(newnode, '4', true);
    72   },
    73   // step 3
    74   function(targetds, root) {
    75     var container = ContainerUtils.MakeSeq(targetds,
    76                       RDF.GetResource(ZOO_NS + 'all-animals'));
    77     var removednode = container.RemoveElementAt('2', true);
    78     targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
    79                       RDF.GetLiteral('Birds'), true);
    80   }
    81 ];
    82 ]]>
    83 </script>
    85 <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">
    86 <template>
    87 <query>
    88 <content uri="?uri"/>
    89 <member container="?uri" child="?parent"/>
    90 <triple subject="?parent" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
    91 </query>
    92 <rule>
    93 <conditions parent="box">
    94 <where subject="?name" rel="contains" value="a"/>
    95 </conditions>
    96 <action>
    97 <button uri="?parent" label="?name"/>
    98 </action>
    99 </rule>
   100 <rule>
   101 <conditions>
   102 <where subject="?name" rel="equals" multiple="true" value="Mammals,Crustaceans,Birds,Insects"/>
   103 </conditions>
   104 <action>
   105 <box uri="?parent">
   106 <label value="?name"/>
   107 </box>
   108 </action>
   109 </rule>
   110 </template>
   111 </vbox>
   113 </window>

mercurial