summaryrefslogtreecommitdiffstats
path: root/dom/xul/templates/tests
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/xul/templates/tests
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/xul/templates/tests')
-rw-r--r--dom/xul/templates/tests/chrome/animals.rdf224
-rw-r--r--dom/xul/templates/tests/chrome/animals.sqlitebin0 -> 5120 bytes
-rw-r--r--dom/xul/templates/tests/chrome/animals.xml19
-rw-r--r--dom/xul/templates/tests/chrome/bug441785-1.rdf263
-rw-r--r--dom/xul/templates/tests/chrome/bug441785-2.rdf11
-rw-r--r--dom/xul/templates/tests/chrome/chrome.ini225
-rw-r--r--dom/xul/templates/tests/chrome/file_bug330010.rdf13
-rw-r--r--dom/xul/templates/tests/chrome/templates_shared.js488
-rw-r--r--dom/xul/templates/tests/chrome/test_bug329335.xul28
-rw-r--r--dom/xul/templates/tests/chrome/test_bug330010.xul51
-rw-r--r--dom/xul/templates/tests/chrome/test_bug397148.xul19
-rw-r--r--dom/xul/templates/tests/chrome/test_bug441785.xul148
-rw-r--r--dom/xul/templates/tests/chrome/test_bug476634.xul76
-rw-r--r--dom/xul/templates/tests/chrome/test_sortservice.xul70
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_bindingsextendedsyntax.xul73
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_bindingsmultiple.xul80
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_bindingsquerysyntax.xul73
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_bindingsreversed.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_bindingssameastriple.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_containerandmembervariablechanged.xul88
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_containervariablechanged.xul49
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_containmentattribute.xul71
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_defaultcontainervariableisuri.xul49
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_errors.xul280
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_extendedsyntax.xul95
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxemptyconditions.xul48
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxotherrefvariable.xul95
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxremoveunmatched.xul55
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxsimplevariablesubstitution.xul54
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxtworulesrecurse.xul81
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxusinganinterveningcontainer.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_extendedvariablesubstitution.xul54
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_gridelement.xul131
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_htmlelementextendedsyntaxwithbinding.xul114
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxrecursive.xul81
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxwithmultiplerules.xul102
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntax.xul81
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntaxusingatextnode.xul81
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_invalidqp.xul48
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_listboxelement.xul117
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_literalasmember.xul52
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_membervariablechanged.xul49
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_membervariablesubstitution.xul54
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_menuelement.xul90
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_menuelementrecursive.xul121
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_menulistelement.xul90
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainer.xul67
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainerisempty.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxisempty.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_noaction.xul48
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_noactionuriattribute.xul55
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_parentconditions.xul113
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_parentcontenttag.xul114
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_parentsimplesyntax.xul110
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_query3triples.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_query3tripleswherecontains.xul111
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querymember3tripleswhereequals.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querymemberandtwotriples.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querymembertriplemembertriple.xul64
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_queryresourcematch.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_queryreversetriple.xul53
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_queryselfwithtriple.xul51
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querysetone.xul95
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querysettwo.xul117
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querysettwowithcondition.xul149
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querysyntax.xul63
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerules.xul115
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulesfirstconditionall.xul71
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulestwoconditions.xul113
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querytripleandmembermerge.xul55
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querytripleobjecttosubject.xul67
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querytwomembers.xul107
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querytwomembersfiltered.xul54
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querytwotriples.xul55
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_queryupwardsmember.xul54
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_queryupwardsmembertripleandfilteringtriple.xul55
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_querywithemptyconditions.xul117
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_referenceasmember.xul65
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_regenerate.xul49
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_selfgenerationextendedsyntax.xul66
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_selfgenerationsimplesyntax.xul53
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainer.xul90
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainerwitharule.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilter.xul45
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithmultiplerules.xul97
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithrule.xul98
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxiteratingoverasinglevalue.xul86
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusinganinterveningcontainer.xul90
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingatextnode.xul50
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingcontainerasthegenerationelement.xul100
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingdontrecurse.xul52
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegeneration.xul109
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegenerationagain.xul64
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxwithtwovariablesused.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsatbeginningandend.xul45
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsubstitution.xul45
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionnovariable.xul45
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarkaspartofvariable.xul45
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarksubstitution.xul56
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutiontextandvariable.xul56
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariableandtextconcatenated.xul45
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariablesconcatenated.xul45
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortascendinginteger.xul70
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortascendingquerysyntax.xul114
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworulesquerysyntax.xul70
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithcontainerquerysyntax.xul80
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithdifferentcontainerquerysyntax.xul84
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortdescendingquerysyntax.xul114
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortquerymemberandtwotriples.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortresource2descendingsimplesyntax.xul52
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicateascendingquerysyntax.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicatedescendingquerysyntax.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortresourceascendingquerysyntax.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortresourcedescendingquerysyntax.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicateascendingquerysyntax.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicatedescendingquerysyntax.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sorttworesourcesasstringsettopredicatedescendingquerysyntax.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sorttworesourcessettopredicateascendingquerysyntax.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingquerysyntax.xul119
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingsimplesyntax.xul52
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesdescendingquerysyntax.xul64
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_sortunknownascendingquerysyntax.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_2.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_3.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_baddatasource.xul56
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_badquery.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_dynamicparameters.xul84
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_listbox.xul55
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_multiqueries.xul86
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_parameters.xul160
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_rule.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_simple.xul52
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_sortintegerasc.xul75
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_sortintegerdesc.xul78
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_sortstringasc.xul75
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_sortstringdesc.xul75
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_storage_tree.xul122
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntax.xul158
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxnotrecursive.xul145
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxnotrecursivetreebuilder.xul145
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursive.xul215
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerules.xul268
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerulestreebuilder.xul230
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivetreebuilder.xul215
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxtreebuilder.xul158
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxnotrecursive.xul136
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxnotrecursivetreebuilder.xul136
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxrecursive.xul206
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxrecursivetreebuilder.xul206
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecell.xul133
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecellsortascending.xul133
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecellsortascendingtreebuilder.xul133
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecelltreebuilder.xul133
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementtreeitemonly.xul96
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_treeelementtreeitemsortascending.xul96
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_twogenerationnodes.xul100
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereafterignorecase.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereafterlowercase.xul63
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereafternegation.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereafteruppercase.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherebeforeignorecase.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherebeforelowercase.xul64
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherebeforenegation.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherebeforeuppercase.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherecontains.xul113
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherecontainsignorecase.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnegation.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnumber.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnumberstring.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherecontainsresource.xul57
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherecontainstwo.xul113
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereendswith.xul57
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereendswithignorecase.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereendswithnegation.xul63
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequals.xul109
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequalsignorecase.xul57
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiple.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiplenegation.xul125
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiplenegationignorecase.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegation.xul63
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegationignorecase.xul63
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegationwrongcase.xul64
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequalsnumber.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequalsothervariable.xul65
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequalsresource.xul57
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequalssamevariable.xul64
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereequalswrongcase.xul55
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wheregreater.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wheregreaternegation.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wheregreaternegationstring.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wheregreaterstring.xul113
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_whereless.xul62
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherelessnegation.xul61
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherelessnegationstring.xul61
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherelessstring.xul62
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherenorel.xul69
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherenosubject.xul69
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherenovalue.xul69
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherestartswith.xul108
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherestartswithignorecase.xul58
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherestartswithmultiple.xul59
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherestartswithnegation.xul62
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherestartswithunknownvariable.xul55
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wherestartswithvariable.xul64
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wheresubjectequalsvariable.xul57
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_wheresubjectstartswithvariable.xul57
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerysimple.xul48
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassign.xul68
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassignmentandcondition.xul69
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassignmentandconditiondontrecurse.xul60
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithbindinginbindings.xul54
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithbindinginrule.xul64
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithdifferentmember.xul48
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithinlinedata.xul54
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithinlinedatawithmultiplequeries.xul71
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithmultiplequeries.xul70
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithothertypes.xul75
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithsort.xul51
-rw-r--r--dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithsortotherfield.xul51
220 files changed, 18097 insertions, 0 deletions
diff --git a/dom/xul/templates/tests/chrome/animals.rdf b/dom/xul/templates/tests/chrome/animals.rdf
new file mode 100644
index 000000000..06fee7ac5
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/animals.rdf
@@ -0,0 +1,224 @@
+<?xml version="1.0"?>
+
+<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:NC="http://home.netscape.com/NC-rdf#"
+ xmlns:ANIMALS="http://www.some-fictitious-zoo.com/rdf#">
+
+ <ANIMALS:Class RDF:about="http://www.some-fictitious-zoo.com/arachnids">
+ <ANIMALS:name>Arachnids</ANIMALS:name>
+ </ANIMALS:Class>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/arachnids/tarantula" ANIMALS:specimens="3">
+ <ANIMALS:name>Tarantula</ANIMALS:name>
+ <ANIMALS:species>Avicularia avicularia</ANIMALS:species>
+ </RDF:Description>
+
+ <ANIMALS:Class RDF:about="http://www.some-fictitious-zoo.com/birds">
+ <ANIMALS:name>Birds</ANIMALS:name>
+ <ANIMALS:keeper resource="http://www.some-fictitious-zoo.com/humans/sarah"/>
+ </ANIMALS:Class>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/birds/emu" ANIMALS:specimens="12">
+ <ANIMALS:name>Emu</ANIMALS:name>
+ <ANIMALS:species>Dromaius novaehollandiae</ANIMALS:species>
+ </RDF:Description>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/birds/barnowl" ANIMALS:specimens="4">
+ <ANIMALS:name>Barn Owl</ANIMALS:name>
+ <ANIMALS:species>Tyto alba</ANIMALS:species>
+ </RDF:Description>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/birds/raven" ANIMALS:specimens="0">
+ <ANIMALS:name>Raven</ANIMALS:name>
+ <ANIMALS:species>Corvus corax</ANIMALS:species>
+ </RDF:Description>
+
+ <ANIMALS:Class RDF:about="http://www.some-fictitious-zoo.com/crustaceans">
+ <ANIMALS:name>Crustaceans</ANIMALS:name>
+ <ANIMALS:keeper resource="http://www.some-fictitious-zoo.com/humans/robert"/>
+ </ANIMALS:Class>
+
+ <ANIMALS:Class RDF:about="http://www.some-fictitious-zoo.com/fish">
+ <ANIMALS:name>Fish</ANIMALS:name>
+ </ANIMALS:Class>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/fish/cod" ANIMALS:specimens="0">
+ <ANIMALS:name>Cod</ANIMALS:name>
+ <ANIMALS:species>Gadus morhua</ANIMALS:species>
+ </RDF:Description>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/fish/swordfish" ANIMALS:specimens="3">
+ <ANIMALS:name>Swordfish</ANIMALS:name>
+ <ANIMALS:species>Xiphias gladius</ANIMALS:species>
+ </RDF:Description>
+
+ <ANIMALS:Class RDF:about="http://www.some-fictitious-zoo.com/mammals">
+ <ANIMALS:name>Mammals</ANIMALS:name>
+ </ANIMALS:Class>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/lion">
+ <ANIMALS:name>Lion</ANIMALS:name>
+ <ANIMALS:species>Panthera leo</ANIMALS:species>
+ <ANIMALS:specimens NC:parseType="Integer">4</ANIMALS:specimens>
+ <ANIMALS:specimensAsString>4</ANIMALS:specimensAsString>
+ </RDF:Description>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/hippopotamus">
+ <ANIMALS:name>HIPPOPOTAMUS</ANIMALS:name>
+ <ANIMALS:species>Hippopotamus amphibius</ANIMALS:species>
+ <ANIMALS:specimens NC:parseType="Integer">2</ANIMALS:specimens>
+ <ANIMALS:specimensAsString>2</ANIMALS:specimensAsString>
+ </RDF:Description>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/africanelephant">
+ <ANIMALS:name>African Elephant</ANIMALS:name>
+ <ANIMALS:species>Loxodonta africana</ANIMALS:species>
+ <ANIMALS:specimens NC:parseType="Integer">14</ANIMALS:specimens>
+ <ANIMALS:specimensAsString>14</ANIMALS:specimensAsString>
+ </RDF:Description>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/llama">
+ <ANIMALS:name>LLAMA</ANIMALS:name>
+ <ANIMALS:species>Lama glama</ANIMALS:species>
+ <ANIMALS:specimens NC:parseType="Integer">5</ANIMALS:specimens>
+ <ANIMALS:specimensAsString>5</ANIMALS:specimensAsString>
+ </RDF:Description>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/polarbear">
+ <ANIMALS:name>Polar Bear</ANIMALS:name>
+ <ANIMALS:species>Thalarctos maritimus</ANIMALS:species>
+ <ANIMALS:specimens NC:parseType="Integer">20</ANIMALS:specimens>
+ <ANIMALS:specimensAsString>20</ANIMALS:specimensAsString>
+ </RDF:Description>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/aardvark">
+ <ANIMALS:name>aardvark</ANIMALS:name>
+ <ANIMALS:species>Orycteropus afer</ANIMALS:species>
+ <ANIMALS:specimens NC:parseType="Integer">2</ANIMALS:specimens>
+ <ANIMALS:specimensAsString>2</ANIMALS:specimensAsString>
+ </RDF:Description>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+ <ANIMALS:name>Nine-banded Armadillo</ANIMALS:name>
+ <ANIMALS:species>Dasypus novemcinctus</ANIMALS:species>
+ <ANIMALS:specimens NC:parseType="Integer">1</ANIMALS:specimens>
+ <ANIMALS:specimensAsString>1</ANIMALS:specimensAsString>
+ </RDF:Description>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/gorilla">
+ <ANIMALS:name>Gorilla</ANIMALS:name>
+ <ANIMALS:species>Gorilla gorilla</ANIMALS:species>
+ <ANIMALS:specimens NC:parseType="Integer">7</ANIMALS:specimens>
+ <ANIMALS:specimensAsString>7</ANIMALS:specimensAsString>
+ </RDF:Description>
+
+ <ANIMALS:Class RDF:about="http://www.some-fictitious-zoo.com/reptiles">
+ <ANIMALS:name>Reptiles</ANIMALS:name>
+ <ANIMALS:keeper resource="http://www.some-fictitious-zoo.com/humans/robert"/>
+ </ANIMALS:Class>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/reptiles/anaconda" ANIMALS:specimens="1">
+ <ANIMALS:name>Anaconda</ANIMALS:name>
+ <ANIMALS:species>Eunectes murinus</ANIMALS:species>
+ </RDF:Description>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/reptiles/chameleon" ANIMALS:specimens="2">
+ <ANIMALS:name>Chameleon</ANIMALS:name>
+ <ANIMALS:species>Chamaeleo chamaelon</ANIMALS:species>
+ </RDF:Description>
+
+ <RDF:Seq RDF:about="http://www.some-fictitious-zoo.com/some-animals" ANIMALS:name="Zoo Animals">
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/arachnids"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/birds"/>
+ </RDF:Seq>
+
+ <RDF:Seq RDF:about="http://www.some-fictitious-zoo.com/all-animals" ANIMALS:name="Zoo Animals">
+ <RDF:li>
+ <RDF:Seq RDF:about="http://www.some-fictitious-zoo.com/arachnids">
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/arachnids/tarantula"/>
+ </RDF:Seq>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Seq RDF:about="http://www.some-fictitious-zoo.com/birds">
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/birds/emu"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/birds/barnowl"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/birds/raven"/>
+ </RDF:Seq>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Seq RDF:about="http://www.some-fictitious-zoo.com/crustaceans"/>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Seq RDF:about="http://www.some-fictitious-zoo.com/fish">
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/fish/cod"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/fish/swordfish"/>
+ </RDF:Seq>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Seq RDF:about="http://www.some-fictitious-zoo.com/mammals">
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/mammals/lion"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/mammals/hippopotamus"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/mammals/africanelephant"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/mammals/llama"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/mammals/polarbear"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/mammals/aardvark"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/mammals/gorilla"/>
+ </RDF:Seq>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Seq RDF:about="http://www.some-fictitious-zoo.com/reptiles">
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/reptiles/anaconda"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/reptiles/chameleon"/>
+ </RDF:Seq>
+ </RDF:li>
+ </RDF:Seq>
+
+ <RDF:Seq RDF:about="http://www.some-fictitious-zoo.com/humans" ANIMALS:name="Humans">
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/humans/sarah"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/humans/robert"/>
+ </RDF:Seq>
+
+ <RDF:Seq RDF:about="http://www.some-fictitious-zoo.com/sarahs-pets" ANIMALS:name="Sarah's Pets">
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/birds/emu"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/arachnids/tarantula"/>
+ </RDF:Seq>
+
+ <RDF:Seq RDF:about="http://www.some-fictitious-zoo.com/roberts-pets" ANIMALS:name="Robert's Pets">
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/reptiles/chameleon"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/arachnids/tarantula"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/mammals/llama"/>
+ </RDF:Seq>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/humans/sarah" ANIMALS:name="Sarah">
+ <ANIMALS:pets resource="http://www.some-fictitious-zoo.com/sarahs-pets"/>
+ <ANIMALS:favoriteAnimal resource="http://www.some-fictitious-zoo.com/birds/emu"/>
+ <ANIMALS:favoriteAnimal resource="http://www.some-fictitious-zoo.com/mammals/polarbear"/>
+ <ANIMALS:favoriteAnimal resource="http://www.some-fictitious-zoo.com/arachnids/tarantula"/>
+ <ANIMALS:description>
+ Sarah became caretaker of the Fictitious Zoo's emu exhibit in 2001. With so
+ many emus living there, she has a lot to do!
+ </ANIMALS:description>
+ </RDF:Description>
+
+ <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/humans/robert" ANIMALS:name="Robert">
+ <ANIMALS:pets resource="http://www.some-fictitious-zoo.com/roberts-pets"/>
+ <ANIMALS:favoriteAnimal resource="http://www.some-fictitious-zoo.com/arachnids/tarantula"/>
+ <ANIMALS:favoriteAnimal resource="http://www.some-fictitious-zoo.com/reptiles/anaconda"/>
+ <ANIMALS:favoriteAnimal resource="http://www.some-fictitious-zoo.com/reptiles/chameleon"/>
+ <ANIMALS:favoriteAnimal resource="http://www.some-fictitious-zoo.com/mammals/africanelephant"/>
+ <ANIMALS:description>
+ Robert helps visitors to the Fictitious Zoo's reptile pavilion learn
+ more about some of the more unusual creatures that live there.
+ </ANIMALS:description>
+ <ANIMALS:lastName>Sanderson</ANIMALS:lastName>
+ </RDF:Description>
+
+ <RDF:Seq RDF:about="http://www.some-fictitious-zoo.com/marked" ANIMALS:name="Marked">
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/humans/sarah"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/mammals"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/crustaceans"/>
+ <RDF:li RDF:resource="http://www.some-fictitious-zoo.com/birds/emu"/>
+ </RDF:Seq>
+
+</RDF:RDF>
diff --git a/dom/xul/templates/tests/chrome/animals.sqlite b/dom/xul/templates/tests/chrome/animals.sqlite
new file mode 100644
index 000000000..7ba88ff74
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/animals.sqlite
Binary files differ
diff --git a/dom/xul/templates/tests/chrome/animals.xml b/dom/xul/templates/tests/chrome/animals.xml
new file mode 100644
index 000000000..f73ec718b
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/animals.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE zoo [
+ <!ATTLIST species id ID #REQUIRED>
+]>
+
+<zoo>
+ <class>
+ <name>Reptiles</name>
+ <species id="Chamaeleo-chamaelon" name="Chameleon" specimens="2"/>
+ </class>
+ <class>
+ <name>Birds</name>
+ <species id="Dromaius-novaehollandiae" name="Emu" specimens="12"/>
+ <species id="Tyto-alba" name="Barn Owl" specimens="4"/>
+ <species id="Corvus-corax" name="Raven" specimens="0"/>
+ <location>Aviary</location>
+ </class>
+</zoo>
diff --git a/dom/xul/templates/tests/chrome/bug441785-1.rdf b/dom/xul/templates/tests/chrome/bug441785-1.rdf
new file mode 100644
index 000000000..4be55657f
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/bug441785-1.rdf
@@ -0,0 +1,263 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:row="http://dummy/rdf#" xmlns:NC="http://home.netscape.com/NC-rdf#">
+ <RDF:Bag about="urn:data:row">
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111110</row:id>
+ <row:title>FILE 1 -- A</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111111</row:id>
+ <row:title>FILE 1 -- B</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111110</row:id>
+ <row:title>FILE 1 -- C</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111111</row:id>
+ <row:title>FILE 1 -- D</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111112</row:id>
+ <row:title>FILE 1 -- E</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111110</row:id>
+ <row:title>FILE 1 -- F</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111114</row:id>
+ <row:title>FILE 1 -- G</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111111</row:id>
+ <row:title>FILE 1 -- H</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111118</row:id>
+ <row:title>FILE 1 -- I</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111116</row:id>
+ <row:title>FILE 1 -- J</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111110</row:id>
+ <row:title>FILE 1 -- K</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111119</row:id>
+ <row:title>FILE 1 -- L</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111116</row:id>
+ <row:title>FILE 1 -- M</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111111</row:id>
+ <row:title>FILE 1 -- N</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111113</row:id>
+ <row:title>FILE 1 -- O</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111111</row:id>
+ <row:title>FILE 1 -- P</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111117</row:id>
+ <row:title>FILE 1 -- Q</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111110</row:id>
+ <row:title>FILE 1 -- R</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111113</row:id>
+ <row:title>FILE 1 -- S</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111112</row:id>
+ <row:title>FILE 1 -- T</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111116</row:id>
+ <row:title>FILE 1 -- U</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111111</row:id>
+ <row:title>FILE 1 -- V</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111121</row:id>
+ <row:title>FILE 1 -- W</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111114</row:id>
+ <row:title>FILE 1 -- X</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111122</row:id>
+ <row:title>FILE 1 -- Y</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111113</row:id>
+ <row:title>FILE 1 -- Z</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111119</row:id>
+ <row:title>FILE 1 -- AA</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111117</row:id>
+ <row:title>FILE 1 -- BB</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111117</row:id>
+ <row:title>FILE 1 -- CC</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111117</row:id>
+ <row:title>FILE 1 -- DD</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111116</row:id>
+ <row:title>FILE 1 -- EE</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111124</row:id>
+ <row:title>FILE 1 -- FF</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111118</row:id>
+ <row:title>FILE 1 -- GG</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111117</row:id>
+ <row:title>FILE 1 -- HH</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111118</row:id>
+ <row:title>FILE 1 -- II</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111125</row:id>
+ <row:title>FILE 1 -- JJ</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111124</row:id>
+ <row:title>FILE 1 -- KK</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111132</row:id>
+ <row:title>FILE 1 -- LL</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111136</row:id>
+ <row:title>FILE 1 -- MM</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111123</row:id>
+ <row:title>FILE 1 -- NN</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111122</row:id>
+ <row:title>FILE 1 -- OO</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">111110</row:id>
+ <row:title>FILE 1 -- PP</row:title>
+ </RDF:Description>
+ </RDF:li>
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">1111116</row:id>
+ <row:title>FILE 1 -- QQ</row:title>
+ </RDF:Description>
+ </RDF:li>
+ </RDF:Bag>
+</RDF:RDF>
diff --git a/dom/xul/templates/tests/chrome/bug441785-2.rdf b/dom/xul/templates/tests/chrome/bug441785-2.rdf
new file mode 100644
index 000000000..dca97ba78
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/bug441785-2.rdf
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:row="http://dummy/rdf#" xmlns:NC="http://home.netscape.com/NC-rdf#">
+ <RDF:Bag about="urn:data:row">
+ <RDF:li>
+ <RDF:Description>
+ <row:id NC:parseType="Integer">222220</row:id>
+ <row:title>FILE 2 -- A</row:title>
+ </RDF:Description>
+ </RDF:li>
+ </RDF:Bag>
+</RDF:RDF>
diff --git a/dom/xul/templates/tests/chrome/chrome.ini b/dom/xul/templates/tests/chrome/chrome.ini
new file mode 100644
index 000000000..97989723c
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/chrome.ini
@@ -0,0 +1,225 @@
+[DEFAULT]
+skip-if = os == 'android'
+support-files =
+ animals.rdf
+ animals.sqlite
+ animals.xml
+ bug441785-1.rdf
+ bug441785-2.rdf
+ templates_shared.js
+
+[test_bug329335.xul]
+[test_bug330010.xul]
+skip-if = os == "win"
+support-files = file_bug330010.rdf
+[test_bug397148.xul]
+skip-if = true # Bug 879531
+[test_bug441785.xul]
+[test_bug476634.xul]
+[test_sortservice.xul]
+[test_tmpl_bindingsextendedsyntax.xul]
+[test_tmpl_bindingsmultiple.xul]
+[test_tmpl_bindingsquerysyntax.xul]
+[test_tmpl_bindingsreversed.xul]
+[test_tmpl_bindingssameastriple.xul]
+[test_tmpl_containerandmembervariablechanged.xul]
+[test_tmpl_containervariablechanged.xul]
+[test_tmpl_containmentattribute.xul]
+[test_tmpl_defaultcontainervariableisuri.xul]
+[test_tmpl_errors.xul]
+[test_tmpl_extendedsyntax.xul]
+[test_tmpl_extendedsyntaxemptyconditions.xul]
+[test_tmpl_extendedsyntaxotherrefvariable.xul]
+[test_tmpl_extendedsyntaxremoveunmatched.xul]
+[test_tmpl_extendedsyntaxsimplevariablesubstitution.xul]
+[test_tmpl_extendedsyntaxtworulesrecurse.xul]
+[test_tmpl_extendedsyntaxusinganinterveningcontainer.xul]
+[test_tmpl_extendedvariablesubstitution.xul]
+[test_tmpl_gridelement.xul]
+[test_tmpl_htmlelementextendedsyntaxwithbinding.xul]
+[test_tmpl_htmlelementquerysyntaxrecursive.xul]
+[test_tmpl_htmlelementquerysyntaxwithmultiplerules.xul]
+[test_tmpl_htmlelementsimplesyntax.xul]
+[test_tmpl_htmlelementsimplesyntaxusingatextnode.xul]
+[test_tmpl_invalidqp.xul]
+[test_tmpl_listboxelement.xul]
+[test_tmpl_literalasmember.xul]
+[test_tmpl_membervariablechanged.xul]
+[test_tmpl_membervariablesubstitution.xul]
+[test_tmpl_menuelement.xul]
+[test_tmpl_menuelementrecursive.xul]
+[test_tmpl_menulistelement.xul]
+[test_tmpl_mixedsyntaxiscontainer.xul]
+[test_tmpl_mixedsyntaxiscontainerisempty.xul]
+[test_tmpl_mixedsyntaxisempty.xul]
+[test_tmpl_noaction.xul]
+[test_tmpl_noactionuriattribute.xul]
+[test_tmpl_parentconditions.xul]
+[test_tmpl_parentcontenttag.xul]
+[test_tmpl_parentsimplesyntax.xul]
+[test_tmpl_query3triples.xul]
+[test_tmpl_query3tripleswherecontains.xul]
+[test_tmpl_querymember3tripleswhereequals.xul]
+[test_tmpl_querymemberandtwotriples.xul]
+[test_tmpl_querymembertriplemembertriple.xul]
+[test_tmpl_queryresourcematch.xul]
+[test_tmpl_queryreversetriple.xul]
+[test_tmpl_queryselfwithtriple.xul]
+[test_tmpl_querysetone.xul]
+[test_tmpl_querysettwo.xul]
+[test_tmpl_querysettwowithcondition.xul]
+[test_tmpl_querysyntax.xul]
+[test_tmpl_querysyntaxmultiplerules.xul]
+[test_tmpl_querysyntaxmultiplerulesfirstconditionall.xul]
+[test_tmpl_querysyntaxmultiplerulestwoconditions.xul]
+[test_tmpl_querytripleandmembermerge.xul]
+[test_tmpl_querytripleobjecttosubject.xul]
+[test_tmpl_querytwomembers.xul]
+[test_tmpl_querytwomembersfiltered.xul]
+[test_tmpl_querytwotriples.xul]
+[test_tmpl_queryupwardsmember.xul]
+[test_tmpl_queryupwardsmembertripleandfilteringtriple.xul]
+[test_tmpl_querywithemptyconditions.xul]
+[test_tmpl_referenceasmember.xul]
+[test_tmpl_regenerate.xul]
+[test_tmpl_selfgenerationextendedsyntax.xul]
+[test_tmpl_selfgenerationsimplesyntax.xul]
+[test_tmpl_simplesyntaxenclosedinacontainer.xul]
+[test_tmpl_simplesyntaxenclosedinacontainerwitharule.xul]
+[test_tmpl_simplesyntaxfilter.xul]
+[test_tmpl_simplesyntaxfilterwithmultiplerules.xul]
+[test_tmpl_simplesyntaxfilterwithrule.xul]
+[test_tmpl_simplesyntaxiteratingoverasinglevalue.xul]
+[test_tmpl_simplesyntaxusinganinterveningcontainer.xul]
+[test_tmpl_simplesyntaxusingatextnode.xul]
+[test_tmpl_simplesyntaxusingcontainerasthegenerationelement.xul]
+[test_tmpl_simplesyntaxusingdontrecurse.xul]
+[test_tmpl_simplesyntaxusingrecursivegeneration.xul]
+[test_tmpl_simplesyntaxusingrecursivegenerationagain.xul]
+[test_tmpl_simplesyntaxwithtwovariablesused.xul]
+[test_tmpl_simplevariablesubstitutioncaretsatbeginningandend.xul]
+[test_tmpl_simplevariablesubstitutioncaretsubstitution.xul]
+[test_tmpl_simplevariablesubstitutionnovariable.xul]
+[test_tmpl_simplevariablesubstitutionquestionmarkaspartofvariable.xul]
+[test_tmpl_simplevariablesubstitutionquestionmarksubstitution.xul]
+[test_tmpl_simplevariablesubstitutiontextandvariable.xul]
+[test_tmpl_simplevariablesubstitutionvariableandtextconcatenated.xul]
+[test_tmpl_simplevariablesubstitutionvariablesconcatenated.xul]
+[test_tmpl_sortascendinginteger.xul]
+[test_tmpl_sortascendingquerysyntax.xul]
+[test_tmpl_sortascendingtworulesquerysyntax.xul]
+[test_tmpl_sortascendingtworuleswithcontainerquerysyntax.xul]
+[test_tmpl_sortascendingtworuleswithdifferentcontainerquerysyntax.xul]
+[test_tmpl_sortdescendingquerysyntax.xul]
+[test_tmpl_sortquerymemberandtwotriples.xul]
+[test_tmpl_sortresource2descendingsimplesyntax.xul]
+[test_tmpl_sortresource2settopredicateascendingquerysyntax.xul]
+[test_tmpl_sortresource2settopredicatedescendingquerysyntax.xul]
+[test_tmpl_sortresourceascendingquerysyntax.xul]
+[test_tmpl_sortresourcedescendingquerysyntax.xul]
+[test_tmpl_sortresourcesettopredicateascendingquerysyntax.xul]
+[test_tmpl_sortresourcesettopredicatedescendingquerysyntax.xul]
+[test_tmpl_sorttworesourcesasstringsettopredicatedescendingquerysyntax.xul]
+[test_tmpl_sorttworesourcessettopredicateascendingquerysyntax.xul]
+[test_tmpl_sorttwovariablesascendingquerysyntax.xul]
+[test_tmpl_sorttwovariablesascendingsimplesyntax.xul]
+[test_tmpl_sorttwovariablesdescendingquerysyntax.xul]
+[test_tmpl_sortunknownascendingquerysyntax.xul]
+[test_tmpl_storage_bad_parameters.xul]
+[test_tmpl_storage_bad_parameters_2.xul]
+[test_tmpl_storage_bad_parameters_3.xul]
+[test_tmpl_storage_baddatasource.xul]
+[test_tmpl_storage_badquery.xul]
+[test_tmpl_storage_dynamicparameters.xul]
+[test_tmpl_storage_listbox.xul]
+[test_tmpl_storage_multiqueries.xul]
+[test_tmpl_storage_parameters.xul]
+[test_tmpl_storage_rule.xul]
+[test_tmpl_storage_simple.xul]
+[test_tmpl_storage_sortintegerasc.xul]
+[test_tmpl_storage_sortintegerdesc.xul]
+[test_tmpl_storage_sortstringasc.xul]
+[test_tmpl_storage_sortstringdesc.xul]
+[test_tmpl_storage_tree.xul]
+[test_tmpl_treeelementquerysyntax.xul]
+[test_tmpl_treeelementquerysyntaxnotrecursive.xul]
+[test_tmpl_treeelementquerysyntaxnotrecursivetreebuilder.xul]
+[test_tmpl_treeelementquerysyntaxrecursive.xul]
+[test_tmpl_treeelementquerysyntaxrecursivemultiplerules.xul]
+[test_tmpl_treeelementquerysyntaxrecursivemultiplerulestreebuilder.xul]
+[test_tmpl_treeelementquerysyntaxrecursivetreebuilder.xul]
+[test_tmpl_treeelementquerysyntaxtreebuilder.xul]
+[test_tmpl_treeelementsimplesyntaxnotrecursive.xul]
+[test_tmpl_treeelementsimplesyntaxnotrecursivetreebuilder.xul]
+[test_tmpl_treeelementsimplesyntaxrecursive.xul]
+[test_tmpl_treeelementsimplesyntaxrecursivetreebuilder.xul]
+[test_tmpl_treeelementtreecell.xul]
+[test_tmpl_treeelementtreecellsortascending.xul]
+[test_tmpl_treeelementtreecellsortascendingtreebuilder.xul]
+[test_tmpl_treeelementtreecelltreebuilder.xul]
+[test_tmpl_treeelementtreeitemonly.xul]
+[test_tmpl_treeelementtreeitemsortascending.xul]
+[test_tmpl_twogenerationnodes.xul]
+[test_tmpl_whereafterignorecase.xul]
+[test_tmpl_whereafterlowercase.xul]
+[test_tmpl_whereafternegation.xul]
+[test_tmpl_whereafteruppercase.xul]
+[test_tmpl_wherebeforeignorecase.xul]
+[test_tmpl_wherebeforelowercase.xul]
+[test_tmpl_wherebeforenegation.xul]
+[test_tmpl_wherebeforeuppercase.xul]
+[test_tmpl_wherecontains.xul]
+[test_tmpl_wherecontainsignorecase.xul]
+[test_tmpl_wherecontainsnegation.xul]
+[test_tmpl_wherecontainsnumber.xul]
+[test_tmpl_wherecontainsnumberstring.xul]
+[test_tmpl_wherecontainsresource.xul]
+[test_tmpl_wherecontainstwo.xul]
+[test_tmpl_whereendswith.xul]
+[test_tmpl_whereendswithignorecase.xul]
+[test_tmpl_whereendswithnegation.xul]
+[test_tmpl_whereequals.xul]
+[test_tmpl_whereequalsignorecase.xul]
+[test_tmpl_whereequalsmultiple.xul]
+[test_tmpl_whereequalsmultiplenegation.xul]
+[test_tmpl_whereequalsmultiplenegationignorecase.xul]
+[test_tmpl_whereequalsnegation.xul]
+[test_tmpl_whereequalsnegationignorecase.xul]
+[test_tmpl_whereequalsnegationwrongcase.xul]
+[test_tmpl_whereequalsnumber.xul]
+[test_tmpl_whereequalsothervariable.xul]
+[test_tmpl_whereequalsresource.xul]
+[test_tmpl_whereequalssamevariable.xul]
+[test_tmpl_whereequalswrongcase.xul]
+[test_tmpl_wheregreater.xul]
+[test_tmpl_wheregreaternegation.xul]
+[test_tmpl_wheregreaternegationstring.xul]
+[test_tmpl_wheregreaterstring.xul]
+[test_tmpl_whereless.xul]
+[test_tmpl_wherelessnegation.xul]
+[test_tmpl_wherelessnegationstring.xul]
+[test_tmpl_wherelessstring.xul]
+[test_tmpl_wherenorel.xul]
+[test_tmpl_wherenosubject.xul]
+[test_tmpl_wherenovalue.xul]
+[test_tmpl_wherestartswith.xul]
+[test_tmpl_wherestartswithignorecase.xul]
+[test_tmpl_wherestartswithmultiple.xul]
+[test_tmpl_wherestartswithnegation.xul]
+[test_tmpl_wherestartswithunknownvariable.xul]
+[test_tmpl_wherestartswithvariable.xul]
+[test_tmpl_wheresubjectequalsvariable.xul]
+[test_tmpl_wheresubjectstartswithvariable.xul]
+[test_tmpl_xmlquerysimple.xul]
+[test_tmpl_xmlquerywithassign.xul]
+[test_tmpl_xmlquerywithassignmentandcondition.xul]
+[test_tmpl_xmlquerywithassignmentandconditiondontrecurse.xul]
+[test_tmpl_xmlquerywithbindinginbindings.xul]
+[test_tmpl_xmlquerywithbindinginrule.xul]
+[test_tmpl_xmlquerywithdifferentmember.xul]
+[test_tmpl_xmlquerywithinlinedata.xul]
+[test_tmpl_xmlquerywithinlinedatawithmultiplequeries.xul]
+[test_tmpl_xmlquerywithmultiplequeries.xul]
+[test_tmpl_xmlquerywithothertypes.xul]
+[test_tmpl_xmlquerywithsort.xul]
+[test_tmpl_xmlquerywithsortotherfield.xul]
diff --git a/dom/xul/templates/tests/chrome/file_bug330010.rdf b/dom/xul/templates/tests/chrome/file_bug330010.rdf
new file mode 100644
index 000000000..428f1045f
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/file_bug330010.rdf
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:s="urn:croczilla:xulsvg1:">
+ <rdf:Description about="urn:root">
+ <s:shapes>
+ <rdf:Bag>
+ <rdf:li>
+ <rdf:Description />
+ </rdf:li>
+ </rdf:Bag>
+ </s:shapes>
+ </rdf:Description>
+</rdf:RDF>
diff --git a/dom/xul/templates/tests/chrome/templates_shared.js b/dom/xul/templates/tests/chrome/templates_shared.js
new file mode 100644
index 000000000..85c49e52e
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/templates_shared.js
@@ -0,0 +1,488 @@
+/**
+ * This script is used for testing XUL templates. Call test_template within
+ * a load event handler.
+ *
+ * A test should have a root node with the datasources attribute with the
+ * id 'root', and a few global variables defined in the test's XUL file:
+ *
+ * testid: the testid, used when outputting test results
+ * expectedOutput: e4x data containing the expected output. It can optionally
+ * be enclosed in an <output> element as most tests generate
+ * more than one node of output.
+ * isTreeBuilder: true for dont-build-content trees, false otherwise
+ * queryType: 'rdf', 'xml', etc.
+ * needsOpen: true for menu tests where the root menu must be opened before
+ * comparing results
+ * notWorkingYet: true if this test isn't working yet, outputs todo results
+ * notWorkingYetDynamic: true if the dynamic changes portion of the test
+ * isn't working yet, outputs todo results
+ * changes: an array of functions to perform in sequence to test dynamic changes
+ * to the datasource.
+ *
+ * If the <output> element has an unordered attribute set to true, the
+ * children within it must all appear to match, but may appear in any order.
+ * If the unordered attribute is not set, the children must appear in the same
+ * order.
+ *
+ * If the 'changes' array is used, it should be an array of functions. Each
+ * function will be called in order and a comparison of the output will be
+ * performed. This allows changes to be made to the datasource to ensure that
+ * the generated template output has been updated. Within the expected output
+ * XML, the step attribute may be set to a number on an element to indicate
+ * that an element only applies before or after a particular change. If step
+ * is set to a positive number, that element will only exist after that step in
+ * the list of changes made. If step is set to a negative number, that element
+ * will only exist until that step. Steps are numbered starting at 1. For
+ * example:
+ * <label value="Cat"/>
+ * <label step="2" value="Dog"/>
+ * <label step="-5" value="Mouse"/>
+ * The first element will always exist. The second element will only appear
+ * after the second change is made. The third element will only appear until
+ * the fifth change and it will no longer be present at later steps.
+ *
+ * If the anyid attribute is set to true on an element in the expected output,
+ * then the value of the id attribute on that element is not compared for a
+ * match. This is used, for example, for xml datasources, where the ids set on
+ * the generated output are pseudo-random.
+ */
+
+const ZOO_NS = "http://www.some-fictitious-zoo.com/";
+const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+const debug = false;
+
+var expectedConsoleMessages = [];
+var expectLoggedMessages = null;
+
+function get_RDF() {
+ try {
+ return Components.classes["@mozilla.org/rdf/rdf-service;1"].
+ getService(Components.interfaces.nsIRDFService);
+ } catch (ex) { }
+}
+
+function get_ContainerUtils()
+{
+ try {
+ return Components.classes["@mozilla.org/rdf/container-utils;1"].
+ getService(Components.interfaces.nsIRDFContainerUtils);
+ } catch(ex) { }
+}
+
+const RDF = get_RDF();
+const ContainerUtils = get_ContainerUtils();
+
+var xmlDoc;
+
+function test_template()
+{
+ var root = document.getElementById("root");
+
+ var ds;
+ if (queryType == "rdf" && RDF) {
+ var ioService = Components.classes["@mozilla.org/network/io-service;1"].
+ getService(Components.interfaces.nsIIOService);
+
+ var src = window.location.href.replace(/test_tmpl.*xul/, "animals.rdf");
+ ds = RDF.GetDataSourceBlocking(src);
+
+ if (expectLoggedMessages) {
+ Components.classes["@mozilla.org/consoleservice;1"].
+ getService(Components.interfaces.nsIConsoleService).reset();
+ }
+
+ if (root.getAttribute("datasources") == "rdf:null")
+ root.setAttribute("datasources", "animals.rdf");
+ }
+ else if (queryType == "xml") {
+ var src = window.location.href.replace(/test_tmpl.*xul/, "animals.xml");
+ xmlDoc = new XMLHttpRequest();
+ xmlDoc.open("get", src, false);
+ xmlDoc.send(null);
+ }
+
+ // open menus if necessary
+ if (needsOpen)
+ root.open = true;
+
+ if (expectLoggedMessages)
+ expectLoggedMessages();
+
+ checkResults(root, 0);
+
+ if (changes.length) {
+ var usedds = ds;
+ // within these chrome tests, RDF datasources won't be modifiable unless
+ // an in-memory datasource is used instead. Call copyRDFDataSource to
+ // copy the datasource.
+ if (queryType == "rdf")
+ usedds = copyRDFDataSource(root, ds);
+ if (needsOpen)
+ root.open = true;
+ setTimeout(iterateChanged, 0, root, usedds);
+ }
+ else {
+ if (needsOpen)
+ root.open = false;
+ if (expectedConsoleMessages.length)
+ compareConsoleMessages();
+ SimpleTest.finish();
+ }
+}
+
+function iterateChanged(root, ds)
+{
+ Components.classes["@mozilla.org/consoleservice;1"].
+ getService(Components.interfaces.nsIConsoleService).reset();
+
+ for (var c = 0; c < changes.length; c++) {
+ changes[c](ds, root);
+ checkResults(root, c + 1);
+ }
+
+ if (needsOpen)
+ root.open = false;
+ if (expectedConsoleMessages.length)
+ compareConsoleMessages();
+ SimpleTest.finish();
+}
+
+function checkResults(root, step)
+{
+ var output = expectedOutput.cloneNode(true);
+ setForCurrentStep(output, step);
+
+ var error;
+ var actualoutput = root;
+ if (isTreeBuilder) {
+ // convert the tree's view data into the equivalent DOM structure
+ // for easier comparison
+ actualoutput = treeViewToDOM(root);
+ var treechildrenElements = [...output.children].filter((e) => e.localName === "treechildren");
+ error = compareOutput(actualoutput, treechildrenElements[0], false);
+ }
+ else {
+ error = compareOutput(actualoutput, output, true);
+ }
+
+ var adjtestid = testid;
+ if (step > 0)
+ adjtestid += " dynamic step " + step;
+
+ var stilltodo = ((step == 0 && notWorkingYet) || (step > 0 && notWorkingYetDynamic));
+ if (stilltodo)
+ todo(false, adjtestid);
+ else
+ ok(!error, adjtestid);
+
+ if ((!stilltodo && error) || debug) {
+ // for debugging, serialize the XML output
+ var serializedXML = "";
+ var rootNodes = actualoutput.childNodes;
+ for (var n = 0; n < rootNodes.length; n++) {
+ var node = rootNodes[n];
+ if (node.localName != "template")
+ serializedXML += ((new XMLSerializer()).serializeToString(node));
+ }
+
+ // remove the XUL namespace declarations to make the output more readable
+ const nsrepl = new RegExp("xmlns=\"" + XUL_NS + "\" ", "g");
+ serializedXML = serializedXML.replace(nsrepl, "");
+ if (debug)
+ dump("-------- " + adjtestid + " " + error + ":\n" + serializedXML + "\n");
+ if (!stilltodo && error)
+ is(serializedXML, "Same", "Error is: " + error);
+ }
+}
+
+/**
+ * Adjust the expected output to acccount for any step attributes.
+ */
+function setForCurrentStep(content, currentStep)
+{
+ var todelete = [];
+ for (var child of content.childNodes) {
+ if (child.nodeType === Node.ELEMENT_NODE) {
+ var stepstr = child.getAttribute("step") || "";
+ var stepsarr = stepstr.split(",");
+ for (var s = 0; s < stepsarr.length; s++) {
+ var step = parseInt(stepsarr[s]);
+ if ((step > 0 && step > currentStep) ||
+ (step < 0 && -step <= currentStep)) {
+ todelete.push(child);
+ }
+ }
+ } else if (child.nodeType === Node.TEXT_NODE) {
+ // Drop empty text nodes.
+ if (child.nodeValue.trim() === "")
+ todelete.push(child);
+ }
+ }
+
+ for (var e of todelete)
+ content.removeChild(e);
+
+ for (var child of content.children) {
+ child.removeAttribute("step");
+ setForCurrentStep(child, currentStep);
+ }
+}
+
+/**
+ * Compares the 'actual' DOM output with the 'expected' output. This function
+ * is called recursively, with isroot true if actual refers to the root of the
+ * template. Returns a null string if they are equal and an error string if
+ * they are not equal. This function is called recursively as it iterates
+ * through each node in the DOM tree.
+ */
+function compareOutput(actual, expected, isroot)
+{
+ if (isroot && expected.localName != "data")
+ return "expected must be a <data> element";
+
+ var t;
+
+ // compare text nodes
+ if (expected.nodeType == Node.TEXT_NODE) {
+ if (actual.nodeValue !== expected.nodeValue.trim())
+ return "Text " + actual.nodeValue + " doesn't match " + expected.nodeValue;
+ return "";
+ }
+
+ if (!isroot) {
+ var anyid = false;
+ // make sure that the tags match
+ if (actual.localName != expected.localName)
+ return "Tag name " + expected.localName + " not found";
+
+ // loop through the attributes in the expected node and compare their
+ // values with the corresponding attribute on the actual node
+
+ var expectedAttrs = expected.attributes;
+ for (var a = 0; a < expectedAttrs.length; a++) {
+ var attr = expectedAttrs[a];
+ var expectval = attr.value;
+ // skip checking the id when anyid="true", however make sure to
+ // ensure that the id is actually present.
+ if (attr.name == "anyid" && expectval == "true") {
+ anyid = true;
+ if (!actual.hasAttribute("id"))
+ return "expected id attribute";
+ }
+ else if (actual.getAttribute(attr.name) != expectval) {
+ return "attribute " + attr.name + " is '" +
+ actual.getAttribute(attr.name) + "' instead of '" + expectval + "'";
+ }
+ }
+
+ // now loop through the actual attributes and make sure that there aren't
+ // any extra attributes that weren't expected
+ var length = actual.attributes.length;
+ for (t = 0; t < length; t++) {
+ var aattr = actual.attributes[t];
+ var expectval = expected.getAttribute(aattr.name);
+ // ignore some attributes that don't matter
+ if (expectval != actual.getAttribute(aattr.name) &&
+ aattr.name != "staticHint" && aattr.name != "xmlns" &&
+ (aattr.name != "id" || !anyid))
+ return "extra attribute " + aattr.name;
+ }
+ }
+
+ // ensure that the node has the right number of children. Subtract one for
+ // the root node to account for the <template> node.
+ length = actual.childNodes.length - (isroot ? 1 : 0);
+ if (length != expected.childNodes.length)
+ return "incorrect child node count of " + actual.localName + " " + length +
+ " expected " + expected.childNodes.length;
+
+ // if <data unordered="true"> is used, then the child nodes may be in any order
+ var unordered = (expected.localName == "data" && expected.getAttribute("unordered") == "true");
+
+ // next, loop over the children and call compareOutput recursively on each one
+ var adj = 0;
+ for (t = 0; t < actual.childNodes.length; t++) {
+ var actualnode = actual.childNodes[t];
+ // skip the <template> element, and add one to the indices when looking
+ // at the later nodes to account for it
+ if (isroot && actualnode.localName == "template") {
+ adj++;
+ }
+ else {
+ var output = "unexpected";
+ if (unordered) {
+ var expectedChildren = expected.childNodes;
+ for (var e = 0; e < expectedChildren.length; e++) {
+ output = compareOutput(actualnode, expectedChildren[e], false);
+ if (!output)
+ break;
+ }
+ }
+ else {
+ output = compareOutput(actualnode, expected.childNodes[t - adj], false);
+ }
+
+ // an error was returned, so return early
+ if (output)
+ return output;
+ }
+ }
+
+ return "";
+}
+
+/*
+ * copy the datasource into an in-memory datasource so that it can be modified
+ */
+function copyRDFDataSource(root, sourceds)
+{
+ var dsourcesArr = [];
+ var composite = root.database;
+ var dsources = composite.GetDataSources();
+ while (dsources.hasMoreElements()) {
+ sourceds = dsources.getNext().QueryInterface(Components.interfaces.nsIRDFDataSource);
+ dsourcesArr.push(sourceds);
+ }
+
+ for (var d = 0; d < dsourcesArr.length; d++)
+ composite.RemoveDataSource(dsourcesArr[d]);
+
+ var newds = Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].
+ createInstance(Components.interfaces.nsIRDFDataSource);
+
+ var sourcelist = sourceds.GetAllResources();
+ while (sourcelist.hasMoreElements()) {
+ var source = sourcelist.getNext();
+ var props = sourceds.ArcLabelsOut(source);
+ while (props.hasMoreElements()) {
+ var prop = props.getNext();
+ if (prop instanceof Components.interfaces.nsIRDFResource) {
+ var targets = sourceds.GetTargets(source, prop, true);
+ while (targets.hasMoreElements())
+ newds.Assert(source, prop, targets.getNext(), true);
+ }
+ }
+ }
+
+ composite.AddDataSource(newds);
+ root.builder.rebuild();
+
+ return newds;
+}
+
+/**
+ * Converts a tree view (nsITreeView) into the equivalent DOM tree.
+ * Returns the treechildren
+ */
+function treeViewToDOM(tree)
+{
+ var treechildren = document.createElement("treechildren");
+
+ if (tree.view)
+ treeViewToDOMInner(tree.columns, treechildren, tree.view, tree.builder, 0, 0);
+
+ return treechildren;
+}
+
+function treeViewToDOMInner(columns, treechildren, view, builder, start, level)
+{
+ var end = view.rowCount;
+
+ for (var i = start; i < end; i++) {
+ if (view.getLevel(i) < level)
+ return i - 1;
+
+ var id = builder ? builder.getResourceAtIndex(i).Value : "id" + i;
+ var item = document.createElement("treeitem");
+ item.setAttribute("id", id);
+ treechildren.appendChild(item);
+
+ var row = document.createElement("treerow");
+ item.appendChild(row);
+
+ for (var c = 0; c < columns.length; c++) {
+ var cell = document.createElement("treecell");
+ var label = view.getCellText(i, columns[c]);
+ if (label)
+ cell.setAttribute("label", label);
+ row.appendChild(cell);
+ }
+
+ if (view.isContainer(i)) {
+ item.setAttribute("container", "true");
+ item.setAttribute("empty", view.isContainerEmpty(i) ? "true" : "false");
+
+ if (!view.isContainerEmpty(i) && view.isContainerOpen(i)) {
+ item.setAttribute("open", "true");
+
+ var innertreechildren = document.createElement("treechildren");
+ item.appendChild(innertreechildren);
+
+ i = treeViewToDOMInner(columns, innertreechildren, view, builder, i + 1, level + 1);
+ }
+ }
+ }
+
+ return i;
+}
+
+function expectConsoleMessage(ref, id, isNew, isActive, extra)
+{
+ var message = "In template with id root" +
+ (ref ? " using ref " + ref : "") + "\n " +
+ (isNew ? "New " : "Removed ") + (isActive ? "active" : "inactive") +
+ " result for query " + extra + ": " + id;
+ expectedConsoleMessages.push(message);
+}
+
+function compareConsoleMessages()
+{
+ var consoleService = Components.classes["@mozilla.org/consoleservice;1"].
+ getService(Components.interfaces.nsIConsoleService);
+ var messages = consoleService.getMessageArray() || [];
+ messages = messages.map(m => m.message);
+ // Copy to avoid modifying expectedConsoleMessages
+ var expect = expectedConsoleMessages.concat();
+ for (var m = 0; m < messages.length; m++) {
+ if (messages[m] == expect[0]) {
+ ok(true, "found message " + expect.shift());
+ }
+ }
+ if (expect.length != 0) {
+ ok(false, "failed to find expected console messages: " + expect);
+ }
+}
+
+function copyToProfile(filename)
+{
+ if (Cc === undefined) {
+ var Cc = Components.classes;
+ var Ci = Components.interfaces;
+ }
+
+ var loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
+ .getService(Ci.mozIJSSubScriptLoader);
+ loader.loadSubScript("chrome://mochikit/content/chrome-harness.js");
+
+ var file = Cc["@mozilla.org/file/directory_service;1"]
+ .getService(Ci.nsIProperties)
+ .get("ProfD", Ci.nsIFile);
+ file.append(filename);
+
+ var parentURI = getResolvedURI(getRootDirectory(window.location.href));
+ if (parentURI.JARFile) {
+ parentURI = extractJarToTmp(parentURI);
+ } else {
+ var fileHandler = Cc["@mozilla.org/network/protocol;1?name=file"].
+ getService(Ci.nsIFileProtocolHandler);
+ parentURI = fileHandler.getFileFromURLSpec(parentURI.spec);
+ }
+
+ parentURI = parentURI.QueryInterface(Ci.nsILocalFile);
+ parentURI.append(filename);
+ try {
+ var retVal = parentURI.copyToFollowingLinks(file.parent, filename);
+ } catch (ex) {
+ //ignore this error as the file could exist already
+ }
+}
diff --git a/dom/xul/templates/tests/chrome/test_bug329335.xul b/dom/xul/templates/tests/chrome/test_bug329335.xul
new file mode 100644
index 000000000..75190c17b
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_bug329335.xul
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:svg="http://www.w3.org/2000/svg">
+
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script>
+
+ SimpleTest.waitForExplicitFinish();
+
+ function init()
+ {
+ document.documentElement.appendChild(document.getElementById("svg"));
+ ok(true, "Didn't crash");
+ SimpleTest.finish();
+ }
+
+ window.addEventListener("load", init, false);
+
+ </script>
+
+
+ <svg:svg datasources="" id="svg"/>
+
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_bug330010.xul b/dom/xul/templates/tests/chrome/test_bug330010.xul
new file mode 100644
index 000000000..67cc81931
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_bug330010.xul
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ onload="boom();">
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+<script type="text/javascript">
+<![CDATA[
+
+SimpleTest.waitForExplicitFinish();
+function boom()
+{
+ const RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].
+ getService(Components.interfaces.nsIRDFService);
+ var src = window.location.href.replace(/test_bug330010.xul/, "file_bug330010.rdf");
+
+ var ds = RDF.GetDataSourceBlocking(src);
+
+ var s = document.getElementById("s");
+ s.setAttribute("datasources", "file_bug330010.rdf");
+
+ var x = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "hbox");
+ var generatedShape = s.childNodes[3];
+ generatedShape.appendChild(x);
+ document.documentElement.removeChild(document.getElementById("s"));
+ ok(true, "Didn't crash");
+ SimpleTest.finish();
+}
+
+]]>
+</script>
+
+ <html:div datasources="rdf:null" ref="urn:root" flex="1" id="s">
+ <template>
+ <rule>
+ <conditions>
+ <content uri="?root"/>
+ <triple subject="?root"
+ predicate="urn:croczilla:xulsvg1:shapes"
+ object="?shapes"/>
+ <member container="?shapes" child="?shape" id="m"/>
+ </conditions>
+ <action>
+ <hbox id="p" uri="?shape" />
+ </action>
+ </rule>
+ </template>
+ </html:div>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_bug397148.xul b/dom/xul/templates/tests/chrome/test_bug397148.xul
new file mode 100644
index 000000000..0f15cfa29
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_bug397148.xul
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" onload="boom();">
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+<script type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+
+function boom() {
+ ok(true, "Didn't crash");
+ SimpleTest.finish();
+}
+</script>
+
+
+<html:span datasources="0" />
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_bug441785.xul b/dom/xul/templates/tests/chrome/test_bug441785.xul
new file mode 100644
index 000000000..7be6df198
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_bug441785.xul
@@ -0,0 +1,148 @@
+<?xml version="1.0" ?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <tree flex="20" id="t" ref="urn:data:row" datasources="rdf:null" seltype="single">
+ <treecols>
+ <treecol flex="1" id="id" label="id" sort="rdf:http://dummy/rdf#id" />
+ <splitter class="tree-splitter"/>
+ <treecol flex="1" id="title" label="title" sort="rdf:http://dummy/rdf#title" sortActive="true" sortDirection="ascending" /><splitter class="tree-splitter"/>
+ </treecols>
+ <template>
+ <treechildren>
+ <treeitem uri="rdf:*" seltype="single">
+ <treerow >
+ <treecell label="rdf:http://dummy/rdf#id"/>
+ <treecell label="rdf:http://dummy/rdf#title"/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </template>
+ </tree>
+ <tree flex="20" id="tc" ref="urn:data:row" datasources="rdf:null" seltype="single" flags="dont-build-content">
+ <treecols>
+ <treecol flex="1" id="idc" label="id" sort="rdf:http://dummy/rdf#id" />
+ <splitter class="tree-splitter"/>
+ <treecol flex="1" id="titlec" label="title" sort="rdf:http://dummy/rdf#title" sortActive="true" sortDirection="ascending" /><splitter class="tree-splitter"/>
+ </treecols>
+ <template>
+ <treechildren>
+ <treeitem uri="rdf:*" seltype="single">
+ <treerow >
+ <treecell label="rdf:http://dummy/rdf#id"/>
+ <treecell label="rdf:http://dummy/rdf#title"/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </template>
+ </tree>
+
+<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<script type="application/x-javascript">
+<![CDATA[
+
+var buildCount = 0;
+
+SimpleTest.waitForExplicitFinish();
+
+var TemplateBuilderListener = {
+ willRebuild: function(aBuilder) {
+ },
+
+ didRebuild: function(aBuilder) {
+ ++buildCount;
+ var remove = false;
+ if (buildCount == 2) {
+ remove =true;
+ setTimeout(nextDataSource, 0);
+ } else if (buildCount == 4) {
+ remove = true;
+ setTimeout(continueTest, 0);
+ }
+ if (remove) {
+ var tree = document.getElementById('t');
+ var treec = document.getElementById('tc');
+ tree.builder.removeListener(TemplateBuilderListener);
+ treec.builder.removeListener(TemplateBuilderListener);
+ }
+ },
+
+ QueryInterface: function (aIID)
+ {
+ if (!aIID.equals(Components.interfaces.nsIXULBuilderListener) &&
+ !aIID.equals(Components.interfaces.nsISupports))
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ return this;
+ }
+};
+
+function runTest() {
+ var tree = document.getElementById('t');
+ var treec = document.getElementById('tc');
+
+ try {
+ var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].
+ getService(Components.interfaces.nsIRDFService);
+
+ var s1 = window.location.href.replace(/test_bug441785.xul/, "bug441785-1.rdf");
+ var ds1 = rdfService.GetDataSourceBlocking(s1);
+
+ var s2 = window.location.href.replace(/test_bug441785.xul/, "bug441785-2.rdf");
+ var ds2 = rdfService.GetDataSourceBlocking(s2);
+ } catch (ex) { }
+
+ tree.builder.addListener(TemplateBuilderListener);
+ treec.builder.addListener(TemplateBuilderListener);
+ tree.setAttribute('datasources', 'bug441785-1.rdf');
+ treec.setAttribute('datasources', 'bug441785-1.rdf');
+}
+
+var oldtreefirstrow, oldtreecfirstrow;
+
+function nextDataSource()
+{
+ var tree = document.getElementById('t');
+ var treec = document.getElementById('tc');
+ tree.treeBoxObject.scrollToRow(10);
+ treec.treeBoxObject.scrollToRow(10);
+
+ is(tree.treeBoxObject.getFirstVisibleRow(), 10, "first tree row count datasource 1");
+ is(treec.treeBoxObject.getFirstVisibleRow(), 10, "second tree row count datasource 1");
+
+ tree.builder.addListener(TemplateBuilderListener);
+ treec.builder.addListener(TemplateBuilderListener);
+ tree.setAttribute('datasources', 'bug441785-2.rdf');
+ treec.setAttribute('datasources', 'bug441785-2.rdf');
+}
+
+function continueTest() {
+ var tree = document.getElementById('t');
+ var treec = document.getElementById('tc');
+
+ is(tree.treeBoxObject.getFirstVisibleRow(), 0, "first tree row count datasource 2");
+ is(treec.treeBoxObject.getFirstVisibleRow(), 0, "second tree row count datasource 2");
+
+ try {
+ window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIDOMWindowUtils)
+ .garbageCollect();
+ }
+ catch (e) { }
+
+ // Hit the bug, crash
+ // (not exactly the same kind of crash as 441785, but from the same cause)
+ tree.parentNode.removeChild(tree);
+ treec.parentNode.removeChild(treec);
+
+ SimpleTest.finish();
+}
+
+window.addEventListener("load", runTest, false);
+
+]]>
+</script>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_bug476634.xul b/dom/xul/templates/tests/chrome/test_bug476634.xul
new file mode 100644
index 000000000..cee01d41a
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_bug476634.xul
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet
+ href="chrome://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=476634
+-->
+<window title="Mozilla Bug 476634" onload="startup()"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank"
+ href="https://bugzilla.mozilla.org/show_bug.cgi?id=304188">Mozilla Bug 476634</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+</pre>
+</body>
+<template id="test-template">
+ <query>SELECT id,value FROM test</query>
+ <action>
+ <label uri="?" id="?id" value="?value"/>
+ </action>
+</template>
+<vbox id="results-list" datasources="rdf:null" querytype="storage" ref="*"
+ template="test-template"/>
+
+<script class="testbody" type="application/javascript">
+<![CDATA[
+function startup() {
+ var ss = Components.classes["@mozilla.org/storage/service;1"]
+ .getService(Components.interfaces.mozIStorageService);
+ var db = ss.openSpecialDatabase("memory");
+
+ db.createTable("test", "id TEXT, value INTEGER");
+ var stmt = db.createStatement("INSERT INTO test (id, value) VALUES (?,?)");
+ stmt.bindByIndex(0, "test1");
+ stmt.bindByIndex(1, 0);
+ stmt.execute();
+ stmt.bindByIndex(0, "test2");
+ stmt.bindByIndex(1, 2147483647);
+ stmt.execute();
+ stmt.bindByIndex(0, "test3");
+ stmt.bindByIndex(1, -2147483648);
+ stmt.execute();
+ stmt.bindByIndex(0, "test4");
+ stmt.bindByIndex(1, 0);
+ stmt.execute();
+ stmt.bindByIndex(0, "test5");
+ stmt.bindByIndex(1, 3147483647);
+ stmt.execute();
+ stmt.bindByIndex(0, "test6");
+ stmt.bindByIndex(1, -3147483648);
+ stmt.execute();
+ stmt.finalize();
+
+ var list = document.getElementById("results-list");
+ list.builder.datasource = db;
+
+ is(list.childNodes.length, 6, "Should be 6 generated elements");
+ is(list.childNodes[0].value, "0", "Should have seen the correct value");
+ is(list.childNodes[1].value, "2147483647", "Should have seen the correct value");
+ is(list.childNodes[2].value, "-2147483648", "Should have seen the correct value");
+ is(list.childNodes[3].value, "0", "Should have seen the correct value");
+ is(list.childNodes[4].value, "3147483647", "Should have seen the correct value");
+ is(list.childNodes[5].value, "-3147483648", "Should have seen the correct value");
+}
+]]>
+</script>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_sortservice.xul b/dom/xul/templates/tests/chrome/test_sortservice.xul
new file mode 100644
index 000000000..af1de3f0e
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_sortservice.xul
@@ -0,0 +1,70 @@
+<?xml version="1.0" ?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<vbox id="box"/>
+
+<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<script type="application/x-javascript">
+<![CDATA[
+
+var tests = [
+ [["One", "Two", "Three", "Four"], "", "Four One Three Two"],
+ [["One", "Two", "Three", "Four"], "integer", "Four One Three Two"],
+ [["One", "Two", "Three", "Four"], "descending", "Two Three One Four"],
+ [["One", "Two", "Three", "Four"], "descending integer", "Two Three One Four"],
+ [["One", "Two", "Three", "Four"], "integer cat descending", "Two Three One Four"],
+ [["1", "13", "2", "7", "12", "240", "2", "170", "222", "98"], "", "1 12 13 170 2 2 222 240 7 98"],
+ [["1", "13", "2", "7", "12", "240", "2", "170", "222", "98"], "integer", "1 2 2 7 12 13 98 170 222 240"],
+ [["1", "13", "2", "7", "12", "240", "2", "170", "222", "98"], "ascending integer", "1 2 2 7 12 13 98 170 222 240"],
+ [["1", "13", "2", "7", "12", "240", "2", "170", "222", "98"], "integer descending", "240 222 170 98 13 12 7 2 2 1"],
+ [["Cat", "cat", "Candy", "candy"], "comparecase", "Candy Cat candy cat"],
+ [["1", "102", "22", "One", "40", "Two"], "integer", "1 22 40 102 One Two"],
+];
+
+SimpleTest.waitForExplicitFinish();
+
+function doTests()
+{
+ var box = document.getElementById("box");
+
+ const sortService = Components.classes["@mozilla.org/xul/xul-sort-service;1"].
+ getService(Components.interfaces.nsIXULSortService);
+
+ for (let t = 0; t < tests.length; t++) {
+ var test = tests[t];
+
+ for (let e = 0; e < test[0].length; e++) {
+ var label = document.createElement("label");
+ label.setAttribute("value", test[0][e]);
+ box.appendChild(label);
+ }
+
+ sortService.sort(box, "value", test[1]);
+
+ var actual = "";
+ for (let e = 0; e < box.childNodes.length; e++) {
+ if (actual)
+ actual += " ";
+ actual += box.childNodes[e].getAttribute("value");
+ }
+ is(actual, test[2], "sorted step " + (t + 1));
+
+ while(box.hasChildNodes())
+ box.removeChild(box.firstChild);
+ box.removeAttribute("sortDirection");
+ }
+
+ SimpleTest.finish();
+}
+
+window.addEventListener("load", doTests, false);
+
+]]>
+</script>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_bindingsextendedsyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_bindingsextendedsyntax.xul
new file mode 100644
index 000000000..42e9a1633
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_bindingsextendedsyntax.xul
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ bindings - extended syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="-2" id="http://www.some-fictitious-zoo.com/humans/sarah" value="Sarah "/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/humans/sarah" value="Sarah Yarmouth"/>
+ <label step="-1" id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert Sanderson"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert "/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="bindings - extended syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/robert'),
+ RDF.GetResource(ZOO_NS + 'rdf#lastName'),
+ RDF.GetLiteral('Sanderson'), true);
+ },
+ // step 2
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'humans/sarah'),
+ RDF.GetResource(ZOO_NS + 'rdf#lastName'),
+ RDF.GetLiteral('Yarmouth'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
+<template id="template">
+<rule>
+<conditions>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<bindings>
+<binding subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#lastName" object="?lastname"/>
+</bindings>
+<action>
+<label uri="?child" value="?name ?lastname"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_bindingsmultiple.xul b/dom/xul/templates/tests/chrome/test_tmpl_bindingsmultiple.xul
new file mode 100644
index 000000000..2af4f89aa
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_bindingsmultiple.xul
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ bindings - multiple
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false" label="Arachnids "/>
+ <button step="-2" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false" label="Birds Sarah "/>
+ <button step="2" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false" label="Birds Sarah Yarmouth"/>
+ <button step="-1" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" label="Crustaceans Robert Sanderson"/>
+ <button step="1" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" label="Crustaceans Robert "/>
+ <button id="http://www.some-fictitious-zoo.com/fish" container="true" empty="false" label="Fish "/>
+ <button id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" label="Mammals "/>
+ <button step="-1" id="http://www.some-fictitious-zoo.com/reptiles" container="true" empty="false" label="Reptiles Robert Sanderson"/>
+ <button step="1" id="http://www.some-fictitious-zoo.com/reptiles" container="true" empty="false" label="Reptiles Robert "/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="bindings - multiple";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/robert'),
+ RDF.GetResource(ZOO_NS + 'rdf#lastName'),
+ RDF.GetLiteral('Sanderson'), true);
+ },
+ // step 2
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'humans/sarah'),
+ RDF.GetResource(ZOO_NS + 'rdf#lastName'),
+ RDF.GetLiteral('Yarmouth'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template>
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+</query>
+<rule>
+<bindings>
+<binding subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#keeper" object="?keeper"/>
+<binding subject="?keeper" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?keepername"/>
+<binding subject="?keeper" predicate="http://www.some-fictitious-zoo.com/rdf#lastName" object="?lastname"/>
+<binding subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</bindings>
+<action>
+<button uri="?child" label="?name ?keepername ?lastname"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_bindingsquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_bindingsquerysyntax.xul
new file mode 100644
index 000000000..d8b6110be
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_bindingsquerysyntax.xul
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ bindings - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="-2" id="http://www.some-fictitious-zoo.com/humans/sarah" value="First Name: Sarah Last Name: "/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/humans/sarah" value="First Name: Sarah Last Name: Yarmouth"/>
+ <label step="-1" id="http://www.some-fictitious-zoo.com/humans/robert" value="First Name: Robert Last Name: Sanderson"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/humans/robert" value="First Name: Robert Last Name: "/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="bindings - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/robert'),
+ RDF.GetResource(ZOO_NS + 'rdf#lastName'),
+ RDF.GetLiteral('Sanderson'), true);
+ },
+ // step 2
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'humans/sarah'),
+ RDF.GetResource(ZOO_NS + 'rdf#lastName'),
+ RDF.GetLiteral('Yarmouth'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule id="rule">
+<bindings id="bindings">
+<binding subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#lastName" object="?lastname"/>
+</bindings>
+<action>
+<label uri="?child" value="First Name: ?name Last Name: ?lastname"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_bindingsreversed.xul b/dom/xul/templates/tests/chrome/test_tmpl_bindingsreversed.xul
new file mode 100644
index 000000000..a7bd190a7
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_bindingsreversed.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ bindings - reversed
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/humans/sarah" value="First Name: Sarah Last Name: "/>
+ <label id="http://www.some-fictitious-zoo.com/humans/robert" value="First Name: Robert Last Name: "/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="bindings - reversed";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule id="rule">
+<bindings id="bindings">
+<binding subject="?lastname" predicate="http://www.some-fictitious-zoo.com/rdf#lastName" object="?child"/>
+</bindings>
+<action>
+<label uri="?child" value="First Name: ?name Last Name: ?lastname"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_bindingssameastriple.xul b/dom/xul/templates/tests/chrome/test_tmpl_bindingssameastriple.xul
new file mode 100644
index 000000000..514979d59
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_bindingssameastriple.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ bindings - same as triple
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/humans/sarah" value="First Name: Sarah Last Name: "/>
+ <label id="http://www.some-fictitious-zoo.com/humans/robert" value="First Name: Robert Last Name: "/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="bindings - same as triple";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule id="rule">
+<bindings id="bindings">
+<binding subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</bindings>
+<action>
+<label uri="?child" value="First Name: ?name Last Name: ?lastname"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_containerandmembervariablechanged.xul b/dom/xul/templates/tests/chrome/test_tmpl_containerandmembervariablechanged.xul
new file mode 100644
index 000000000..7b90d64b1
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_containerandmembervariablechanged.xul
@@ -0,0 +1,88 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ container and member variable changed
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/wren"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/emu" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/emu"/>
+ <button step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/barnowl"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/raven" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/raven"/>
+ <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/archaeopteryx"/>
+ <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/emperorpenguin"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="container and member variable changed";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template container="?parent" member="?child">
+<rule>
+<button uri="?" label="?parent ?child"/>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_containervariablechanged.xul b/dom/xul/templates/tests/chrome/test_tmpl_containervariablechanged.xul
new file mode 100644
index 000000000..f9100047f
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_containervariablechanged.xul
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ container variable changed
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button id="http://www.some-fictitious-zoo.com/birds/emu" label="http://www.some-fictitious-zoo.com/birds "/>
+ <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="http://www.some-fictitious-zoo.com/birds "/>
+ <button id="http://www.some-fictitious-zoo.com/birds/raven" label="http://www.some-fictitious-zoo.com/birds "/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="container variable changed";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template container="?parent">
+<rule>
+<button uri="?" label="?parent ?child"/>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_containmentattribute.xul b/dom/xul/templates/tests/chrome/test_tmpl_containmentattribute.xul
new file mode 100644
index 000000000..909a05e34
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_containmentattribute.xul
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ containment attribute
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" unordered="true">
+ <checkbox step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" label="Tarantula"/>
+ <checkbox step="2" id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/reptiles/anaconda" label="Anaconda"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/reptiles/chameleon" label="Chameleon"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="containment attribute";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/robert'),
+ RDF.GetResource(ZOO_NS + 'rdf#favoriteAnimal'),
+ RDF.GetResource(ZOO_NS + 'arachnids/tarantula'), true);
+ },
+ // step 2
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'humans/robert'),
+ RDF.GetResource(ZOO_NS + 'rdf#favoriteAnimal'),
+ RDF.GetResource(ZOO_NS + 'mammals/lion'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert" containment="http://www.some-fictitious-zoo.com/rdf#favoriteAnimal">
+<template id="template">
+<rule id="rule">
+<conditions>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action>
+<checkbox uri="?child" label="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_defaultcontainervariableisuri.xul b/dom/xul/templates/tests/chrome/test_tmpl_defaultcontainervariableisuri.xul
new file mode 100644
index 000000000..933c51bc0
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_defaultcontainervariableisuri.xul
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ default container variable is ?uri
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button id="http://www.some-fictitious-zoo.com/birds/emu" label="http://www.some-fictitious-zoo.com/birds"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="http://www.some-fictitious-zoo.com/birds"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/raven" label="http://www.some-fictitious-zoo.com/birds"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="default container variable is ?uri";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template>
+<rule>
+<button uri="?uri" label="?uri"/>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_errors.xul b/dom/xul/templates/tests/chrome/test_tmpl_errors.xul
new file mode 100644
index 000000000..f3b58502d
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_errors.xul
@@ -0,0 +1,280 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tests for templates with invalid syntax
+-->
+
+<window title="XUL Invalid Template Tests" width="500" height="600"
+ onload="runTest();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var consoleService = Components.classes["@mozilla.org/consoleservice;1"].
+ getService(Components.interfaces.nsIConsoleService);
+
+function checkConsole(expectedError)
+{
+ var message = consoleService.getMessageArray()[0].message;
+ is(message, expectedError, "logged message " + expectedError);
+}
+
+// each test consists of a pre function executed before the template build, an
+// expected error message, and a post function executed after the template build
+var tests = [
+
+// <queryset> used in invalid location
+{
+ pre: template => template.insertBefore(document.createElement("queryset"), template.lastChild),
+ error: "Error parsing template: unexpected <queryset> element",
+ post: queryset => queryset.parentNode.removeChild(queryset)
+},
+
+// no member variable found
+{
+ pre: template => $("action").firstChild.removeAttribute("uri"),
+ error: "Error parsing template: no member variable found. Action body should have an element with uri attribute",
+ post: () => $("action").firstChild.setAttribute("uri", "?child")
+},
+
+// bad binding subject
+{
+ pre: template => $("binding").removeAttribute("subject"),
+ error: "Error parsing template: <binding> requires a variable for its subject attribute",
+ post: () => $("binding").setAttribute("subject", "?child"),
+},
+
+// bad binding predicate
+{
+ pre: template => $("binding").removeAttribute("predicate"),
+ error: "Error parsing template: <binding> element is missing a predicate attribute",
+ post: () => $("binding").setAttribute("predicate", "http://www.some-fictitious-zoo.com/rdf#name"),
+},
+
+// bad binding object
+{
+ pre: template => $("binding").setAttribute("object", "blah"),
+ error: "Error parsing template: <binding> requires a variable for its object attribute",
+ post: () => $("binding").setAttribute("object", "?name"),
+},
+
+// where condition missing a subject
+{
+ pre: function(template) { var rule = $("rule");
+ var where = document.createElement("where");
+ where.setAttribute("subject", "");
+ where.setAttribute("rel", "equals");
+ where.setAttribute("value", "Raven");
+ rule.appendChild(where);
+ return where; },
+ error: "Error parsing template: <where> element is missing a subject attribute",
+ post: function(where) { where.parentNode.removeChild(where); }
+},
+
+// where condition missing a rel
+{
+ pre: function(template) { var rule = $("rule");
+ var where = document.createElement("where");
+ where.setAttribute("subject", "?name");
+ where.setAttribute("rel", "");
+ where.setAttribute("value", "Raven");
+ rule.appendChild(where);
+ return where; },
+ error: "Error parsing template: <where> element is missing a rel attribute",
+ post: function(where) { where.parentNode.removeChild(where); }
+},
+
+// where condition missing a value
+{
+ pre: function(template) { var rule = $("rule");
+ var where = document.createElement("where");
+ where.setAttribute("subject", "?name");
+ where.setAttribute("rel", "equals");
+ where.setAttribute("value", "");
+ rule.appendChild(where);
+ return where; },
+ error: "Error parsing template: <where> element is missing a value attribute",
+ post: function(where) { where.parentNode.removeChild(where); }
+},
+
+// where condition missing a variable
+{
+ pre: function(template) { var rule = $("rule");
+ var where = document.createElement("where");
+ where.setAttribute("subject", "name");
+ where.setAttribute("rel", "equals");
+ where.setAttribute("value", "Raven");
+ rule.appendChild(where);
+ return where; },
+ error: "Error parsing template: <where> element must have at least one variable as a subject or value",
+ post: function(where) { where.parentNode.removeChild(where); }
+},
+
+// bad member container
+{
+ pre: template => $("member").setAttribute("container", "blah"),
+ error: "Error parsing template: <member> requires a variable for its container attribute",
+ post: () => $("member").setAttribute("container", "?uri"),
+},
+
+// bad member child
+{
+ pre: template => $("member").setAttribute("child", "blah"),
+ error: "Error parsing template: <member> requires a variable for its child attribute",
+ post: () => $("member").setAttribute("child", "?child"),
+},
+
+// bad triple subject
+{
+ pre: template => $("triple").removeAttribute("subject"),
+ error: "Error parsing template: <triple> requires a variable for its subject attribute",
+ post: () => $("triple").setAttribute("subject", "?child"),
+},
+
+// missing triple predicate
+{
+ pre: template => $("triple").removeAttribute("predicate"),
+ error: "Error parsing template: <triple> should have a non-variable value as a predicate",
+ post: () => $("triple").setAttribute("predicate", "http://www.some-fictitious-zoo.com/rdf#name"),
+},
+
+// bad triple predicate
+{
+ pre: template => $("triple").setAttribute("predicate", "?predicate"),
+ error: "Error parsing template: <triple> should have a non-variable value as a predicate",
+ post: () => $("triple").setAttribute("predicate", "http://www.some-fictitious-zoo.com/rdf#name"),
+},
+
+// bad triple object
+{
+ pre: template => $("triple").removeAttribute("object"),
+ error: "Error parsing template: <triple> requires a variable for its object attribute",
+ post: () => $("triple").setAttribute("object", "?name"),
+},
+
+// content not first element in query
+{
+ pre: function(template) { var content = $("content"); content.parentNode.appendChild(content); return content; },
+ error: "Error parsing template: expected <content> to be first",
+ post: content => content.parentNode.insertBefore(content, content.parentNode.firstChild),
+},
+
+// member container variable not bound
+{
+ pre: template => $("member").removeAttribute("container"),
+ error: "Error parsing template: neither container or child variables of <member> has a value",
+ post: () => $("member").setAttribute("container", "?uri"),
+},
+
+// neither triple subject or object variable are bound
+{
+ pre: template => $("triple").setAttribute("subject", "?blah"),
+ error: "Error parsing template: neither subject or object variables of <triple> has a value",
+ post: () => $("triple").setAttribute("subject", "?child"),
+},
+
+// neither triple subject or object variable are bound
+{
+ pre: function(template) { var triple = $("triple"); triple.setAttribute("subject", "blah");
+ triple.setAttribute("object", "blah"); },
+ error: "Error parsing template: <triple> should have at least one variable as a subject or object",
+ post: function() { var triple = $("triple"); triple.setAttribute("subject", "?uri");
+ triple.setAttribute("object", "?uri") }
+},
+
+// could not parse xml query expression
+{
+ firstXMLTest: true,
+ pre: function(template) { $("query").setAttribute("expr", "something()"); },
+ error: "Error parsing template: XPath expression in query could not be parsed",
+ post: function() { }
+},
+
+// could not parse xml assign expression
+{
+ pre: function(template) { var query = $("query");
+ query.setAttribute("expr", "*");
+ var assign = document.createElement("assign");
+ assign.setAttribute("var", "?name");
+ assign.setAttribute("expr", "something()");
+ query.appendChild(assign);
+ return assign; },
+ error: "Error parsing template: XPath expression in <assign> could not be parsed",
+ post: function(assign) { assign.parentNode.removeChild(assign); }
+},
+
+// could not parse xml binding expression
+{
+ pre: function(template) { $("binding").setAttribute("predicate", "something()"); },
+ error: "Error parsing template: XPath expression in <binding> could not be parsed",
+ post: function() { $("binding").setAttribute("predicate", "[name]"); },
+},
+
+];
+
+function runTest()
+{
+ var root = $("root");
+ var template = $("template");
+ while (test = tests.shift()) {
+ consoleService.reset();
+ var context = test.pre(template);
+ root.builder.rebuild();
+ checkConsole(test.error);
+ test.post(context);
+
+ // preload and set up for the xml datasource query error tests
+ if (tests.length && tests[0].firstXMLTest) {
+ var src = window.location.href.replace(/test_tmpl.*xul/, "animals.xml");
+ xmlDoc = new XMLHttpRequest();
+ xmlDoc.open("get", src, false);
+ xmlDoc.send(null);
+
+ var root = $("root");
+ root.setAttribute("querytype", "xml");
+ root.setAttribute("datasources", "animals.xml");
+ $("binding").setAttribute("predicate", "[name]");
+
+ function waitForDatasource() {
+ // wait for the datasource to be available before continuing the test
+ if (root.builder.datasource instanceof XMLDocument)
+ runTest();
+ else
+ setTimeout(waitForDatasource, 100);
+ }
+
+ setTimeout(waitForDatasource, 0);
+ return;
+ }
+ }
+ SimpleTest.finish();
+}
+
+]]>
+</script>
+
+<vbox id="root" datasources="animals.rdf" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+ <query id="query">
+ <content id="content" uri="?uri"/>
+ <member id="member" container="?uri" child="?child"/>
+ <triple id="triple" subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+ </query>
+ <rule id="rule">
+ <binding id="binding" subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+ <action id="action">
+ <label uri="?child" value="?name"/>
+ </action>
+ </rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntax.xul
new file mode 100644
index 000000000..1bd31525e
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntax.xul
@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ extended syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="extended syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+<rule id="rule">
+<conditions id="conditions">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxemptyconditions.xul b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxemptyconditions.xul
new file mode 100644
index 000000000..8e0e37c3a
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxemptyconditions.xul
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ extended syntax - empty conditions
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="extended syntax - empty conditions";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+<rule id="rule">
+<conditions id="conditions"/>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxotherrefvariable.xul b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxotherrefvariable.xul
new file mode 100644
index 000000000..6895034f2
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxotherrefvariable.xul
@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ extended syntax - other ref variable
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="extended syntax - other ref variable";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+<rule id="rule">
+<conditions id="conditions">
+<content uri="?start"/>
+<member container="?start" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxremoveunmatched.xul b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxremoveunmatched.xul
new file mode 100644
index 000000000..b2ef77d9e
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxremoveunmatched.xul
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ extended syntax, remove unmatched
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert Sanderson"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="extended syntax, remove unmatched";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
+<template id="template">
+<rule>
+<conditions>
+<content uri="?uri"/>
+<member container="?uri" child="?human"/>
+<triple subject="?human" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?human" predicate="http://www.some-fictitious-zoo.com/rdf#lastName" object="?lastname"/>
+</conditions>
+<action id="action">
+<label uri="?human" value="?name ?lastname"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxsimplevariablesubstitution.xul b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxsimplevariablesubstitution.xul
new file mode 100644
index 000000000..d38bd96c0
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxsimplevariablesubstitution.xul
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ extended syntax - simple variable substitution
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value=""/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="extended syntax - simple variable substitution";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<rule id="rule">
+<conditions id="conditions">
+<content uri="?start"/>
+<member container="?start" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxtworulesrecurse.xul b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxtworulesrecurse.xul
new file mode 100644
index 000000000..d0e4faadf
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxtworulesrecurse.xul
@@ -0,0 +1,81 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ extended syntax - two rules recurse
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <vbox id="http://www.some-fictitious-zoo.com/humans/sarah">
+ <label value="The favorite animals of Sarah"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/emu" class="indent" value="Emu which belongs to the class Birds"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" class="indent" value="Polar Bear which belongs to the class Mammals"/>
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" class="indent" value="Tarantula which belongs to the class Arachnids"/>
+ </vbox>
+ <vbox id="http://www.some-fictitious-zoo.com/humans/robert">
+ <label value="The favorite animals of Robert"/>
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" class="indent" value="Tarantula which belongs to the class Arachnids"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" class="indent" value="Anaconda which belongs to the class Reptiles"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" class="indent" value="Chameleon which belongs to the class Reptiles"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" class="indent" value="African Elephant which belongs to the class Mammals"/>
+ </vbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="extended syntax - two rules recurse";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
+<template>
+<rule>
+<conditions>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action>
+<vbox uri="?child">
+<label value="The favorite animals of ?name"/>
+</vbox>
+</action>
+</rule>
+<rule>
+<conditions>
+<content uri="?uri"/>
+<triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#favoriteAnimal" object="?child"/>
+<member container="?animalClass" child="?child"/>
+<triple subject="?animalClass" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" object="http://www.some-fictitious-zoo.com/rdf#Class"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?animalClass" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?animalClassName"/>
+</conditions>
+<action>
+<label uri="?child" class="indent" value="?name which belongs to the class ?animalClassName"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxusinganinterveningcontainer.xul b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxusinganinterveningcontainer.xul
new file mode 100644
index 000000000..2e9ce8a2f
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxusinganinterveningcontainer.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ extended syntax using an intervening container
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <groupbox>
+ <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+ </groupbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="extended syntax using an intervening container";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+<rule id="rule">
+<conditions id="conditions">
+<content uri="?start"/>
+<member container="?start" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action id="action">
+<groupbox>
+<label uri="?animal" value="?name"/>
+</groupbox>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_extendedvariablesubstitution.xul b/dom/xul/templates/tests/chrome/test_tmpl_extendedvariablesubstitution.xul
new file mode 100644
index 000000000..deee822dd
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_extendedvariablesubstitution.xul
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ extended variable substitution
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula? - TarantulaTarantula^ Test"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="extended variable substitution";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<rule id="rule">
+<conditions id="conditions">
+<content uri="?start"/>
+<member container="?start" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name^?? ?name?name - ?name^?name^^ Test"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_gridelement.xul b/dom/xul/templates/tests/chrome/test_tmpl_gridelement.xul
new file mode 100644
index 000000000..12575c6b8
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_gridelement.xul
@@ -0,0 +1,131 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ grid element
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <columns>
+ <column/>
+ <column/>
+ </columns>
+ <rows>
+ <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="The coolest animal is: Wren"/>
+ <row id="http://www.some-fictitious-zoo.com/birds/emu">
+ <label value="Emu"/>
+ <label value="Birds"/>
+ </row>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="The coolest animal is: Barn Owl"/>
+ <row id="http://www.some-fictitious-zoo.com/birds/raven">
+ <label value="Raven"/>
+ <label value="Birds"/>
+ </row>
+ <row step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+ <label value="Archaeopteryx"/>
+ <label value="Birds"/>
+ </row>
+ <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="The coolest animal is: Emperor Penguin"/>
+ </rows>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="grid element";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<grid xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<columns>
+<column/>
+<column/>
+</columns>
+<template>
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?classname"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions>
+<where subject="?name" rel="equals" value="Raven" negate="true"/>
+<where subject="?name" rel="contains" value="n"/>
+</conditions>
+<action>
+<rows>
+<label uri="?child" value="The coolest animal is: ?name"/>
+</rows>
+</action>
+</rule>
+<rule>
+<action>
+<rows>
+<row uri="?child">
+<label value="?name"/>
+<label value="?classname"/>
+</row>
+</rows>
+</action>
+</rule>
+</template>
+</grid>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_htmlelementextendedsyntaxwithbinding.xul b/dom/xul/templates/tests/chrome/test_tmpl_htmlelementextendedsyntaxwithbinding.xul
new file mode 100644
index 000000000..a9a14e00a
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_htmlelementextendedsyntaxwithbinding.xul
@@ -0,0 +1,114 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ html element - extended syntax with binding
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" xmlns:html="http://www.w3.org/1999/xhtml">
+ <html:div id="http://www.some-fictitious-zoo.com/mammals/lion" title="Lion">
+ <html:em step="-2">4</html:em>
+ <html:em step="2">9</html:em>
+ </html:div>
+ <html:div id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" title="HIPPOPOTAMUS">
+ <html:em>2</html:em>
+ </html:div>
+ <html:p id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
+ African Elephant
+ <html:span title="14"/>
+ </html:p>
+ <html:p step="4" id="http://www.some-fictitious-zoo.com/mammals/chimpanzee">
+ Chimpanzee
+ <html:span step="-5"/>
+ <html:span step="5" title="3"/>
+ </html:p>
+ <html:div id="http://www.some-fictitious-zoo.com/mammals/llama" title="LLAMA">
+ <html:em>5</html:em>
+ </html:div>
+ <html:div id="http://www.some-fictitious-zoo.com/mammals/polarbear" title="Polar Bear">
+ <html:em step="-1">20</html:em>
+ <html:em step="1">5</html:em>
+ </html:div>
+ <html:div id="http://www.some-fictitious-zoo.com/mammals/aardvark" title="aardvark">
+ <html:em>2</html:em>
+ </html:div>
+ <html:p step="-3" id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+ Nine-banded Armadillo
+ <html:span title="1"/>
+ </html:p>
+ <html:div id="http://www.some-fictitious-zoo.com/mammals/gorilla" title="Gorilla">
+ <html:em>7</html:em>
+ </html:div>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="html element - extended syntax with binding";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'mammals/polarbear');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'mammals/polarbear'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('5'));
+ },
+ // step 2
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'mammals/lion');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'mammals/lion'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('9'));
+ },
+ // step 3
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('7', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Nine-banded Armadillo'), true);
+ },
+ // step 4
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/chimpanzee');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Chimpanzee'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 5
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/chimpanzee'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ RDF.GetLiteral('3'), true);
+ }
+];
+]]>
+</script>
+
+<div xmlns="http://www.w3.org/1999/xhtml" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals"><template xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="template"><rule><conditions><content uri="?uri"/><member container="?uri" child="?animal"/><triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/><where subject="?name" rel="contains" value="an"/></conditions><bindings><binding subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/></bindings><action><p xmlns="http://www.w3.org/1999/xhtml" uri="?animal"><textnode xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" value="?name"/><span title="?specimens"/></p></action></rule><rule><conditions><content uri="?uri"/><member container="?uri" child="?animal"/><triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/></conditions><bindings><binding subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/></bindings><action><div xmlns="http://www.w3.org/1999/xhtml" uri="?animal" title="?name"><em><textnode xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" value="?specimens"/></em></div></action></rule></template></div>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxrecursive.xul b/dom/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxrecursive.xul
new file mode 100644
index 000000000..b03f20ce2
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxrecursive.xul
@@ -0,0 +1,81 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ html element - query syntax recursive
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" xmlns:html="http://www.w3.org/1999/xhtml">
+ <html:strong id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false">Arachnids</html:strong>
+ <html:strong step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+ Birds
+ <html:span id="http://www.some-fictitious-zoo.com/birds/barnowl">Barn Owl</html:span>
+ </html:strong>
+ <html:strong step="1" id="http://www.some-fictitious-zoo.com/insects">Insects</html:strong>
+ <html:strong id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+ Mammals
+ <html:span id="http://www.some-fictitious-zoo.com/mammals/lion">Lion</html:span>
+ <html:span id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">HIPPOPOTAMUS</html:span>
+ <html:span step="2" id="http://www.some-fictitious-zoo.com/mammals/koala">Koala</html:span>
+ <html:span id="http://www.some-fictitious-zoo.com/mammals/polarbear">Polar Bear</html:span>
+ <html:span id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">Nine-banded Armadillo</html:span>
+ <html:span id="http://www.some-fictitious-zoo.com/mammals/gorilla">Gorilla</html:span>
+ </html:strong>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="html element - query syntax recursive";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'insects');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Insects'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'all-animals'));
+ container.InsertElementAt(newnode, '3', true);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'all-animals'));
+ var removednode = container.RemoveElementAt('2', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Birds'), true);
+ }
+];
+]]>
+</script>
+
+<div xmlns="http://www.w3.org/1999/xhtml" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/all-animals"><template xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="template"><query><content uri="?uri"/><member container="?uri" child="?child"/><triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/></query><rule><conditions><where subject="?name" rel="endswith" multiple="true" value="mals,ects,nids,irds"/></conditions><action><strong xmlns="http://www.w3.org/1999/xhtml" uri="?child"><textnode xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" value="?name"/></strong></action></rule><rule><conditions><where subject="?uri" rel="equals" negate="true" value="http://www.some-fictitious-zoo.com/all-animals"/><where subject="?name" rel="contains" ignorecase="true" value="o"/></conditions><action><span xmlns="http://www.w3.org/1999/xhtml" uri="?child"><textnode xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" value="?name"/></span></action></rule></template></div>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxwithmultiplerules.xul b/dom/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxwithmultiplerules.xul
new file mode 100644
index 000000000..e0ef6a732
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxwithmultiplerules.xul
@@ -0,0 +1,102 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ html element - query syntax with multiple rules
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" xmlns:html="http://www.w3.org/1999/xhtml">
+ <html:span step="-2" id="http://www.some-fictitious-zoo.com/mammals/lion">Lion</html:span>
+ <html:span id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">HIPPOPOTAMUS</html:span>
+ <vbox>
+ <html:p step="2" id="http://www.some-fictitious-zoo.com/mammals/lion">
+ <html:span title="Lion"/>
+ </html:p>
+ <html:p id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
+ <html:span title="African Elephant"/>
+ </html:p>
+ <html:p step="-1" id="http://www.some-fictitious-zoo.com/mammals/polarbear">
+ <html:span title="Polar Bear"/>
+ </html:p>
+ <html:p id="http://www.some-fictitious-zoo.com/mammals/gorilla">
+ <html:span title="Gorilla"/>
+ </html:p>
+ </vbox>
+ <html:span step="5" id="http://www.some-fictitious-zoo.com/mammals/chimpanzee">Chimpanzee</html:span>
+ <html:span id="http://www.some-fictitious-zoo.com/mammals/llama">LLAMA</html:span>
+ <html:span step="1" id="http://www.some-fictitious-zoo.com/mammals/polarbear">Polar Bear</html:span>
+ <html:span id="http://www.some-fictitious-zoo.com/mammals/aardvark">aardvark</html:span>
+ <html:span step="-3" id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">Nine-banded Armadillo</html:span>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="html element - query syntax with multiple rules";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = true;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'mammals/polarbear');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'mammals/polarbear'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('5'));
+ },
+ // step 2
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'mammals/lion');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'mammals/lion'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('9'));
+ },
+ // step 3
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('7', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Nine-banded Armadillo'), true);
+ },
+ // step 4
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/chimpanzee');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Chimpanzee'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 5
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/chimpanzee'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ RDF.GetLiteral('3'), true);
+ }
+];
+]]>
+</script>
+
+<div xmlns="http://www.w3.org/1999/xhtml" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals"><template xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="template"><query><content uri="?uri"/><member container="?uri" child="?animal"/><triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/><triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/></query><rule><conditions id="conditions"><where subject="?specimens" rel="greater" value="6"/></conditions><action><vbox><p xmlns="http://www.w3.org/1999/xhtml" uri="?animal"><span title="?name"/></p></vbox></action></rule><rule><action><span xmlns="http://www.w3.org/1999/xhtml" uri="?animal"><textnode xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" value="?name"/></span></action></rule></template></div>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntax.xul
new file mode 100644
index 000000000..95c016fe8
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntax.xul
@@ -0,0 +1,81 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ html element - simple syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" xmlns:html="http://www.w3.org/1999/xhtml">
+ <html:p step="3" id="http://www.some-fictitious-zoo.com/birds/wren" title="Wren"/>
+ <html:p id="http://www.some-fictitious-zoo.com/birds/emu" title="Emu"/>
+ <html:p step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" title="Barn Owl"/>
+ <html:p id="http://www.some-fictitious-zoo.com/birds/raven" title="Raven"/>
+ <html:p step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" title="Archaeopteryx"/>
+ <html:p step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" title="Emperor Penguin"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="html element - simple syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<div xmlns="http://www.w3.org/1999/xhtml" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds"><template xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"><p xmlns="http://www.w3.org/1999/xhtml" uri="rdf:*" title="rdf:http://www.some-fictitious-zoo.com/rdf#name"/></template></div>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntaxusingatextnode.xul b/dom/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntaxusingatextnode.xul
new file mode 100644
index 000000000..14d8bab38
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntaxusingatextnode.xul
@@ -0,0 +1,81 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ html element - simple syntax using a textnode
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" xmlns:html="http://www.w3.org/1999/xhtml">
+ <html:p step="3" id="http://www.some-fictitious-zoo.com/birds/wren">Wren</html:p>
+ <html:p id="http://www.some-fictitious-zoo.com/birds/emu">Emu</html:p>
+ <html:p step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">Barn Owl</html:p>
+ <html:p id="http://www.some-fictitious-zoo.com/birds/raven">Raven</html:p>
+ <html:p step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">Archaeopteryx</html:p>
+ <html:p step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">Emperor Penguin</html:p>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="html element - simple syntax using a textnode";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<div xmlns="http://www.w3.org/1999/xhtml" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds"><template xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"><p xmlns="http://www.w3.org/1999/xhtml" uri="rdf:*"><textnode xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/></p></template></div>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_invalidqp.xul b/dom/xul/templates/tests/chrome/test_tmpl_invalidqp.xul
new file mode 100644
index 000000000..2231f2067
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_invalidqp.xul
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ invalid syntax - querytype="blah"
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="invalid syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+Components.classes["@mozilla.org/consoleservice;1"].
+ getService(Components.interfaces.nsIConsoleService).reset();
+expectedConsoleMessages.push("Error parsing template: querytype attribute doesn't specify a valid query processor");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null"
+ ref="http://www.some-fictitious-zoo.com/birds" querytype="blah">
+<template zoo:name="Barn Owl" xmlns:zoo="http://www.some-fictitious-zoo.com/rdf#">
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_listboxelement.xul b/dom/xul/templates/tests/chrome/test_tmpl_listboxelement.xul
new file mode 100644
index 000000000..e754b1542
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_listboxelement.xul
@@ -0,0 +1,117 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ listbox element
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <listcols>
+ <listcol flex="1"/>
+ <listcol flex="1"/>
+ </listcols>
+ <listitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
+ <listcell label="Wren"/>
+ <listcell label=""/>
+ </listitem>
+ <listitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <listcell label="Emu"/>
+ <listcell label="Dromaius novaehollandiae"/>
+ </listitem>
+ <listitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <listcell label="Barn Owl"/>
+ <listcell label="Tyto alba"/>
+ </listitem>
+ <listitem id="http://www.some-fictitious-zoo.com/birds/raven">
+ <listcell label="Raven"/>
+ <listcell label="Corvus corax"/>
+ </listitem>
+ <listitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+ <listcell label="Archaeopteryx"/>
+ <listcell label=""/>
+ </listitem>
+ <listitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
+ <listcell label="Emperor Penguin"/>
+ <listcell label=""/>
+ </listitem>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.expectAssertions(4);
+
+SimpleTest.waitForExplicitFinish();
+
+var testid ="listbox element";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<listcols>
+<listcol flex="1"/>
+<listcol flex="1"/>
+</listcols>
+<template>
+<listitem uri="rdf:*">
+<listcell label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+<listcell label="rdf:http://www.some-fictitious-zoo.com/rdf#species"/>
+</listitem>
+</template>
+</listbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_literalasmember.xul b/dom/xul/templates/tests/chrome/test_tmpl_literalasmember.xul
new file mode 100644
index 000000000..5e2ffe326
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_literalasmember.xul
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ literal as member
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="literal as member";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<rule id="rule">
+<conditions id="conditions">
+<content uri="?start"/>
+<member container="?start" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action id="action">
+<label uri="?name" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_membervariablechanged.xul b/dom/xul/templates/tests/chrome/test_tmpl_membervariablechanged.xul
new file mode 100644
index 000000000..c231b8670
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_membervariablechanged.xul
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ member variable changed
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button id="http://www.some-fictitious-zoo.com/birds/emu" label="http://www.some-fictitious-zoo.com/birds/emu Emu"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="http://www.some-fictitious-zoo.com/birds/barnowl Barn Owl"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/raven" label="http://www.some-fictitious-zoo.com/birds/raven Raven"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="member variable changed";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template member="?child">
+<rule>
+<button uri="?child" label="?child rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_membervariablesubstitution.xul b/dom/xul/templates/tests/chrome/test_tmpl_membervariablesubstitution.xul
new file mode 100644
index 000000000..512717934
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_membervariablesubstitution.xul
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ member variable substitution
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="http://www.some-fictitious-zoo.com/arachnids/tarantula"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="member variable substitution";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<rule id="rule">
+<conditions id="conditions">
+<content uri="?start"/>
+<member container="?start" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?animal"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_menuelement.xul b/dom/xul/templates/tests/chrome/test_tmpl_menuelement.xul
new file mode 100644
index 000000000..eecb6a7ed
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_menuelement.xul
@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ menu element
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <menupopup>
+ <menuitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+ <menuitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ <menuitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+ <menuitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ <menuitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+ <menuitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+ </menupopup>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="menu element";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = true;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<button xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" type="menu" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template>
+<menupopup>
+<menuitem uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</menupopup>
+</template>
+</button>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_menuelementrecursive.xul b/dom/xul/templates/tests/chrome/test_tmpl_menuelementrecursive.xul
new file mode 100644
index 000000000..1597e3164
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_menuelementrecursive.xul
@@ -0,0 +1,121 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ menu element recursive
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template()"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <menupopup>
+ <menuitem id="http://www.some-fictitious-zoo.com/arachnids" label="Arachnids" container="true" empty="false"/>
+ <menu step="-2" id="http://www.some-fictitious-zoo.com/birds" label="Birds" container="true" empty="false"/>
+ <menu step="2" id="http://www.some-fictitious-zoo.com/birds" label="Birds" container="true" empty="false" open="true">
+ <menupopup>
+ <menuitem step="4" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+ <menuitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ <menuitem step="-5" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+ <menuitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ <menuitem step="3" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+ <menuitem id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+ </menupopup>
+ </menu>
+ <menuitem id="http://www.some-fictitious-zoo.com/crustaceans" label="Crustaceans" container="true" empty="true"/>
+ <menuitem id="http://www.some-fictitious-zoo.com/fish" label="Fish" container="true" empty="false"/>
+ <menuitem id="http://www.some-fictitious-zoo.com/mammals" label="Mammals" container="true" empty="false"/>
+ <menuitem id="http://www.some-fictitious-zoo.com/reptiles" label="Reptiles" container="true" empty="false"/>
+ </menupopup>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="menu element recursive";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = true;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ // nothing should change at this step as the submenu is not open
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ // open the submenu
+ root.lastChild.firstChild.nextSibling.open = true;
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ root.lastChild.firstChild.nextSibling.open = true;
+ },
+ // step 4
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ root.lastChild.firstChild.nextSibling.open = true;
+ },
+ // step 5
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ root.lastChild.firstChild.nextSibling.open = true;
+ }
+];
+]]>
+</script>
+
+<button xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" type="menu" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/all-animals">
+<template>
+<rule iscontainer="true" zoo:name="Birds" xmlns:zoo="http://www.some-fictitious-zoo.com/rdf#">
+<menupopup>
+<menu uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</menupopup>
+</rule>
+<rule parent="button">
+<menupopup>
+<menuitem uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</menupopup>
+</rule>
+<rule parent="menu">
+<menupopup>
+<menuitem uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</menupopup>
+</rule>
+</template>
+</button>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_menulistelement.xul b/dom/xul/templates/tests/chrome/test_tmpl_menulistelement.xul
new file mode 100644
index 000000000..bebc7b970
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_menulistelement.xul
@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ menulist element
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="$('root').selectedItem = null; test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <menupopup>
+ <menuitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+ <menuitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ <menuitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+ <menuitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ <menuitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+ <menuitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+ </menupopup>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="menulist element";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<menulist xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template>
+<menupopup>
+<menuitem uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</menupopup>
+</template>
+</menulist>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainer.xul b/dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainer.xul
new file mode 100644
index 000000000..446fa77ec
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainer.xul
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ mixed syntax - iscontainer
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <checkbox id="http://www.some-fictitious-zoo.com/humans/sarah" label="Sarah"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" label="Mammals"/>
+ <button id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" label="Crustaceans"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="mixed syntax - iscontainer";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/sarah'),
+ RDF.GetResource(ZOO_NS + 'rdf#pets'),
+ RDF.GetResource(ZOO_NS + 'sarahs-pets'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" flags="dont-recurse">
+<template id="template">
+<rule id="rule1" iscontainer="true">
+<button uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</rule>
+<rule>
+<conditions>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action>
+<checkbox uri="?child" label="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainerisempty.xul b/dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainerisempty.xul
new file mode 100644
index 000000000..2c3a3e23c
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainerisempty.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ mixed syntax - iscontainer isempty
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <checkbox id="http://www.some-fictitious-zoo.com/humans/sarah" label="Sarah"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" label="Mammals"/>
+ <label id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" value="Crustaceans"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="mixed syntax - iscontainer isempty";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" flags="dont-recurse">
+<template id="template">
+<rule id="rule1" iscontainer="true" isempty="true">
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</rule>
+<rule>
+<conditions>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action>
+<checkbox uri="?child" label="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxisempty.xul b/dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxisempty.xul
new file mode 100644
index 000000000..25b5d59a0
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxisempty.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ mixed syntax - isempty
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/humans/sarah" value="Sarah"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" label="Mammals"/>
+ <label id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" value="Crustaceans"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="mixed syntax - isempty";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" flags="dont-recurse">
+<template id="template">
+<rule id="rule1" isempty="true">
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</rule>
+<rule>
+<conditions>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action>
+<checkbox uri="?child" label="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_noaction.xul b/dom/xul/templates/tests/chrome/test_tmpl_noaction.xul
new file mode 100644
index 000000000..f03623e09
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_noaction.xul
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ no action
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="no action";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template>
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<button uri="?child" label="?name"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_noactionuriattribute.xul b/dom/xul/templates/tests/chrome/test_tmpl_noactionuriattribute.xul
new file mode 100644
index 000000000..bd14bee1f
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_noactionuriattribute.xul
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ no action uri attribute
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label value="Tarantula"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="no action uri attribute";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Hairy Spider'));
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<label value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_parentconditions.xul b/dom/xul/templates/tests/chrome/test_tmpl_parentconditions.xul
new file mode 100644
index 000000000..dae20a830
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_parentconditions.xul
@@ -0,0 +1,113 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ parent - conditions
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <box step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+ <label value="Birds"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ </box>
+ <box step="1" id="http://www.some-fictitious-zoo.com/insects">
+ <label value="Insects"/>
+ </box>
+ <box id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <label value="Crustaceans"/>
+ </box>
+ <box id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+ <label value="Mammals"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+ <button step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" label="Koala"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
+ </box>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="parent - conditions";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'insects');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Insects'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'all-animals'));
+ container.InsertElementAt(newnode, '3', true);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'all-animals'));
+ var removednode = container.RemoveElementAt('2', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Birds'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template>
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?parent"/>
+<triple subject="?parent" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions parent="box">
+<where subject="?name" rel="contains" value="a"/>
+</conditions>
+<action>
+<button uri="?parent" label="?name"/>
+</action>
+</rule>
+<rule>
+<conditions>
+<where subject="?name" rel="equals" multiple="true" value="Mammals,Crustaceans,Birds,Insects"/>
+</conditions>
+<action>
+<box uri="?parent">
+<label value="?name"/>
+</box>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_parentcontenttag.xul b/dom/xul/templates/tests/chrome/test_tmpl_parentcontenttag.xul
new file mode 100644
index 000000000..afcb1d34a
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_parentcontenttag.xul
@@ -0,0 +1,114 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ parent - content tag
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <groupbox step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+ <caption value="Birds"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ </groupbox>
+ <groupbox step="1" id="http://www.some-fictitious-zoo.com/insects">
+ <caption value="Insects"/>
+ </groupbox>
+ <groupbox id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <caption value="Crustaceans"/>
+ </groupbox>
+ <groupbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+ <caption value="Mammals"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+ <checkbox step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" label="Koala"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
+ </groupbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="parent - content tag";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'insects');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Insects'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'all-animals'));
+ container.InsertElementAt(newnode, '3', true);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'all-animals'));
+ var removednode = container.RemoveElementAt('2', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Birds'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template>
+<rule>
+<conditions>
+<content uri="?uri" tag="groupbox"/>
+<member container="?uri" child="?parent"/>
+<triple subject="?parent" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<where subject="?name" rel="contains" value="a"/>
+</conditions>
+<action>
+<checkbox uri="?parent" label="?name"/>
+</action>
+</rule>
+<rule>
+<conditions>
+<content uri="?uri"/>
+<member container="?uri" child="?parent"/>
+<triple subject="?parent" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<where subject="?name" rel="equals" multiple="true" value="Mammals,Crustaceans,Birds,Insects"/>
+</conditions>
+<action>
+<groupbox uri="?parent">
+<caption value="?name"/>
+</groupbox>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_parentsimplesyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_parentsimplesyntax.xul
new file mode 100644
index 000000000..c5d94e0e2
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_parentsimplesyntax.xul
@@ -0,0 +1,110 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ parent - simple syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+ <label value="Birds"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ </hbox>
+ <hbox step="1" id="http://www.some-fictitious-zoo.com/insects">
+ <label value="Insects"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <label value="Crustaceans"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+ <label value="Mammals"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+ <button step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" label="Koala"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="parent - simple syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'insects');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Insects'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'all-animals'));
+ container.InsertElementAt(newnode, '3', true);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'all-animals'));
+ var removednode = container.RemoveElementAt('2', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Birds'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template member="?parent">
+<rule parent="hbox">
+<button uri="?parent" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</rule>
+<rule>
+<conditions>
+<content uri="?uri"/>
+<member container="?uri" child="?parent"/>
+<triple subject="?parent" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<where subject="?name" rel="equals" multiple="true" value="Mammals,Crustaceans,Birds,Insects"/>
+</conditions>
+<action>
+<hbox uri="?parent">
+<label value="?name"/>
+</hbox>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_query3triples.xul b/dom/xul/templates/tests/chrome/test_tmpl_query3triples.xul
new file mode 100644
index 000000000..c0114effe
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_query3triples.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - 3 triples
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" unordered="true">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Robert likes Tarantulas"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Robert likes Anacondas"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Robert likes Chameleons"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="Robert likes African Elephants"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - 3 triples";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?humanname"/>
+<triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#favoriteAnimal" object="?favoriteAnimal"/>
+<triple subject="?favoriteAnimal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?animalname"/>
+</query>
+<rule>
+<conditions id="conditions"/>
+<action>
+<label uri="?favoriteAnimal" value="?humanname likes ?animalname^s"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_query3tripleswherecontains.xul b/dom/xul/templates/tests/chrome/test_tmpl_query3tripleswherecontains.xul
new file mode 100644
index 000000000..98006fc0d
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_query3tripleswherecontains.xul
@@ -0,0 +1,111 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - 3 triples - where contains
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Robert likes Tarantulas"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="Robert likes African Elephants"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="Robert likes African Elephants"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - 3 triples - where contains";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Arctic Hare'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Zebra'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('4', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 6
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'),
+ RDF.GetLiteral('8'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?humanname"/>
+<triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#favoriteAnimal" object="?favoriteAnimal"/>
+<triple subject="?favoriteAnimal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?animalname"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?favoriteAnimal" rel="contains" value="ant"/>
+</conditions>
+<action>
+<label uri="?favoriteAnimal" value="?humanname likes ?animalname^s"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querymember3tripleswhereequals.xul b/dom/xul/templates/tests/chrome/test_tmpl_querymember3tripleswhereequals.xul
new file mode 100644
index 000000000..8604a1321
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querymember3tripleswhereequals.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - member, 3 triples - where equals
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" unordered="true">
+ <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Sarah likes Emus"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Sarah likes Polar Bears"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - member, 3 triples - where equals";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?human"/>
+<triple subject="?human" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?humanname"/>
+<triple subject="?human" predicate="http://www.some-fictitious-zoo.com/rdf#favoriteAnimal" object="?favoriteAnimal"/>
+<triple subject="?favoriteAnimal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?animalname"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?humanname" rel="equals" value="Sarah"/>
+</conditions>
+<action>
+<label uri="?favoriteAnimal" value="?humanname likes ?animalname^s"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querymemberandtwotriples.xul b/dom/xul/templates/tests/chrome/test_tmpl_querymemberandtwotriples.xul
new file mode 100644
index 000000000..9f3f36288
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querymemberandtwotriples.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - member and two triples
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" unordered="true">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - member and two triples";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?human"/>
+<triple subject="?human" predicate="http://www.some-fictitious-zoo.com/rdf#favoriteAnimal" object="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+,<action>
+<label uri="?child" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querymembertriplemembertriple.xul b/dom/xul/templates/tests/chrome/test_tmpl_querymembertriplemembertriple.xul
new file mode 100644
index 000000000..b5b3acf79
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querymembertriplemembertriple.xul
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - member, triple, member, triple
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" unordered="true">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label step="-1" id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - member, triple, member, triple";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/sarah'),
+ RDF.GetResource(ZOO_NS + 'rdf#pets'),
+ RDF.GetResource(ZOO_NS + 'sarahs-pets'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?human"/>
+<triple subject="?human" predicate="http://www.some-fictitious-zoo.com/rdf#pets" object="?pets"/>
+<member container="?pets" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+,<action>
+<label uri="?child" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_queryresourcematch.xul b/dom/xul/templates/tests/chrome/test_tmpl_queryresourcematch.xul
new file mode 100644
index 000000000..b13ccdb7f
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_queryresourcematch.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - resource match
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false" value="Arachnids"/>
+ <label id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false" value="Birds"/>
+ <label id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" value="Crustaceans"/>
+ <label id="http://www.some-fictitious-zoo.com/fish" container="true" empty="false" value="Fish"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" value="Mammals"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles" container="true" empty="false" value="Reptiles"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - resource match";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" object="http://www.some-fictitious-zoo.com/rdf#Class"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+,<action>
+<label uri="?child" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_queryreversetriple.xul b/dom/xul/templates/tests/chrome/test_tmpl_queryreversetriple.xul
new file mode 100644
index 000000000..633df8834
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_queryreversetriple.xul
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - reverse triple
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/reptiles" container="true" empty="false" value="Reptiles"/>
+ <label id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" value="Crustaceans"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - reverse triple";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#keeper" object="?uri"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+,<action>
+<label uri="?child" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_queryselfwithtriple.xul b/dom/xul/templates/tests/chrome/test_tmpl_queryselfwithtriple.xul
new file mode 100644
index 000000000..bd10d0d1f
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_queryselfwithtriple.xul
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - self with triple
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" value="Mammals"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - self with triple";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template>
+<query id="query">
+<content uri="?uri"/>
+<triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action>
+<label uri="?uri" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querysetone.xul b/dom/xul/templates/tests/chrome/test_tmpl_querysetone.xul
new file mode 100644
index 000000000..ed9c93843
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querysetone.xul
@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ queryset - one
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ <button step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+ <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="queryset - one";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+<queryset>
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action>
+<button uri="?animal" label="?name"/>
+</action>
+</queryset>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querysettwo.xul b/dom/xul/templates/tests/chrome/test_tmpl_querysettwo.xul
new file mode 100644
index 000000000..1f6627931
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querysettwo.xul
@@ -0,0 +1,117 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ queryset - two
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ <checkbox step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+ <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="queryset - two";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/emperorpenguin', true, true,
+ '2 matching rule 1');
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/archaeopteryx', true, true,
+ '2 matching rule 1');
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/wren', true, true,
+ '2 matching rule 1');
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/barnowl', false, false,
+ '2 (active query is 1)');
+ expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/barnowl', false, true,
+ '1 (no new active query)');
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" flags="logging"
+ datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template>
+<queryset>
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="Barn Owl"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action>
+<checkbox uri="?animal" label="?name"/>
+</action>
+</queryset>
+<queryset>
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action>
+<button uri="?animal" label="?name"/>
+</action>
+</queryset>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querysettwowithcondition.xul b/dom/xul/templates/tests/chrome/test_tmpl_querysettwowithcondition.xul
new file mode 100644
index 000000000..29b19f984
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querysettwowithcondition.xul
@@ -0,0 +1,149 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ queryset - two with condition
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox step="-6" id="http://www.some-fictitious-zoo.com/birds/emu">
+ <label value="Emu"/>
+ <label value="Dromaius novaehollandiae"/>
+ </hbox>
+ <button step="6" id="http://www.some-fictitious-zoo.com/birds/emu" label="No Emus Currently"/>
+ <hbox step="3" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+ <label value="Archaeopteryx"/>
+ <label value="Archaeopteryx lithographica"/>
+ </hbox>
+ <hbox step="-2" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <label value="Barn Owl"/>
+ <label value="Tyto alba"/>
+ </hbox>
+ <button step="-5" id="http://www.some-fictitious-zoo.com/birds/raven" label="No Ravens Currently"/>
+ <hbox step="5" id="http://www.some-fictitious-zoo.com/birds/raven">
+ <label step="-7" value="Raven"/>
+ <label step="7" value="Crow"/>
+ <label value="Corvus corax"/>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="queryset - two with condition";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '2', true);
+ },
+ // step 2
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ },
+ // step 3
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'),
+ RDF.GetResource(ZOO_NS + 'rdf#species'),
+ RDF.GetLiteral('Archaeopteryx lithographica'), true);
+ },
+ // step 4
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ RDF.GetLiteral('5'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/raven');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/raven'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('2'));
+ },
+ // step 6
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/emu');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/emu'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('0'));
+ },
+ // step 7
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/raven');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/raven'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Crow'));
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template>
+<queryset>
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<conditions>
+<where subject="?specimens" rel="equals" value="0"/>
+</conditions>
+<action>
+<button uri="?child" label="No ?name^s Currently"/>
+</action>
+</rule>
+</queryset>
+<queryset>
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#species" object="?species"/>
+</query>
+<action>
+<hbox uri="?child">
+<label value="?name^?unknown"/>
+<label value="?species^?specimens"/>
+</hbox>
+</action>
+</queryset>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_querysyntax.xul
new file mode 100644
index 000000000..713cb371c
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querysyntax.xul
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Hairy Spider"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Hairy Spider'));
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerules.xul b/dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerules.xul
new file mode 100644
index 000000000..e1ac87c72
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerules.xul
@@ -0,0 +1,115 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query syntax - multiple rules
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="-2" id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <checkbox step="2" id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/mammals/chimpanzee" value="Chimpanzee"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <checkbox step="-1" id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label step="-3" id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query syntax - multiple rules";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'mammals/polarbear');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'mammals/polarbear'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('5'));
+ },
+ // step 2
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'mammals/lion');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'mammals/lion'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('9'));
+ },
+ // step 3
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('7', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Nine-banded Armadillo'), true);
+ },
+ // step 4
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/chimpanzee');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Chimpanzee'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 5
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/chimpanzee'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ RDF.GetLiteral('3'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="greater" value="6"/>
+</conditions>
+<action>
+<checkbox uri="?animal" label="?name"/>
+</action>
+</rule>
+<rule id="rule2">
+<action>
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulesfirstconditionall.xul b/dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulesfirstconditionall.xul
new file mode 100644
index 000000000..4509c1018
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulesfirstconditionall.xul
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query syntax - multiple rules first condition all
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query syntax - multiple rules first condition all";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<where subject="?animal" rel="contains" value="zoo"/>
+<action>
+<checkbox uri="?animal" label="?name"/>
+</action>
+</rule>
+<rule id="rule2">
+<conditions>
+<where subject="?name" rel="contains" value="an"/>
+</conditions>
+<action>
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulestwoconditions.xul b/dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulestwoconditions.xul
new file mode 100644
index 000000000..68060c6b4
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulestwoconditions.xul
@@ -0,0 +1,113 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query syntax - multiple rules two conditions
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <checkbox step="2" id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/mammals/chimpanzee" value="Chimpanzee"/>
+ <checkbox step="-1" id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
+ <label step="-3" id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <checkbox id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query syntax - multiple rules two conditions";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'mammals/polarbear');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'mammals/polarbear'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('5'));
+ },
+ // step 2
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'mammals/lion');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'mammals/lion'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('9'));
+ },
+ // step 3
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('7', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Nine-banded Armadillo'), true);
+ },
+ // step 4
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/chimpanzee');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Chimpanzee'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 5
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/chimpanzee'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ RDF.GetLiteral('3'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="greater" value="6"/>
+</conditions>
+<action>
+<checkbox uri="?animal" label="?name"/>
+</action>
+</rule>
+<rule id="rule2">
+<conditions>
+<where subject="?name" rel="contains" value="an"/>
+</conditions>
+<action>
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querytripleandmembermerge.xul b/dom/xul/templates/tests/chrome/test_tmpl_querytripleandmembermerge.xul
new file mode 100644
index 000000000..7abb67e1c
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querytripleandmembermerge.xul
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - triple and member merge
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" unordered="true">
+ <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - triple and member merge";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#favoriteAnimal" object="?child"/>
+<triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#pets" object="?pets"/>
+<member container="?pets" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+,<action>
+<label uri="?child" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querytripleobjecttosubject.xul b/dom/xul/templates/tests/chrome/test_tmpl_querytripleobjecttosubject.xul
new file mode 100644
index 000000000..3998f1796
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querytripleobjecttosubject.xul
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - triple object to subject
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="-1" id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert"/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert"/>
+ <label id="http://www.some-fictitious-zoo.com/humans/sarah" value="Sarah"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - triple object to subject";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/robert'),
+ RDF.GetResource(ZOO_NS + 'rdf#favoriteAnimal'),
+ RDF.GetResource(ZOO_NS + 'arachnids/tarantula'), true);
+ },
+ // step 2
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'humans/robert'),
+ RDF.GetResource(ZOO_NS + 'rdf#favoriteAnimal'),
+ RDF.GetResource(ZOO_NS + 'mammals/lion'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids/tarantula">
+<template id="template">
+<query>
+<content uri="?uri"/>
+<triple subject="?human" predicate="http://www.some-fictitious-zoo.com/rdf#favoriteAnimal" object="?uri"/>
+<triple subject="?human" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?humanname"/>
+</query>
+<action>
+<label uri="?human" value="?humanname"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querytwomembers.xul b/dom/xul/templates/tests/chrome/test_tmpl_querytwomembers.xul
new file mode 100644
index 000000000..df487a26f
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querytwomembers.xul
@@ -0,0 +1,107 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - two members
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" unordered="true">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+ <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+ <label id="http://www.some-fictitious-zoo.com/fish/cod" value="Cod"/>
+ <label id="http://www.some-fictitious-zoo.com/fish/swordfish" value="Swordfish"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - two members";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?childone"/>
+<member container="?childone" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+,<action>
+<label uri="?child" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querytwomembersfiltered.xul b/dom/xul/templates/tests/chrome/test_tmpl_querytwomembersfiltered.xul
new file mode 100644
index 000000000..fdd1efb20
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querytwomembersfiltered.xul
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - two members filtered
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="Mammals"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - two members filtered";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?childone"/>
+<triple subject="?childone" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<member container="?childone" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="LLAMA"/>
+</query>
+,<action>
+<label uri="?child" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querytwotriples.xul b/dom/xul/templates/tests/chrome/test_tmpl_querytwotriples.xul
new file mode 100644
index 000000000..83887358f
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querytwotriples.xul
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - two triples
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" unordered="true">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - two triples";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#favoriteAnimal" object="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+,<action>
+<label uri="?child" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_queryupwardsmember.xul b/dom/xul/templates/tests/chrome/test_tmpl_queryupwardsmember.xul
new file mode 100644
index 000000000..5d3658535
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_queryupwardsmember.xul
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - upwards member
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" unordered="true">
+ <label id="http://www.some-fictitious-zoo.com/marked" container="true" empty="false" value="Marked"/>
+ <label id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false" value="Birds"/>
+ <label id="http://www.some-fictitious-zoo.com/sarahs-pets" container="true" empty="false" value="Sarah's Pets"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - upwards member";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds/emu" flags="dont-recurse">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?child" child="?uri"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+,<action>
+<label uri="?child" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_queryupwardsmembertripleandfilteringtriple.xul b/dom/xul/templates/tests/chrome/test_tmpl_queryupwardsmembertripleandfilteringtriple.xul
new file mode 100644
index 000000000..1cfb689b0
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_queryupwardsmembertripleandfilteringtriple.xul
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query - upwards member, triple and filtering triple
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output" unordered="true">
+ <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query - upwards member, triple and filtering triple";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#favoriteAnimal" object="?child"/>
+<member container="?reptiles" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?reptiles" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="Reptiles"/>
+</query>
+,<action>
+<label uri="?child" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_querywithemptyconditions.xul b/dom/xul/templates/tests/chrome/test_tmpl_querywithemptyconditions.xul
new file mode 100644
index 000000000..265a5bb14
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_querywithemptyconditions.xul
@@ -0,0 +1,117 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ query with empty conditions
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" value="Koala"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="query with empty conditions";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Arctic Hare'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Zebra'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('4', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 6
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'),
+ RDF.GetLiteral('8'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions"/>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_referenceasmember.xul b/dom/xul/templates/tests/chrome/test_tmpl_referenceasmember.xul
new file mode 100644
index 000000000..bf67ebf9d
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_referenceasmember.xul
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ reference as member
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false" value="Tarantula"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false" value="Hairy Spider"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="reference as member";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Hairy Spider'));
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<rule id="rule">
+<conditions id="conditions">
+<content uri="?start"/>
+<member container="?start" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</conditions>
+<action id="action">
+<label uri="?start" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_regenerate.xul b/dom/xul/templates/tests/chrome/test_tmpl_regenerate.xul
new file mode 100644
index 000000000..2c9aedc7b
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_regenerate.xul
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ Regenerate template by removing and appending elements
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_regenerate()"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+function test_regenerate()
+{
+ var container = document.getElementById("container");
+ var node = container.firstChild;
+
+ if (node.childNodes.length != 2) {
+ setTimeout(test_regenerate, 50);
+ return;
+ }
+
+ container.removeChild(node);
+ is(node.childNodes.length, 1, "childNodes after removeChild");
+ container.appendChild(node);
+ is(node.childNodes.length, 2, "childNodes after appendChild");
+ SimpleTest.finish();
+}
+
+]]>
+</script>
+
+<vbox id="container">
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="animals.rdf" ref="http://www.some-fictitious-zoo.com/birds">
+<template zoo:name="Barn Owl" xmlns:zoo="http://www.some-fictitious-zoo.com/rdf#">
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</template>
+</vbox>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_selfgenerationextendedsyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_selfgenerationextendedsyntax.xul
new file mode 100644
index 000000000..712cd4a44
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_selfgenerationextendedsyntax.xul
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ self generation - extended syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Hairy Spider"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="self generation - extended syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Hairy Spider'));
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids/tarantula">
+<template id="template">
+<query>
+<content uri="?uri"/>
+</query>
+<rule>
+<bindings>
+<binding subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</bindings>
+<action>
+<label uri="?uri" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_selfgenerationsimplesyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_selfgenerationsimplesyntax.xul
new file mode 100644
index 000000000..e644d16ac
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_selfgenerationsimplesyntax.xul
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ self generation - simple syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="self generation - simple syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Hairy Spider'));
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids/tarantula">
+<template id="template">
+<button uri="?" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainer.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainer.xul
new file mode 100644
index 000000000..18e8b72a9
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainer.xul
@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax enclosed in a container
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox>
+ <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax enclosed in a container";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+<hbox>
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</hbox>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainerwitharule.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainerwitharule.xul
new file mode 100644
index 000000000..5582e4845
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainerwitharule.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax enclosed in a container with a rule
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
+ <label value="Emu"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <label value="Barn Owl"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
+ <label value="Raven"/>
+ </hbox>
+ <label step="2" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax enclosed in a container with a rule";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+<rule>
+<hbox uri="rdf:*">
+<label value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</hbox>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilter.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilter.xul
new file mode 100644
index 000000000..8715d3cc1
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilter.xul
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax - filter
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax - filter";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template zoo:name="Barn Owl" xmlns:zoo="http://www.some-fictitious-zoo.com/rdf#">
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithmultiplerules.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithmultiplerules.xul
new file mode 100644
index 000000000..ba8591f60
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithmultiplerules.xul
@@ -0,0 +1,97 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax - filter with multiple rules
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ <label step="-1" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+ <button step="4,-5" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Spooky Bird"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+ <button step="1,-3" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Spooky Bird"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/birds/syntheticbarnowl" value="Barn Owl"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax - filter with multiple rules";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/barnowl');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/barnowl'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Spooky Bird'));
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/syntheticbarnowl');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 3
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('2', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/barnowl');
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '2', true);
+ },
+ // step 5
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/barnowl');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/barnowl'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Barn Owl'));
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template>
+<rule zoo:name="Barn Owl" xmlns:zoo="http://www.some-fictitious-zoo.com/rdf#">
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</rule>
+<rule>
+<button uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithrule.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithrule.xul
new file mode 100644
index 000000000..a2a3eb55e
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithrule.xul
@@ -0,0 +1,98 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax - filter with rule
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox step="-1" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <label value="Barn Owl"/>
+ </hbox>
+ <hbox step="5" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <label value="Barn Owl"/>
+ </hbox>
+ <hbox step="2" id="http://www.some-fictitious-zoo.com/birds/syntheticbarnowl">
+ <label value="Barn Owl"/>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax - filter with rule";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/barnowl');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/barnowl'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Spooky Bird'));
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/syntheticbarnowl');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 3
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('2', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/barnowl');
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '2', true);
+ },
+ // step 5
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/barnowl');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/barnowl'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Barn Owl'));
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template>
+<rule zoo:name="Barn Owl" xmlns:zoo="http://www.some-fictitious-zoo.com/rdf#">
+<hbox uri="rdf:*">
+<label value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</hbox>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxiteratingoverasinglevalue.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxiteratingoverasinglevalue.xul
new file mode 100644
index 000000000..e8e05acf2
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxiteratingoverasinglevalue.xul
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax iterating over a single value
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax iterating over a single value";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusinganinterveningcontainer.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusinganinterveningcontainer.xul
new file mode 100644
index 000000000..5aa5172c9
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusinganinterveningcontainer.xul
@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax using an intervening container
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <groupbox>
+ <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+ </groupbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax using an intervening container";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+<groupbox>
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</groupbox>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingatextnode.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingatextnode.xul
new file mode 100644
index 000000000..3fb1fdfa0
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingatextnode.xul
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax using a textnode
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <description step="3" id="http://www.some-fictitious-zoo.com/birds/wren">Wren</description>
+ <description id="http://www.some-fictitious-zoo.com/birds/emu">Emu</description>
+ <description step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">Barn Owl</description>
+ <description id="http://www.some-fictitious-zoo.com/birds/raven">Raven</description>
+ <description step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">Archaeopteryx</description>
+ <description step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">Emperor Penguin</description>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax using a textnode";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+<description uri="rdf:*"><textnode value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/></description>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingcontainerasthegenerationelement.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingcontainerasthegenerationelement.xul
new file mode 100644
index 000000000..238540fb4
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingcontainerasthegenerationelement.xul
@@ -0,0 +1,100 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax using container as the generation element
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
+ <label value="Wren"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
+ <label value="Emu"/>
+ </hbox>
+ <hbox step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <label value="Barn Owl"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
+ <label value="Raven"/>
+ </hbox>
+ <hbox step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+ <label value="Archaeopteryx"/>
+ </hbox>
+ <hbox step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
+ <label value="Emperor Penguin"/>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax using container as the generation element";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+<hbox uri="rdf:*">
+<label value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</hbox>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingdontrecurse.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingdontrecurse.xul
new file mode 100644
index 000000000..31aa9c404
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingdontrecurse.xul
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax using dont-recurse
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false">
+ <label value="Arachnids"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+ <label value="Birds"/>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax using dont-recurse";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/some-animals" flags="dont-recurse">
+<template id="template">
+<hbox uri="rdf:*">
+<label value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</hbox>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegeneration.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegeneration.xul
new file mode 100644
index 000000000..3ef3b1d3d
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegeneration.xul
@@ -0,0 +1,109 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax using recursive generation
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false">
+ <label value="Arachnids"/>
+ <hbox id="http://www.some-fictitious-zoo.com/arachnids/tarantula">
+ <label value="Tarantula"/>
+ </hbox>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+ <label value="Birds"/>
+ <hbox step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
+ <label value="Wren"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
+ <label value="Emu"/>
+ </hbox>
+ <hbox step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <label value="Barn Owl"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
+ <label value="Raven"/>
+ </hbox>
+ <hbox step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+ <label value="Archaeopteryx"/>
+ </hbox>
+ <hbox step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
+ <label value="Emperor Penguin"/>
+ </hbox>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax using recursive generation";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/some-animals">
+<template id="template">
+<hbox uri="rdf:*">
+<label value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</hbox>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegenerationagain.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegenerationagain.xul
new file mode 100644
index 000000000..73d7f742e
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegenerationagain.xul
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax using recursive generation again
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false">
+ <label value="Arachnids"/>
+ <hbox id="http://www.some-fictitious-zoo.com/arachnids/tarantula">
+ <label value="Tarantula"/>
+ </hbox>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+ <label value="Birds"/>
+ <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
+ <label value="Emu"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <label value="Barn Owl"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
+ <label value="Raven"/>
+ </hbox>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax using recursive generation again";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/some-animals">
+<template id="template">
+<hbox uri="rdf:*">
+<label value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</hbox>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxwithtwovariablesused.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxwithtwovariablesused.xul
new file mode 100644
index 000000000..fccee70ce
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxwithtwovariablesused.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple syntax with two variables used
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
+ <label value="Emu"/>
+ <label value="12"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <label value="Barn Owl"/>
+ <label value="4"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
+ <label value="Raven"/>
+ <label value="0"/>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple syntax with two variables used";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template id="template">
+<hbox uri="rdf:*">
+<label value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+<label value="rdf:http://www.some-fictitious-zoo.com/rdf#specimens"/>
+</hbox>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsatbeginningandend.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsatbeginningandend.xul
new file mode 100644
index 000000000..2ca63da19
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsatbeginningandend.xul
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple variable substitution - carets at beginning and end
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="^^Before Tarantula^"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple variable substitution - carets at beginning and end";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<label uri="rdf:*" value="^^Before rdf:http://www.some-fictitious-zoo.com/rdf#name^^"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsubstitution.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsubstitution.xul
new file mode 100644
index 000000000..abc28ff0f
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsubstitution.xul
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple variable substitution - caret substitution
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula^ and^^ lots ^ more"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple variable substitution - caret substitution";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name^^ and^^ lots ^ more"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionnovariable.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionnovariable.xul
new file mode 100644
index 000000000..4d2404aca
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionnovariable.xul
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple variable substitution - no variable
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Name"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple variable substitution - no variable";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<label uri="rdf:*" value="Name"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarkaspartofvariable.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarkaspartofvariable.xul
new file mode 100644
index 000000000..0dd1a7ccf
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarkaspartofvariable.xul
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple variable substitution - question mark as part of variable
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Name is "/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple variable substitution - question mark as part of variable";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<label uri="rdf:*" value="Name is rdf:http://www.some-fictitious-zoo.com/rdf#name?"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarksubstitution.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarksubstitution.xul
new file mode 100644
index 000000000..c31401dd4
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarksubstitution.xul
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple variable substitution - question mark substitution
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Are you a Tarantula ?"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Are you a Hairy Spider ?"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple variable substitution - question mark substitution";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Hairy Spider'));
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<label uri="rdf:*" value="Are you a rdf:http://www.some-fictitious-zoo.com/rdf#name ?sample ??"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutiontextandvariable.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutiontextandvariable.xul
new file mode 100644
index 000000000..6d2bc806b
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutiontextandvariable.xul
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple variable substitution - text and variable
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Name is Tarantula the Spider"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Name is Hairy Spider the Spider"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple variable substitution - text and variable";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Hairy Spider'));
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<label uri="rdf:*" value="Name is rdf:http://www.some-fictitious-zoo.com/rdf#name the Spider"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariableandtextconcatenated.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariableandtextconcatenated.xul
new file mode 100644
index 000000000..41df3d4d8
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariableandtextconcatenated.xul
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple variable substitution - variable and text concatenated
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="The Tarantula's Nest"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple variable substitution - variable and text concatenated";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<label uri="rdf:*" value="The rdf:http://www.some-fictitious-zoo.com/rdf#name^'s Nest"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariablesconcatenated.xul b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariablesconcatenated.xul
new file mode 100644
index 000000000..b8864c3b3
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariablesconcatenated.xul
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ simple variable substitution - variables concatenated
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula3"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="simple variable substitution - variables concatenated";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
+<template id="template">
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name^rdf:http://www.some-fictitious-zoo.com/rdf#specimens"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortascendinginteger.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortascendinginteger.xul
new file mode 100644
index 000000000..2d30ced27
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortascendinginteger.xul
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort ascending - integers
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label step="-1" id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort ascending - integers";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'mammals/llama');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimensAsString');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(subject, predicate, oldval, RDF.GetLiteral('12'), true);
+ }
+];
+]]>
+</script>
+
+<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" sort="?specimens ?name" sortDirection="ascending" sorthints="integer">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimensAsString" object="?specimens"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortascendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortascendingquerysyntax.xul
new file mode 100644
index 000000000..5f90a8334
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortascendingquerysyntax.xul
@@ -0,0 +1,114 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort ascending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" value="Koala"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort ascending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Arctic Hare'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Zebra'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('4', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 6
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'),
+ RDF.GetLiteral('8'), true);
+ }
+];
+]]>
+</script>
+
+<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" sort="?name" sortDirection="ascending">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworulesquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworulesquerysyntax.xul
new file mode 100644
index 000000000..612a50fc6
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworulesquerysyntax.xul
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort ascending two rules - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort ascending two rules - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortDirection="ascending" sort="?specimens ?name" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<conditions>
+<where subject="?name" rel="contains" value="o"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+<rule>
+<action>
+<button uri="?animal" label="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithcontainerquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithcontainerquerysyntax.xul
new file mode 100644
index 000000000..e3fb2e37b
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithcontainerquerysyntax.xul
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort ascending two rules with container - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+ <label value="Nine-banded Armadillo"/>
+ </hbox>
+ <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
+ <hbox id="http://www.some-fictitious-zoo.com/mammals/lion">
+ <label value="Lion"/>
+ </hbox>
+ <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
+ <hbox id="http://www.some-fictitious-zoo.com/mammals/gorilla">
+ <label value="Gorilla"/>
+ </hbox>
+ <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+ <hbox id="http://www.some-fictitious-zoo.com/mammals/polarbear">
+ <label value="Polar Bear"/>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort ascending two rules with container - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortDirection="ascending" sort="?specimens ?name" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<conditions>
+<where subject="?name" rel="contains" value="o"/>
+</conditions>
+<action id="action">
+<hbox uri="?animal">
+<label value="?name"/>
+</hbox>
+</action>
+</rule>
+<rule>
+<action>
+<button uri="?animal" label="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithdifferentcontainerquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithdifferentcontainerquerysyntax.xul
new file mode 100644
index 000000000..fdab29054
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithdifferentcontainerquerysyntax.xul
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort ascending two rules with different container - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <vbox>
+ <hbox id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+ <label value="Nine-banded Armadillo"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/mammals/lion">
+ <label value="Lion"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/mammals/gorilla">
+ <label value="Gorilla"/>
+ </hbox>
+ <hbox id="http://www.some-fictitious-zoo.com/mammals/polarbear">
+ <label value="Polar Bear"/>
+ </hbox>
+ </vbox>
+ <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
+ <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort ascending two rules with different container - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortDirection="ascending" sort="?specimens ?name" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<conditions>
+<where subject="?name" rel="contains" value="o"/>
+</conditions>
+<action id="action">
+<vbox>
+<hbox uri="?animal">
+<label value="?name"/>
+</hbox>
+</vbox>
+</action>
+</rule>
+<rule>
+<action>
+<button uri="?animal" label="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortdescendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortdescendingquerysyntax.xul
new file mode 100644
index 000000000..1979fdb98
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortdescendingquerysyntax.xul
@@ -0,0 +1,114 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort descending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" value="Koala"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort descending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Arctic Hare'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Zebra'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('4', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 6
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'),
+ RDF.GetLiteral('8'), true);
+ }
+];
+]]>
+</script>
+
+<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" sort="?name" sortDirection="descending">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortquerymemberandtwotriples.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortquerymemberandtwotriples.xul
new file mode 100644
index 000000000..8176553e4
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortquerymemberandtwotriples.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort query - member and two triples
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
+ <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+ <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort query - member and two triples";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans" sortDirection="ascending" sort="?name" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?human"/>
+<triple subject="?human" predicate="http://www.some-fictitious-zoo.com/rdf#favoriteAnimal" object="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action>
+<label uri="?child" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortresource2descendingsimplesyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortresource2descendingsimplesyntax.xul
new file mode 100644
index 000000000..d328d81b2
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortresource2descendingsimplesyntax.xul
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sortResource2 descending - simple syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sortResource2 descending - simple syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortDirection="descending" sort="http://www.some-fictitious-zoo.com/rdf#specimens http://www.some-fictitious-zoo.com/rdf#name" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
+<template id="template">
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicateascendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicateascendingquerysyntax.xul
new file mode 100644
index 000000000..653584c52
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicateascendingquerysyntax.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sortResource2 set to predicate ascending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sortResource2 set to predicate ascending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortDirection="ascending" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicatedescendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicatedescendingquerysyntax.xul
new file mode 100644
index 000000000..8fcb569a7
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicatedescendingquerysyntax.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sortResource2 set to predicate descending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sortResource2 set to predicate descending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortDirection="descending" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortresourceascendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortresourceascendingquerysyntax.xul
new file mode 100644
index 000000000..346a988a5
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortresourceascendingquerysyntax.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sortResource ascending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sortResource ascending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortResource="?name" sortDirection="ascending">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortresourcedescendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortresourcedescendingquerysyntax.xul
new file mode 100644
index 000000000..7281eb6ef
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortresourcedescendingquerysyntax.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sortResource descending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sortResource descending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortResource="?name" sortDirection="descending">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicateascendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicateascendingquerysyntax.xul
new file mode 100644
index 000000000..151c5d5ae
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicateascendingquerysyntax.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sortResource set to predicate ascending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sortResource set to predicate ascending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortDirection="ascending">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicatedescendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicatedescendingquerysyntax.xul
new file mode 100644
index 000000000..893f056b8
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicatedescendingquerysyntax.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sortResource set to predicate descending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sortResource set to predicate descending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortDirection="descending">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sorttworesourcesasstringsettopredicatedescendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sorttworesourcesasstringsettopredicatedescendingquerysyntax.xul
new file mode 100644
index 000000000..1daf2dab9
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sorttworesourcesasstringsettopredicatedescendingquerysyntax.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort two resources as string set to predicate descending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort two resources as string set to predicate descending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortDirection="descending" sort="http://www.some-fictitious-zoo.com/rdf#specimensAsString http://www.some-fictitious-zoo.com/rdf#name">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sorttworesourcessettopredicateascendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sorttworesourcessettopredicateascendingquerysyntax.xul
new file mode 100644
index 000000000..8d9137ffa
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sorttworesourcessettopredicateascendingquerysyntax.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort two resources set to predicate ascending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort two resources set to predicate ascending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortDirection="ascending" sort="http://www.some-fictitious-zoo.com/rdf#specimens http://www.some-fictitious-zoo.com/rdf#name">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingquerysyntax.xul
new file mode 100644
index 000000000..6a396d3b9
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingquerysyntax.xul
@@ -0,0 +1,119 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort two variables ascending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
+ <label step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" value="Koala"/>
+ <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort two variables ascending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Arctic Hare'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Zebra'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('4', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 6
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'),
+ RDF.GetLiteral('8'), true);
+ }
+];
+]]>
+</script>
+
+<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" sortDirection="ascending" sort="?specimens ?name">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<bindings>
+<binding subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</bindings>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingsimplesyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingsimplesyntax.xul
new file mode 100644
index 000000000..fd8200a66
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingsimplesyntax.xul
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort two variables ascending - simple syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort two variables ascending - simple syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortDirection="ascending" sort="http://www.some-fictitious-zoo.com/rdf#specimens http://www.some-fictitious-zoo.com/rdf#name">
+<template id="template">
+<label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesdescendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesdescendingquerysyntax.xul
new file mode 100644
index 000000000..f2fb6ca9d
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesdescendingquerysyntax.xul
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort two variables descending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort two variables descending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sortDirection="descending" sort="?specimens ?name">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<bindings>
+<binding subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</bindings>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_sortunknownascendingquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_sortunknownascendingquerysyntax.xul
new file mode 100644
index 000000000..d995c4c1c
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_sortunknownascendingquerysyntax.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ sort unknown ascending - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="sort unknown ascending - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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" sort="?other">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters.xul
new file mode 100644
index 000000000..b11367e28
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage listbox with bad query parameters
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="storage listbox with bad query parameters";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+
+Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService)
+ .reset();
+
+copyToProfile('animals.sqlite');
+expectedConsoleMessages.push("Error parsing template: the given named parameter is unknown in the SQL query");
+
+var changes = [];
+]]>
+</script>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root"
+ flex="1" datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = ? ORDER BY name
+ <param name="bar">2</param>
+ </query>
+ <action>
+ <listitem uri="?" label="?name"/>
+ </action>
+ </template>
+</listbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_2.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_2.xul
new file mode 100644
index 000000000..81517d2df
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_2.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage listbox with bad query parameters
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="storage listbox with bad query parameters";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+
+Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService)
+ .reset();
+
+copyToProfile('animals.sqlite');
+
+expectedConsoleMessages.push("Error parsing template: the type of a query parameter is wrong");
+
+var changes = [];
+]]>
+</script>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root"
+ flex="1" datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = ? ORDER BY name
+ <param type="mysupertype">2</param>
+ </query>
+ <action>
+ <listitem uri="?" label="?name"/>
+ </action>
+ </template>
+</listbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_3.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_3.xul
new file mode 100644
index 000000000..22be02c28
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_3.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage listbox with bad query parameters
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="storage listbox with bad query parameters";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+
+Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService)
+ .reset();
+
+copyToProfile('animals.sqlite');
+
+expectedConsoleMessages.push("Error parsing template: a query parameter cannot be bound to the SQL query");
+
+var changes = [];
+]]>
+</script>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root"
+ flex="1" datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = :spec ORDER BY name
+ <param name="spec" type="int32">5</param>
+ <param>L%</param>
+ </query>
+ <action>
+ <listitem uri="?" label="?name"/>
+ </action>
+ </template>
+</listbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_baddatasource.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_baddatasource.xul
new file mode 100644
index 000000000..da9c83d0c
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_baddatasource.xul
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage bad datasource
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="storage bad datasource";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService)
+ .reset();
+
+expectedConsoleMessages.push("Error parsing template: only profile: or file URI are allowed");
+
+
+var changes = [];
+]]>
+</script>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root"
+ flex="1" rows="8"
+ datasources="http://foo.local/animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = 2 ORDER BY name
+ </query>
+ <action>
+ <listitem uri="?" label="?name" />
+ </action>
+ </template>
+</listbox>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_badquery.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_badquery.xul
new file mode 100644
index 000000000..39df0edac
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_badquery.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage bad query
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="storage bad query";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService)
+ .reset();
+
+copyToProfile('animals.sqlite');
+
+expectedConsoleMessages.push("Error parsing template: syntax error in the SQL query");
+
+
+var changes = [];
+]]>
+</script>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root"
+ flex="1" rows="8"
+ datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animalssssssss WHERE species_id = 2 ORDER BY
+ </query>
+ <action>
+ <listitem uri="?" label="?name" />
+ </action>
+ </template>
+</listbox>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_dynamicparameters.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_dynamicparameters.xul
new file mode 100644
index 000000000..c791c6acd
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_dynamicparameters.xul
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage listbox with dynamic query parameters
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_storage_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+ <data id="rebuilt-output">
+ <listitem anyid="true" label="Barn Owl"/>
+ <listitem anyid="true" label="Emu"/>
+ <listitem anyid="true" label="Raven"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+copyToProfile('animals.sqlite');
+
+function test_storage_template()
+{
+ var root = document.getElementById("root");
+ expectedOutput = document.getElementById("output");
+ checkResults(root, 0);
+
+ document.getElementById("species-id").textContent = '2';
+ root.builder.addListener(myBuilderListener);
+ root.builder.rebuild();
+}
+
+var myBuilderListener = {
+
+ willRebuild: function(aBuilder) {
+
+ },
+ didRebuild: function (aBuilder) {
+ var root = document.getElementById("root");
+ expectedOutput = document.getElementById("rebuilt-output");
+ checkResults(root, 0);
+ SimpleTest.finish();
+ }
+}
+
+var testid ="storage listbox with dynamic query parameters";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root"
+ flex="1" datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = :spec ORDER BY name
+ <param id="species-id" name="spec" type="int32" />
+ </query>
+ <action>
+ <listitem uri="?" label="?name"/>
+ </action>
+ </template>
+</listbox>
+
+
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_listbox.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_listbox.xul
new file mode 100644
index 000000000..43661c417
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_listbox.xul
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage simple with listbox
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <listitem anyid="true" label="Barn Owl"/>
+ <listitem anyid="true" label="Emu"/>
+ <listitem anyid="true" label="Raven"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+copyToProfile('animals.sqlite');
+
+var testid ="storage simple listbox";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root"
+ flex="1" rows="8"
+ datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = 2 ORDER BY name
+ </query>
+ <action>
+ <listitem uri="?" label="?name" />
+ </action>
+ </template>
+</listbox>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_multiqueries.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_multiqueries.xul
new file mode 100644
index 000000000..28dcaa926
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_multiqueries.xul
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage listbox with multiqueries
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <listitem anyid="true" label="Mammal: African Elephant"/>
+ <listitem anyid="true" label="Mammal: Gorilla" style="font-weight:bold"/>
+ <listitem anyid="true" label="Mammal: HIPPOPOTAMUS"/>
+ <listitem anyid="true" label="Mammal: LAMA"/>
+ <listitem anyid="true" label="Mammal: Lion"/>
+ <listitem anyid="true" label="Mammal: Nine-banded Armadillo" style="font-weight:bold"/>
+ <listitem anyid="true" label="Mammal: Polar Bear"/>
+ <listitem anyid="true" label="Mammal: aardvark"/>
+ <listitem anyid="true" label="Bird: Barn Owl" style="font-style:italic"/>
+ <listitem anyid="true" label="Bird: Emu"/>
+ <listitem anyid="true" label="Bird: Raven"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+copyToProfile('animals.sqlite');
+
+var testid ="storage listbox with multiqueries";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root"
+ flex="1" datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <queryset>
+ <query>SELECT * FROM animals WHERE species_id = 5 ORDER BY name</query>
+ <rule>
+ <where subject="?id" rel="greater" value="12"/>
+ <action>
+ <listitem uri="?" label="Mammal: ?name" style="font-weight:bold"/>
+ </action>
+ </rule>
+ <rule>
+ <action>
+ <listitem uri="?" label="Mammal: ?name"/>
+ </action>
+ </rule>
+ </queryset>
+ <queryset>
+ <!-- we use aliases on columns just to have different "column names" in the result set
+ to "similate" a result set from another table for example -->
+ <query>SELECT * FROM animals WHERE species_id = 2 ORDER BY name</query>
+ <rule>
+ <where subject="?id" rel="equals" value="3"/>
+ <action>
+ <listitem uri="?" label="Bird: ?name" style="font-style:italic"/>
+ </action>
+ </rule>
+ <rule>
+ <action>
+ <listitem uri="?" label="Bird: ?name"/>
+ </action>
+ </rule>
+ </queryset>
+ </template>
+</listbox>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_parameters.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_parameters.xul
new file mode 100644
index 000000000..0df561884
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_parameters.xul
@@ -0,0 +1,160 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage listbox with query parameters
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_storage_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output-birds">
+ <listitem anyid="true" label="Barn Owl"/>
+ <listitem anyid="true" label="Emu"/>
+ <listitem anyid="true" label="Raven"/>
+ </data>
+
+ <data id="output-L">
+ <listitem anyid="true" label="LAMA"/>
+ <listitem anyid="true" label="Lion"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+
+copyToProfile('animals.sqlite');
+SimpleTest.waitForExplicitFinish();
+
+
+function test_storage_template()
+{
+ var root = document.getElementById("root1");
+ expectedOutput = document.getElementById("output-birds");
+ checkResults(root, 0);
+
+root = document.getElementById("root2");
+checkResults(root, 0);
+
+root = document.getElementById("root6");
+checkResults(root, 0);
+
+root = document.getElementById("root3");
+expectedOutput = document.getElementById("output-L");
+checkResults(root, 0);
+
+root = document.getElementById("root4");
+checkResults(root, 0);
+
+root = document.getElementById("root5");
+checkResults(root, 0);
+
+SimpleTest.finish();
+}
+
+
+var testid ="storage listbox with query parameters";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput;
+
+var changes = [];
+]]>
+</script>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root1"
+ flex="1" datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = ? ORDER BY name
+ <param>2</param>
+ </query>
+ <action>
+ <listitem uri="?" label="?name"/>
+ </action>
+ </template>
+</listbox>
+
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root2"
+ flex="1" datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = ? ORDER BY name
+ <param type="int32">2</param>
+ </query>
+ <action>
+ <listitem uri="?" label="?name"/>
+ </action>
+ </template>
+</listbox>
+
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root3"
+ flex="1" datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = :spec AND name like ? ORDER BY name
+ <param name="spec" type="int32">5</param>
+ <param>L%</param>
+ </query>
+ <action>
+ <listitem uri="?" label="?name"/>
+ </action>
+ </template>
+</listbox>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root4"
+ flex="1" datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = ?3 AND name like ?1 ORDER BY name
+ <param index="3" type="int32">5</param>
+ <param index="1">L%</param>
+ </query>
+ <action>
+ <listitem uri="?" label="?name"/>
+ </action>
+ </template>
+</listbox>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root5"
+ flex="1" datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = ?3 AND name like :pattern ORDER BY name
+ <param name="pattern">L%</param>
+ <param index="3" type="int32">5</param>
+ </query>
+ <action>
+ <listitem uri="?" label="?name"/>
+ </action>
+ </template>
+</listbox>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root6"
+ flex="1" datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = ? ORDER BY name
+ <param type="int32">2qsdqsd</param>
+ </query>
+ <action>
+ <listitem uri="?" label="?name"/>
+ </action>
+ </template>
+</listbox>
+
+
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_rule.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_rule.xul
new file mode 100644
index 000000000..003682750
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_rule.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage listbox with rule
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <listitem anyid="true" label="Gorilla"/>
+ <listitem anyid="true" label="Nine-banded Armadillo"/>
+ <listitem anyid="true" label="Polar Bear"/>
+ <listitem anyid="true" label="aardvark"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+
+SimpleTest.waitForExplicitFinish();
+copyToProfile('animals.sqlite');
+
+var testid ="storage listbox with rule";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<listbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root"
+ flex="1" rows="8"
+ datasources="profile:animals.sqlite" ref="." querytype="storage">
+ <template>
+ <query>
+ SELECT * FROM animals WHERE species_id = 5 ORDER BY name
+ </query>
+ <rule>
+ <where subject="?id" rel="greater" value="10"/>
+ <action>
+ <listitem uri="?" label="?name" />
+ </action>
+ </rule>
+ </template>
+</listbox>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_simple.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_simple.xul
new file mode 100644
index 000000000..0ac6d3857
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_simple.xul
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage simple
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button anyid="true" label="Barn Owl / Tyto alba"/>
+ <button anyid="true" label="Emu / Dromaius novaehollandiae"/>
+ <button anyid="true" label="Raven / Corvus corax"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+copyToProfile('animals.sqlite');
+SimpleTest.waitForExplicitFinish();
+
+var testid ="storage simple";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root"
+ datasources="profile:animals.sqlite" querytype="storage" ref=".">
+<template>
+ <query>SELECT * FROM animals WHERE species_id = 2 ORDER BY name</query>
+ <action>
+ <button uri="?" label="?name / ?specimen"/>
+ </action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_sortintegerasc.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_sortintegerasc.xul
new file mode 100644
index 000000000..376cee25c
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_sortintegerasc.xul
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage sort integer asc
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <row anyid="true"> <label value="1"/> <label value="Tarantula"/> </row>
+ <row anyid="true"> <label value="2"/> <label value="Emu"/> </row>
+ <row anyid="true"> <label value="3"/> <label value="Barn Owl"/> </row>
+ <row anyid="true"> <label value="4"/> <label value="Raven"/> </row>
+ <row anyid="true"> <label value="5"/> <label value="Cod"/> </row>
+ <row anyid="true"> <label value="6"/> <label value="Swordfish"/> </row>
+ <row anyid="true"> <label value="7"/> <label value="Lion"/> </row>
+ <row anyid="true"> <label value="8"/> <label value="HIPPOPOTAMUS"/> </row>
+ <row anyid="true"> <label value="9"/> <label value="African Elephant"/> </row>
+ <row anyid="true"> <label value="10"/> <label value="LAMA"/> </row>
+ <row anyid="true"> <label value="11"/> <label value="Polar Bear"/> </row>
+ <row anyid="true"> <label value="12"/> <label value="aardvark"/> </row>
+ <row anyid="true"> <label value="13"/> <label value="Nine-banded Armadillo"/> </row>
+ <row anyid="true"> <label value="14"/> <label value="Gorilla"/> </row>
+ <row anyid="true"> <label value="15"/> <label value="Anaconda"/> </row>
+ <row anyid="true"> <label value="16"/> <label value="Chameleon"/> </row>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+copyToProfile('animals.sqlite');
+
+var testid ="storage sort integer asc";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<grid xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
+ <columns>
+ <column flex="1"/>
+ <column flex="3"/>
+ </columns>
+ <rows id="root" datasources="profile:animals.sqlite" querytype="storage" ref="."
+ sort="?id" sortDirection="ascending">
+ <template>
+ <query>SELECT id, name FROM animals</query>
+ <action>
+ <row uri="?">
+ <label value="?id"/>
+ <label value="?name"/>
+ </row>
+ </action>
+ </template>
+ </rows>
+</grid>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_sortintegerdesc.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_sortintegerdesc.xul
new file mode 100644
index 000000000..3ab75fcf4
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_sortintegerdesc.xul
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage sort integer desc
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <row anyid="true"> <label value="16"/> <label value="Chameleon"/> </row>
+ <row anyid="true"> <label value="15"/> <label value="Anaconda"/> </row>
+ <row anyid="true"> <label value="14"/> <label value="Gorilla"/> </row>
+ <row anyid="true"> <label value="13"/> <label value="Nine-banded Armadillo"/> </row>
+ <row anyid="true"> <label value="12"/> <label value="aardvark"/> </row>
+ <row anyid="true"> <label value="11"/> <label value="Polar Bear"/> </row>
+ <row anyid="true"> <label value="10"/> <label value="LAMA"/> </row>
+ <row anyid="true"> <label value="9"/> <label value="African Elephant"/> </row>
+ <row anyid="true"> <label value="8"/> <label value="HIPPOPOTAMUS"/> </row>
+ <row anyid="true"> <label value="7"/> <label value="Lion"/> </row>
+ <row anyid="true"> <label value="6"/> <label value="Swordfish"/> </row>
+ <row anyid="true"> <label value="5"/> <label value="Cod"/> </row>
+ <row anyid="true"> <label value="4"/> <label value="Raven"/> </row>
+ <row anyid="true"> <label value="3"/> <label value="Barn Owl"/> </row>
+ <row anyid="true"> <label value="2"/> <label value="Emu"/> </row>
+ <row anyid="true"> <label value="1"/> <label value="Tarantula"/> </row>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+copyToProfile('animals.sqlite');
+
+var testid ="storage sort integer desc";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<grid xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
+ <columns>
+ <column flex="1"/>
+ <column flex="3"/>
+ </columns>
+ <rows id="root" datasources="profile:animals.sqlite" querytype="storage" ref="."
+ sort="?id" sortDirection="descending">
+ <template>
+ <query>SELECT id, name FROM animals</query>
+ <action>
+ <row uri="?">
+ <label value="?id"/>
+ <label value="?name"/>
+ </row>
+ </action>
+ </template>
+ </rows>
+</grid>
+
+
+
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_sortstringasc.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_sortstringasc.xul
new file mode 100644
index 000000000..600db67c4
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_sortstringasc.xul
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage sort string asc
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <row anyid="true"> <label value="12"/> <label value="aardvark"/> </row>
+ <row anyid="true"> <label value="9"/> <label value="African Elephant"/> </row>
+ <row anyid="true"> <label value="15"/> <label value="Anaconda"/> </row>
+ <row anyid="true"> <label value="3"/> <label value="Barn Owl"/> </row>
+ <row anyid="true"> <label value="16"/> <label value="Chameleon"/> </row>
+ <row anyid="true"> <label value="5"/> <label value="Cod"/> </row>
+ <row anyid="true"> <label value="2"/> <label value="Emu"/> </row>
+ <row anyid="true"> <label value="14"/> <label value="Gorilla"/> </row>
+ <row anyid="true"> <label value="8"/> <label value="HIPPOPOTAMUS"/> </row>
+ <row anyid="true"> <label value="10"/> <label value="LAMA"/> </row>
+ <row anyid="true"> <label value="7"/> <label value="Lion"/> </row>
+ <row anyid="true"> <label value="13"/> <label value="Nine-banded Armadillo"/> </row>
+ <row anyid="true"> <label value="11"/> <label value="Polar Bear"/> </row>
+ <row anyid="true"> <label value="4"/> <label value="Raven"/> </row>
+ <row anyid="true"> <label value="6"/> <label value="Swordfish"/> </row>
+ <row anyid="true"> <label value="1"/> <label value="Tarantula"/> </row>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+copyToProfile('animals.sqlite');
+
+var testid ="storage sort string asc";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<grid xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
+ <columns>
+ <column flex="1"/>
+ <column flex="3"/>
+ </columns>
+ <rows id="root" datasources="profile:animals.sqlite" querytype="storage" ref="."
+ sort="?name" sortDirection="ascending">
+ <template>
+ <query>SELECT id, name FROM animals</query>
+ <action>
+ <row uri="?">
+ <label value="?id"/>
+ <label value="?name"/>
+ </row>
+ </action>
+ </template>
+ </rows>
+</grid>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_sortstringdesc.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_sortstringdesc.xul
new file mode 100644
index 000000000..b99c849e7
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_sortstringdesc.xul
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage sort string desc
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <row anyid="true"> <label value="1"/> <label value="Tarantula"/> </row>
+ <row anyid="true"> <label value="6"/> <label value="Swordfish"/> </row>
+ <row anyid="true"> <label value="4"/> <label value="Raven"/> </row>
+ <row anyid="true"> <label value="11"/> <label value="Polar Bear"/> </row>
+ <row anyid="true"> <label value="13"/> <label value="Nine-banded Armadillo"/> </row>
+ <row anyid="true"> <label value="7"/> <label value="Lion"/> </row>
+ <row anyid="true"> <label value="10"/> <label value="LAMA"/> </row>
+ <row anyid="true"> <label value="8"/> <label value="HIPPOPOTAMUS"/> </row>
+ <row anyid="true"> <label value="14"/> <label value="Gorilla"/> </row>
+ <row anyid="true"> <label value="2"/> <label value="Emu"/> </row>
+ <row anyid="true"> <label value="5"/> <label value="Cod"/> </row>
+ <row anyid="true"> <label value="16"/> <label value="Chameleon"/> </row>
+ <row anyid="true"> <label value="3"/> <label value="Barn Owl"/> </row>
+ <row anyid="true"> <label value="15"/> <label value="Anaconda"/> </row>
+ <row anyid="true"> <label value="9"/> <label value="African Elephant"/> </row>
+ <row anyid="true"> <label value="12"/> <label value="aardvark"/> </row>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+copyToProfile('animals.sqlite');
+
+var testid ="storage sort string desc";
+var queryType = "storage";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<grid xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
+ <columns>
+ <column flex="1"/>
+ <column flex="3"/>
+ </columns>
+ <rows id="root" datasources="profile:animals.sqlite" querytype="storage" ref="."
+ sort="?name" sortDirection="descending">
+ <template>
+ <query>SELECT id, name FROM animals</query>
+ <action>
+ <row uri="?">
+ <label value="?id"/>
+ <label value="?name"/>
+ </row>
+ </action>
+ </template>
+ </rows>
+</grid>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_storage_tree.xul b/dom/xul/templates/tests/chrome/test_tmpl_storage_tree.xul
new file mode 100644
index 000000000..9ca042713
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_storage_tree.xul
@@ -0,0 +1,122 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ storage tree
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols orient="horizontal">
+ <treecol id="species" primary="true" label="Species" flex="2" ordinal="1"/>
+ <treecol id="name" label="Common name" flex="2" ordinal="3"/>
+ <treecol id="specimen" label="Specimen" flex="3" ordinal="5"/>
+ <treecol id="id" label="id" flex="1" ordinal="7"/>
+ </treecols>
+ <treechildren>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="arachnids" /> <treecell label="Tarantula"/> <treecell label="Avicularia avicularia" /> <treecell label="1"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="birds" /> <treecell label="Barn Owl"/> <treecell label="Tyto alba" /> <treecell label="3"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="birds" /> <treecell label="Emu"/> <treecell label="Dromaius novaehollandiae" /> <treecell label="2"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="birds" /> <treecell label="Raven"/> <treecell label="Corvus corax" /> <treecell label="4"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="fish" /> <treecell label="Cod"/> <treecell label="Gadus morhua" /> <treecell label="5"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="fish" /> <treecell label="Swordfish"/> <treecell label="Xiphias gladius" /> <treecell label="6"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="mammals" /> <treecell label="African Elephant"/> <treecell label="Loxodonta africana" /> <treecell label="9"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="mammals" /> <treecell label="Gorilla"/> <treecell label="Gorilla gorilla" /> <treecell label="14"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="mammals" /> <treecell label="HIPPOPOTAMUS"/> <treecell label="Hippopotamus amphibius" /> <treecell label="8"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="mammals" /> <treecell label="LAMA"/> <treecell label="Lama glama" /> <treecell label="10"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="mammals" /> <treecell label="Lion"/> <treecell label="Panthera leo" /> <treecell label="7"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="mammals" /> <treecell label="Nine-banded Armadillo"/> <treecell label="Dasypus novemcinctus" /> <treecell label="13"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="mammals" /> <treecell label="Polar Bear"/> <treecell label="Thalarctos maritimus" /> <treecell label="11"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="mammals" /> <treecell label="aardvark"/> <treecell label="Orycteropus afer" /> <treecell label="12"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="reptiles" /> <treecell label="Anaconda"/> <treecell label="Eunectes murinus" /> <treecell label="15"/>
+ </treerow> </treeitem>
+ <treeitem anyid="true"> <treerow>
+ <treecell label="reptiles" /> <treecell label="Chameleon"/> <treecell label="Chamaeleo chamaelon" /> <treecell label="16"/>
+ </treerow> </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+copyToProfile('animals.sqlite');
+
+var testid ="storage tree";
+var queryType = "storage";
+var isTreeBuilder = true;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root"
+ flex="1" datasources="profile:animals.sqlite" ref="*" querytype="storage" flags="dont-build-content">
+ <treecols>
+ <treecol id="species" primary="true" label="Species" flex="2"/>
+ <treecol id="name" label="Common name" flex="2"/>
+ <treecol id="specimen" label="Specimen" flex="3"/>
+ <treecol id="id" label="id" flex="1"/>
+ </treecols>
+ <template>
+ <query>
+ SELECT a.id, a.name, a.specimen, s.name as species FROM animals a, species s
+ WHERE a.species_id = s.id ORDER BY species, a.name</query>
+ <action>
+ <treechildren>
+ <treeitem uri="?">
+ <treerow>
+ <treecell label="?species"/>
+ <treecell label="?name"/>
+ <treecell label="?specimen"/>
+ <treecell label="?id"/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </action>
+ </template>
+ </tree>
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntax.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntax.xul
new file mode 100644
index 000000000..bfb494c79
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntax.xul
@@ -0,0 +1,158 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - query syntax
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell step="-6" label="12"/>
+ <treecell step="6" label="0"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+ <treerow>
+ <treecell label="Archaeopteryx"/>
+ <treecell step="-4"/>
+ <treecell step="4" label="5"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-2" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <treerow>
+ <treecell label="Barn Owl"/>
+ <treecell label="4"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/raven">
+ <treerow>
+ <treecell step="-7" label="Raven"/>
+ <treecell step="7" label="Crow"/>
+ <treecell step="-5" label="0"/>
+ <treecell step="5" label="2"/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - query syntax";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '2', true);
+ },
+ // step 2
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ },
+ // step 3
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'),
+ RDF.GetResource(ZOO_NS + 'rdf#species'),
+ RDF.GetLiteral('Archaeopteryx lithographica'), true);
+ },
+ // step 4
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ RDF.GetLiteral('5'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/raven');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/raven'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('2'));
+ },
+ // step 6
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/emu');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/emu'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('0'));
+ },
+ // step 7
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/raven');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/raven'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Crow'));
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" flags="" id="root" ref="http://www.some-fictitious-zoo.com/birds">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+<treecol label="Species"/>
+</treecols>
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<bindings>
+<binding subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</bindings>
+<action>
+<treechildren>
+<treeitem uri="?child">
+<treerow>
+<treecell label="?name"/>
+<treecell label="?specimens"/>
+</treerow>
+</treeitem>
+</treechildren>
+</action>
+</rule>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxnotrecursive.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxnotrecursive.xul
new file mode 100644
index 000000000..9a07372fe
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxnotrecursive.xul
@@ -0,0 +1,145 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - query syntax not recursive
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah">
+ <treerow>
+ <treecell label="Sarah"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" open="true">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - query syntax not recursive";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Lobster'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'crustaceans'));
+ container.AppendElement(newnode);
+ },
+ // step 4
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 5
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 6
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" flags="dont-recurse" id="root">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+<treecol label="Species"/>
+</treecols>
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<action>
+<treechildren>
+<treeitem uri="?child">
+<treerow>
+<treecell label="?name"/>
+<treecell/>
+</treerow>
+</treeitem>
+</treechildren>
+</action>
+</rule>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxnotrecursivetreebuilder.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxnotrecursivetreebuilder.xul
new file mode 100644
index 000000000..106d4d7cd
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxnotrecursivetreebuilder.xul
@@ -0,0 +1,145 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - query syntax not recursive tree builder
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah">
+ <treerow>
+ <treecell label="Sarah"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="true">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="true" open="">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - query syntax not recursive tree builder";
+var queryType = "rdf";
+var isTreeBuilder = true;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Lobster'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'crustaceans'));
+ container.AppendElement(newnode);
+ },
+ // step 4
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 5
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 6
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" flags="dont-recurse dont-build-content" id="root">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+<treecol label="Species"/>
+</treecols>
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<action>
+<treechildren>
+<treeitem uri="?child">
+<treerow>
+<treecell label="?name"/>
+<treecell/>
+</treerow>
+</treeitem>
+</treechildren>
+</action>
+</rule>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursive.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursive.xul
new file mode 100644
index 000000000..1002cd00c
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursive.xul
@@ -0,0 +1,215 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - query syntax recursive
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah">
+ <treerow>
+ <treecell label="Sarah"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" open="true">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/lion">
+ <treerow>
+ <treecell label="Lion"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">
+ <treerow>
+ <treecell label="HIPPOPOTAMUS"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
+ <treerow>
+ <treecell label="African Elephant"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="2" id="http://www.some-fictitious-zoo.com/mammals/koala">
+ <treerow>
+ <treecell label="Koala"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/llama">
+ <treerow>
+ <treecell label="LLAMA"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/polarbear">
+ <treerow>
+ <treecell label="Polar Bear"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/aardvark">
+ <treerow>
+ <treecell label="aardvark"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+ <treerow>
+ <treecell label="Nine-banded Armadillo"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/gorilla">
+ <treerow>
+ <treecell label="Gorilla"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </treeitem>
+ <treeitem step="-3" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="3,-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false" open="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/crustaceans/lobster">
+ <treerow>
+ <treecell label="Lobster"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - query syntax recursive";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Lobster'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'crustaceans'));
+ container.AppendElement(newnode);
+ },
+ // step 4
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 5
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 6
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" id="root">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+<treecol label="Species"/>
+</treecols>
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<action>
+<treechildren>
+<treeitem uri="?child">
+<treerow>
+<treecell label="?name"/>
+<treecell/>
+</treerow>
+</treeitem>
+</treechildren>
+</action>
+</rule>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerules.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerules.xul
new file mode 100644
index 000000000..282beb69d
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerules.xul
@@ -0,0 +1,268 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - query syntax recursive multiple rules
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah">
+ <treerow>
+ <treecell label="Sarah"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Mammals?"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" open="true">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Mammals?"/>
+ </treerow>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/lion">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Lion?"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">
+ <treerow>
+ <treecell label="HIPPOPOTAMUS"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: African Elephant?"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="2" id="http://www.some-fictitious-zoo.com/mammals/koala">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Koala?"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/llama">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: LLAMA?"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/polarbear">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Polar Bear?"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/aardvark">
+ <treerow>
+ <treecell label="aardvark"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Nine-banded Armadillo?"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/gorilla">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Gorilla?"/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </treeitem>
+ <treeitem step="-3" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="3,-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="5" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false" open="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/crustaceans/lobster">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Lobster?"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/crustaceans/crayfish">
+ <treerow>
+ <treecell label="Crayfish"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - query syntax recursive multiple rules";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/lion', true, true,
+ '1 matching rule 1');
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/hippopotamus', true, true,
+ '1 matching rule 2');
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/africanelephant', true, true,
+ '1 matching rule 1');
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/llama', true, true,
+ '1 matching rule 1');
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/polarbear', true, true,
+ '1 matching rule 1');
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/aardvark', true, true,
+ '1 matching rule 2');
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/ninebandedarmadillo', true, true,
+ '1 matching rule 1');
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/gorilla', true, true,
+ '1 matching rule 1');
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/koala', true, true,
+ '1 matching rule 1');
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Lobster'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'crustaceans'));
+ container.AppendElement(newnode);
+ },
+ // step 4
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/crayfish');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Crayfish'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'crustaceans'));
+ container.AppendElement(newnode);
+ },
+ // step 5
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ expectConsoleMessage(ZOO_NS + 'crustaceans', ZOO_NS + 'crustaceans/lobster', true, true,
+ '1 matching rule 1');
+ expectConsoleMessage(ZOO_NS + 'crustaceans', ZOO_NS + 'crustaceans/crayfish', true, true,
+ '1 matching rule 2');
+ },
+ // step 6
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 7
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true"
+ flags="logging" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" id="root">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+<treecol label="Species"/>
+</treecols>
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions>
+<where subject="?name" rel="contains" value="l" ignorecase="true"/>
+</conditions>
+<action>
+<treechildren>
+<treeitem uri="?child">
+<treerow>
+<treecell/>
+<treecell label="Is this cool: ?name^??"/>
+</treerow>
+</treeitem>
+</treechildren>
+</action>
+</rule>
+<rule>
+<action>
+<treechildren>
+<treeitem uri="?child">
+<treerow>
+<treecell label="?name"/>
+<treecell/>
+</treerow>
+</treeitem>
+</treechildren>
+</action>
+</rule>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerulestreebuilder.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerulestreebuilder.xul
new file mode 100644
index 000000000..8c9e5c012
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerulestreebuilder.xul
@@ -0,0 +1,230 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - query syntax recursive multiple rules tree builder
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah">
+ <treerow>
+ <treecell label="Sarah"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Mammals?"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" open="true">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Mammals?"/>
+ </treerow>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/lion">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Lion?"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">
+ <treerow>
+ <treecell label="HIPPOPOTAMUS"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: African Elephant?"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="2" id="http://www.some-fictitious-zoo.com/mammals/koala">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Koala?"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/llama">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: LLAMA?"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/polarbear">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Polar Bear?"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/aardvark">
+ <treerow>
+ <treecell label="aardvark"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Nine-banded Armadillo?"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/gorilla">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Gorilla?"/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </treeitem>
+ <treeitem step="-3" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="3,-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false" open="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/crustaceans/lobster">
+ <treerow>
+ <treecell/>
+ <treecell label="Is this cool: Lobster?"/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - query syntax recursive multiple rules tree builder";
+var queryType = "rdf";
+var isTreeBuilder = true;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Lobster'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'crustaceans'));
+ container.AppendElement(newnode);
+ },
+ // step 4
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 5
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 6
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" flags=" dont-build-content" id="root">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+<treecol label="Species"/>
+</treecols>
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions>
+<where subject="?name" rel="contains" value="l" ignorecase="true"/>
+</conditions>
+<action>
+<treechildren>
+<treeitem uri="?child">
+<treerow>
+<treecell/>
+<treecell label="Is this cool: ?name^??"/>
+</treerow>
+</treeitem>
+</treechildren>
+</action>
+</rule>
+<rule>
+<action>
+<treechildren>
+<treeitem uri="?child">
+<treerow>
+<treecell label="?name"/>
+<treecell/>
+</treerow>
+</treeitem>
+</treechildren>
+</action>
+</rule>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivetreebuilder.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivetreebuilder.xul
new file mode 100644
index 000000000..387279240
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivetreebuilder.xul
@@ -0,0 +1,215 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - query syntax recursive tree builder
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah">
+ <treerow>
+ <treecell label="Sarah"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" open="true">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/lion">
+ <treerow>
+ <treecell label="Lion"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">
+ <treerow>
+ <treecell label="HIPPOPOTAMUS"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
+ <treerow>
+ <treecell label="African Elephant"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="2" id="http://www.some-fictitious-zoo.com/mammals/koala">
+ <treerow>
+ <treecell label="Koala"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/llama">
+ <treerow>
+ <treecell label="LLAMA"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/polarbear">
+ <treerow>
+ <treecell label="Polar Bear"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/aardvark">
+ <treerow>
+ <treecell label="aardvark"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+ <treerow>
+ <treecell label="Nine-banded Armadillo"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/gorilla">
+ <treerow>
+ <treecell label="Gorilla"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </treeitem>
+ <treeitem step="-3" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="3,-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false" open="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/crustaceans/lobster">
+ <treerow>
+ <treecell label="Lobster"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - query syntax recursive tree builder";
+var queryType = "rdf";
+var isTreeBuilder = true;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Lobster'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'crustaceans'));
+ container.AppendElement(newnode);
+ },
+ // step 4
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 5
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 6
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" flags=" dont-build-content" id="root">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+<treecol label="Species"/>
+</treecols>
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<action>
+<treechildren>
+<treeitem uri="?child">
+<treerow>
+<treecell label="?name"/>
+<treecell/>
+</treerow>
+</treeitem>
+</treechildren>
+</action>
+</rule>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxtreebuilder.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxtreebuilder.xul
new file mode 100644
index 000000000..e857c8e0e
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxtreebuilder.xul
@@ -0,0 +1,158 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - query syntax tree builder
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell step="-6" label="12"/>
+ <treecell step="6" label="0"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+ <treerow>
+ <treecell label="Archaeopteryx"/>
+ <treecell step="-4"/>
+ <treecell step="4" label="5"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-2" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <treerow>
+ <treecell label="Barn Owl"/>
+ <treecell label="4"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/raven">
+ <treerow>
+ <treecell step="-7" label="Raven"/>
+ <treecell step="7" label="Crow"/>
+ <treecell step="-5" label="0"/>
+ <treecell step="5" label="2"/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - query syntax tree builder";
+var queryType = "rdf";
+var isTreeBuilder = true;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '2', true);
+ },
+ // step 2
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ },
+ // step 3
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'),
+ RDF.GetResource(ZOO_NS + 'rdf#species'),
+ RDF.GetLiteral('Archaeopteryx lithographica'), true);
+ },
+ // step 4
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ RDF.GetLiteral('5'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/raven');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/raven'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('2'));
+ },
+ // step 6
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/emu');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/emu'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimens'),
+ oldval, RDF.GetLiteral('0'));
+ },
+ // step 7
+ function(targetds, root) {
+ var subject = RDF.GetResource(ZOO_NS + 'birds/raven');
+ var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
+ var oldval = targetds.GetTarget(subject, predicate, true);
+ targetds.Change(RDF.GetResource(ZOO_NS + 'birds/raven'),
+ RDF.GetResource(ZOO_NS + 'rdf#name'),
+ oldval, RDF.GetLiteral('Crow'));
+ }
+];
+]]>
+</script>
+
+<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">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+<treecol label="Species"/>
+</treecols>
+<template id="template">
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<bindings>
+<binding subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</bindings>
+<action>
+<treechildren>
+<treeitem uri="?child">
+<treerow>
+<treecell label="?name"/>
+<treecell label="?specimens"/>
+</treerow>
+</treeitem>
+</treechildren>
+</action>
+</rule>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxnotrecursive.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxnotrecursive.xul
new file mode 100644
index 000000000..ff447916e
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxnotrecursive.xul
@@ -0,0 +1,136 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - simple syntax not recursive
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah">
+ <treerow>
+ <treecell label="Sarah"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" open="true">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - simple syntax not recursive";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Lobster'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'crustaceans'));
+ container.AppendElement(newnode);
+ },
+ // step 4
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 5
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 6
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" flags="dont-recurse" ref="http://www.some-fictitious-zoo.com/marked" id="root">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+<treecol label="Species"/>
+</treecols>
+<template id="template">
+<treechildren>
+<treeitem uri="rdf:*">
+<treerow>
+<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+<treecell/>
+</treerow>
+</treeitem>
+</treechildren>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxnotrecursivetreebuilder.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxnotrecursivetreebuilder.xul
new file mode 100644
index 000000000..793506143
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxnotrecursivetreebuilder.xul
@@ -0,0 +1,136 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - simple syntax not recursive tree builder
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah">
+ <treerow>
+ <treecell label="Sarah"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="true">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="true" open="">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - simple syntax not recursive tree builder";
+var queryType = "rdf";
+var isTreeBuilder = true;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Lobster'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'crustaceans'));
+ container.AppendElement(newnode);
+ },
+ // step 4
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 5
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 6
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" flags="dont-recurse dont-build-content" ref="http://www.some-fictitious-zoo.com/marked" id="root">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+<treecol label="Species"/>
+</treecols>
+<template id="template">
+<treechildren>
+<treeitem uri="rdf:*">
+<treerow>
+<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+<treecell/>
+</treerow>
+</treeitem>
+</treechildren>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxrecursive.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxrecursive.xul
new file mode 100644
index 000000000..009dd1367
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxrecursive.xul
@@ -0,0 +1,206 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - simple syntax recursive
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah">
+ <treerow>
+ <treecell label="Sarah"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" open="true">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/lion">
+ <treerow>
+ <treecell label="Lion"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">
+ <treerow>
+ <treecell label="HIPPOPOTAMUS"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
+ <treerow>
+ <treecell label="African Elephant"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="2" id="http://www.some-fictitious-zoo.com/mammals/koala">
+ <treerow>
+ <treecell label="Koala"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/llama">
+ <treerow>
+ <treecell label="LLAMA"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/polarbear">
+ <treerow>
+ <treecell label="Polar Bear"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/aardvark">
+ <treerow>
+ <treecell label="aardvark"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+ <treerow>
+ <treecell label="Nine-banded Armadillo"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/gorilla">
+ <treerow>
+ <treecell label="Gorilla"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </treeitem>
+ <treeitem step="-3" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="3,-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false" open="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/crustaceans/lobster">
+ <treerow>
+ <treecell label="Lobster"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - simple syntax recursive";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Lobster'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'crustaceans'));
+ container.AppendElement(newnode);
+ },
+ // step 4
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 5
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 6
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" flags="" ref="http://www.some-fictitious-zoo.com/marked" id="root">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+<treecol label="Species"/>
+</treecols>
+<template id="template">
+<treechildren>
+<treeitem uri="rdf:*">
+<treerow>
+<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+<treecell/>
+</treerow>
+</treeitem>
+</treechildren>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxrecursivetreebuilder.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxrecursivetreebuilder.xul
new file mode 100644
index 000000000..3cd7a8f07
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxrecursivetreebuilder.xul
@@ -0,0 +1,206 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - simple syntax recursive tree builder
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah">
+ <treerow>
+ <treecell label="Sarah"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" open="true">
+ <treerow>
+ <treecell label="Mammals"/>
+ <treecell/>
+ </treerow>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/lion">
+ <treerow>
+ <treecell label="Lion"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">
+ <treerow>
+ <treecell label="HIPPOPOTAMUS"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
+ <treerow>
+ <treecell label="African Elephant"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="2" id="http://www.some-fictitious-zoo.com/mammals/koala">
+ <treerow>
+ <treecell label="Koala"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/llama">
+ <treerow>
+ <treecell label="LLAMA"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/polarbear">
+ <treerow>
+ <treecell label="Polar Bear"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/aardvark">
+ <treerow>
+ <treecell label="aardvark"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+ <treerow>
+ <treecell label="Nine-banded Armadillo"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/mammals/gorilla">
+ <treerow>
+ <treecell label="Gorilla"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </treeitem>
+ <treeitem step="-3" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="3,-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false" open="true">
+ <treerow>
+ <treecell label="Crustaceans"/>
+ <treecell/>
+ </treerow>
+ <treechildren>
+ <treeitem id="http://www.some-fictitious-zoo.com/crustaceans/lobster">
+ <treerow>
+ <treecell label="Lobster"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - simple syntax recursive tree builder";
+var queryType = "rdf";
+var isTreeBuilder = true;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Lobster'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'crustaceans'));
+ container.AppendElement(newnode);
+ },
+ // step 4
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 5
+ function(targetds, root) {
+ if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
+ root.view.toggleOpenState(11);
+ },
+ // step 6
+ function(targetds, root) {
+ if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
+ root.view.toggleOpenState(1);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" flags="dont-build-content" ref="http://www.some-fictitious-zoo.com/marked" id="root">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+<treecol label="Species"/>
+</treecols>
+<template id="template">
+<treechildren>
+<treeitem uri="rdf:*">
+<treerow>
+<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+<treecell/>
+</treerow>
+</treeitem>
+</treechildren>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecell.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecell.xul
new file mode 100644
index 000000000..43c926ec8
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecell.xul
@@ -0,0 +1,133 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - treecell
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
+ <treerow>
+ <treecell label="Wren"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell label="Dromaius novaehollandiae"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <treerow>
+ <treecell label="Barn Owl"/>
+ <treecell label="Tyto alba"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/raven">
+ <treerow>
+ <treecell label="Raven"/>
+ <treecell label="Corvus corax"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+ <treerow>
+ <treecell label="Archaeopteryx"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
+ <treerow>
+ <treecell label="Emperor Penguin"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - treecell";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds" hidevscroll="true" hidehscroll="true">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+<treecol label="Species" ordinal="3"/>
+</treecols>
+<template id="template">
+<treechildren id="treechildren">
+<treeitem uri="rdf:*">
+<treerow>
+<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#species"/>
+</treerow>
+</treeitem>
+</treechildren>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecellsortascending.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecellsortascending.xul
new file mode 100644
index 000000000..da6c52507
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecellsortascending.xul
@@ -0,0 +1,133 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - treecell sort ascending
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1" sort="rdf:http://www.some-fictitious-zoo.com/rdf#name" sortDirection="ascending" sortActive="true"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+ <treerow>
+ <treecell label="Archaeopteryx"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <treerow>
+ <treecell label="Barn Owl"/>
+ <treecell label="Tyto alba"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
+ <treerow>
+ <treecell label="Emperor Penguin"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell label="Dromaius novaehollandiae"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/raven">
+ <treerow>
+ <treecell label="Raven"/>
+ <treecell label="Corvus corax"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
+ <treerow>
+ <treecell label="Wren"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - treecell sort ascending";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" flags="" sort="rdf:http://www.some-fictitious-zoo.com/rdf#name" sortDirection="ascending" id="root" ref="http://www.some-fictitious-zoo.com/birds">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name" ordinal="1" sort="rdf:http://www.some-fictitious-zoo.com/rdf#name" sortDirection="ascending" sortActive="true"/>
+<treecol label="Species" ordinal="3"/>
+</treecols>
+<template id="template">
+<treechildren id="treechildren">
+<treeitem uri="rdf:*">
+<treerow>
+<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#species"/>
+</treerow>
+</treeitem>
+</treechildren>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecellsortascendingtreebuilder.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecellsortascendingtreebuilder.xul
new file mode 100644
index 000000000..a4f0e2417
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecellsortascendingtreebuilder.xul
@@ -0,0 +1,133 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - treecell sort ascending tree builder
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1" sort="rdf:http://www.some-fictitious-zoo.com/rdf#name" sortDirection="ascending" sortActive="true"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+ <treerow>
+ <treecell label="Archaeopteryx"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <treerow>
+ <treecell label="Barn Owl"/>
+ <treecell label="Tyto alba"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
+ <treerow>
+ <treecell label="Emperor Penguin"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell label="Dromaius novaehollandiae"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/raven">
+ <treerow>
+ <treecell label="Raven"/>
+ <treecell label="Corvus corax"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
+ <treerow>
+ <treecell label="Wren"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - treecell sort ascending tree builder";
+var queryType = "rdf";
+var isTreeBuilder = true;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" flags="dont-build-content" sort="rdf:http://www.some-fictitious-zoo.com/rdf#name" sortDirection="ascending" id="root" ref="http://www.some-fictitious-zoo.com/birds">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name" ordinal="1" sort="rdf:http://www.some-fictitious-zoo.com/rdf#name" sortDirection="ascending" sortActive="true"/>
+<treecol label="Species" ordinal="3"/>
+</treecols>
+<template id="template">
+<treechildren id="treechildren">
+<treeitem uri="rdf:*">
+<treerow>
+<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#species"/>
+</treerow>
+</treeitem>
+</treechildren>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecelltreebuilder.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecelltreebuilder.xul
new file mode 100644
index 000000000..dcc14e0bb
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecelltreebuilder.xul
@@ -0,0 +1,133 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - treecell tree builder
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ <treecol label="Species" ordinal="3"/>
+ </treecols>
+ <treechildren>
+ <treeitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
+ <treerow>
+ <treecell label="Wren"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
+ <treerow>
+ <treecell label="Emu"/>
+ <treecell label="Dromaius novaehollandiae"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+ <treerow>
+ <treecell label="Barn Owl"/>
+ <treecell label="Tyto alba"/>
+ </treerow>
+ </treeitem>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/raven">
+ <treerow>
+ <treecell label="Raven"/>
+ <treecell label="Corvus corax"/>
+ </treerow>
+ </treeitem>
+ <treeitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+ <treerow>
+ <treecell label="Archaeopteryx"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
+ <treerow>
+ <treecell label="Emperor Penguin"/>
+ <treecell/>
+ </treerow>
+ </treeitem>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - treecell tree builder";
+var queryType = "rdf";
+var isTreeBuilder = true;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = true;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+<treecol label="Species" ordinal="3"/>
+</treecols>
+<template id="template">
+<treechildren id="treechildren">
+<treeitem uri="rdf:*">
+<treerow>
+<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+<treecell label="rdf:http://www.some-fictitious-zoo.com/rdf#species"/>
+</treerow>
+</treeitem>
+</treechildren>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreeitemonly.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreeitemonly.xul
new file mode 100644
index 000000000..fb94cbdad
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreeitemonly.xul
@@ -0,0 +1,96 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - treeitem only
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
+ </treecols>
+ <treechildren>
+ <treeitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ <treeitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ <treeitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - treeitem only";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds" hidevscroll="true" hidehscroll="true">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name"/>
+</treecols>
+<template id="template">
+<treechildren id="treechildren">
+<treeitem uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</treechildren>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreeitemsortascending.xul b/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreeitemsortascending.xul
new file mode 100644
index 000000000..654e79e1c
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_treeelementtreeitemsortascending.xul
@@ -0,0 +1,96 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ tree element - treeitem sort ascending
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <treecols id="treecols" orient="horizontal">
+ <treecol id="treecol" primary="true" label="Name" ordinal="1" sort="rdf:http://www.some-fictitious-zoo.com/rdf#name" sortDirection="ascending" sortActive="true"/>
+ </treecols>
+ <treechildren>
+ <treeitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+ <treeitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+ <treeitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ <treeitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ <treeitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+ </treechildren>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="tree element - treeitem sort ascending";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" sort="rdf:http://www.some-fictitious-zoo.com/rdf#name" sortDirection="ascending" id="root" ref="http://www.some-fictitious-zoo.com/birds">
+<treecols orient="horizontal" id="treecols">
+<treecol id="treecol" primary="true" label="Name" ordinal="1" sort="rdf:http://www.some-fictitious-zoo.com/rdf#name" sortDirection="ascending" sortActive="true"/>
+</treecols>
+<template id="template">
+<treechildren id="treechildren">
+<treeitem uri="rdf:*" label="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
+</treechildren>
+</template>
+</tree>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_twogenerationnodes.xul b/dom/xul/templates/tests/chrome/test_tmpl_twogenerationnodes.xul
new file mode 100644
index 000000000..17528d34b
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_twogenerationnodes.xul
@@ -0,0 +1,100 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ two generation nodes
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+ <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+ <button step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+ <button step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+ <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+ <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+ <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+ <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="two generation nodes";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Emperor Penguin'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Archaeopteryx'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'birds/wren');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Wren'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'birds'));
+ var removednode = container.RemoveElementAt('3', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Barn Owl'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
+<template>
+<query>
+<content uri="?uri"/>
+<member container="?uri" child="?child"/>
+<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<action>
+<button uri="?child" label="?name"/>
+<button uri="?child" label="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereafterignorecase.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereafterignorecase.xul
new file mode 100644
index 000000000..1fda7ec75
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereafterignorecase.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - after ignore case
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - after ignore case";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="after" ignorecase="true" value="l"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereafterlowercase.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereafterlowercase.xul
new file mode 100644
index 000000000..987c9a468
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereafterlowercase.xul
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - after lowercase
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - after lowercase";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = true;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="after" value="l"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereafternegation.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereafternegation.xul
new file mode 100644
index 000000000..4ae159991
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereafternegation.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - after negation
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - after negation";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="after" negate="true" value="H"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereafteruppercase.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereafteruppercase.xul
new file mode 100644
index 000000000..4f11a3de3
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereafteruppercase.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - after uppercase
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - after uppercase";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="after" value="L"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherebeforeignorecase.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherebeforeignorecase.xul
new file mode 100644
index 000000000..130f3ee76
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherebeforeignorecase.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - before ignore case
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - before ignore case";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = true;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="before" ignorecase="true" value="h"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherebeforelowercase.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherebeforelowercase.xul
new file mode 100644
index 000000000..b6a6a1de3
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherebeforelowercase.xul
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - before lowercase
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - before lowercase";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = true;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="before" value="l"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherebeforenegation.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherebeforenegation.xul
new file mode 100644
index 000000000..9885dbfce
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherebeforenegation.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - before negation
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - before negation";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="before" negate="true" value="N"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherebeforeuppercase.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherebeforeuppercase.xul
new file mode 100644
index 000000000..40cd73854
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherebeforeuppercase.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - before uppercase
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - before uppercase";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="before" value="H"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherecontains.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherecontains.xul
new file mode 100644
index 000000000..09818b1e1
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherecontains.xul
@@ -0,0 +1,113 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - contains
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - contains";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Arctic Hare'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Zebra'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('4', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 6
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'),
+ RDF.GetLiteral('8'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="contains" value="e"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsignorecase.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsignorecase.xul
new file mode 100644
index 000000000..ecec06997
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsignorecase.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - contains ignore case
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - contains ignore case";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="contains" ignorecase="true" value="P"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnegation.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnegation.xul
new file mode 100644
index 000000000..07a421ef0
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnegation.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - contains negation
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - contains negation";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="contains" negate="true" value="a"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnumber.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnumber.xul
new file mode 100644
index 000000000..b1934edca
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnumber.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - contains number
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="2"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="20"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="2"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - contains number";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="contains" value="2"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?specimens"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnumberstring.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnumberstring.xul
new file mode 100644
index 000000000..033c87506
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnumberstring.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - contains number string
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="2"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="20"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="2"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - contains number string";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimensAsString" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="contains" value="2"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?specimens"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsresource.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsresource.xul
new file mode 100644
index 000000000..45569d41e
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherecontainsresource.xul
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - contains resource
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - contains resource";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?animal" rel="contains" value="/llama"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherecontainstwo.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherecontainstwo.xul
new file mode 100644
index 000000000..1519862fa
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherecontainstwo.xul
@@ -0,0 +1,113 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - contains two
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - contains two";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Arctic Hare'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Zebra'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('4', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 6
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'),
+ RDF.GetLiteral('8'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="contains" value="i"/>
+<where subject="?name" rel="contains" value="r"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereendswith.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereendswith.xul
new file mode 100644
index 000000000..69a6d68fc
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereendswith.xul
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - endswith
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - endswith";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="endswith" value="a"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereendswithignorecase.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereendswithignorecase.xul
new file mode 100644
index 000000000..34794c51a
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereendswithignorecase.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - endswith ignore case
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - endswith ignore case";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="endswith" ignorecase="true" value="A"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereendswithnegation.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereendswithnegation.xul
new file mode 100644
index 000000000..8d3d0c575
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereendswithnegation.xul
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - endswith negation
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - endswith negation";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="endswith" negate="true" value="k"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequals.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequals.xul
new file mode 100644
index 000000000..2679c607e
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequals.xul
@@ -0,0 +1,109 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Arctic Hare'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Zebra'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('4', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 6
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'),
+ RDF.GetLiteral('8'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="equals" value="African Elephant"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequalsignorecase.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsignorecase.xul
new file mode 100644
index 000000000..e26be898b
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsignorecase.xul
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals ignore case
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals ignore case";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="equals" ignorecase="true" value="GoriLLA"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiple.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiple.xul
new file mode 100644
index 000000000..00558388d
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiple.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals multiple
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals multiple";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="equals" multiple="true" value="Lion,Gorilla"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiplenegation.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiplenegation.xul
new file mode 100644
index 000000000..a66792dd7
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiplenegation.xul
@@ -0,0 +1,125 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals multiple negation
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals multiple negation";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Arctic Hare'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/arctichare', true, true,
+ '1 matching rule 1');
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/koala', true, false,
+ '1 (didn\'t match a rule)');
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Zebra'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '1', true);
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/zebra', true, true,
+ '1 matching rule 1');
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('4', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/africanelephant', false, true,
+ '1 (no new active query)');
+ },
+ // step 5
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/africanelephant', true, true,
+ '1 matching rule 1');
+ },
+ // step 6
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'),
+ RDF.GetLiteral('8'), true);
+ }
+];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" flags="logging"
+ datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="equals" multiple="true" negate="true" value="Lion,aardvark,LLAMA,Gorilla,Koala"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiplenegationignorecase.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiplenegationignorecase.xul
new file mode 100644
index 000000000..67b3f2fcf
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiplenegationignorecase.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals multiple negation ignore case
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals multiple negation ignore case";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="equals" multiple="true" ignorecase="true" negate="true" value="Lion,Aardvark,llama,Polar BEAR"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegation.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegation.xul
new file mode 100644
index 000000000..edcac5542
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegation.xul
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals negation
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals negation";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="equals" negate="true" value="Polar Bear"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegationignorecase.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegationignorecase.xul
new file mode 100644
index 000000000..cd877f1ce
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegationignorecase.xul
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals negation ignore case
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals negation ignore case";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="equals" negate="true" ignorecase="true" value="AFRICAN Elephant"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegationwrongcase.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegationwrongcase.xul
new file mode 100644
index 000000000..16eca331e
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegationwrongcase.xul
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals negation wrong case
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals negation wrong case";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="equals" negate="true" value="Llama"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequalsnumber.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsnumber.xul
new file mode 100644
index 000000000..c036a3c6a
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsnumber.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals number
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="2"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="2"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals number";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="equals" value="2"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?specimens"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequalsothervariable.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsothervariable.xul
new file mode 100644
index 000000000..a6ae12135
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsothervariable.xul
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals other variable
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals other variable";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?othername"/>
+</query>
+<rule id="rule">
+<conditions id="conditions">
+<where subject="?name" rel="equals" value="?othername"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequalsresource.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsresource.xul
new file mode 100644
index 000000000..d2779a20f
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequalsresource.xul
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals resource
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals resource";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?animal" rel="equals" value="http://www.some-fictitious-zoo.com/mammals/polarbear"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequalssamevariable.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequalssamevariable.xul
new file mode 100644
index 000000000..455fd147f
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequalssamevariable.xul
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals same variable
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals same variable";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="equals" value="?name"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereequalswrongcase.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereequalswrongcase.xul
new file mode 100644
index 000000000..b67200b57
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereequalswrongcase.xul
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - equals wrong case
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - equals wrong case";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="equals" value="Llama"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wheregreater.xul b/dom/xul/templates/tests/chrome/test_tmpl_wheregreater.xul
new file mode 100644
index 000000000..5276fb598
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wheregreater.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - greater
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="14"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="5"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="20"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="7"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - greater";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="greater" value="4"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?specimens"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wheregreaternegation.xul b/dom/xul/templates/tests/chrome/test_tmpl_wheregreaternegation.xul
new file mode 100644
index 000000000..7daa0a7cc
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wheregreaternegation.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - greater negation
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="4"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="2"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="2"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="1"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - greater negation";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="greater" negate="true" value="4"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?specimens"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wheregreaternegationstring.xul b/dom/xul/templates/tests/chrome/test_tmpl_wheregreaternegationstring.xul
new file mode 100644
index 000000000..22f351547
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wheregreaternegationstring.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - greater negation string
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="4"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="2"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="2"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="1"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - greater negation string";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimensAsString" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="greater" negate="true" value="4"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?specimens"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wheregreaterstring.xul b/dom/xul/templates/tests/chrome/test_tmpl_wheregreaterstring.xul
new file mode 100644
index 000000000..f7c1e4b11
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wheregreaterstring.xul
@@ -0,0 +1,113 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - greater string
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="14"/>
+ <label step="6" id="http://www.some-fictitious-zoo.com/mammals/koala" value="8"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="5"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="20"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="7"/>
+ <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="14"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - greater string";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Arctic Hare'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Zebra'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('4', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 6
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'),
+ RDF.GetLiteral('8'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimensAsString" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="greater" value="4"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?specimens"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_whereless.xul b/dom/xul/templates/tests/chrome/test_tmpl_whereless.xul
new file mode 100644
index 000000000..4c42f54e2
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_whereless.xul
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - less
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="4"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="2"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="5"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="2"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="1"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="7"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - less";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="less" value="14"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?specimens"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherelessnegation.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherelessnegation.xul
new file mode 100644
index 000000000..46e9d7819
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherelessnegation.xul
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - less negation
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="4"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="14"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="5"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="20"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="7"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - less negation";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="less" negate="true" value="4"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?specimens"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherelessnegationstring.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherelessnegationstring.xul
new file mode 100644
index 000000000..728e7ae3d
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherelessnegationstring.xul
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - less negation string
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="4"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="14"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="5"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="20"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="7"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - less negation string";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimensAsString" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="less" negate="true" value="4"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?specimens"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherelessstring.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherelessstring.xul
new file mode 100644
index 000000000..445f5efa1
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherelessstring.xul
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - less string
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="4"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="2"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="5"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="2"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="1"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="7"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - less string";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#specimensAsString" object="?specimens"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?specimens" rel="less" value="14"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?specimens"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherenorel.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherenorel.xul
new file mode 100644
index 000000000..b7e79ba18
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherenorel.xul
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - no rel
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+expectLoggedMessages = function()
+{
+ expectedConsoleMessages.push("Error parsing template: <where> element is missing a rel attribute");
+}
+
+var testid ="where - no rel";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" value="Lion"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherenosubject.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherenosubject.xul
new file mode 100644
index 000000000..c6b566fbe
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherenosubject.xul
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - no subject
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+expectLoggedMessages = function()
+{
+ expectedConsoleMessages.push("Error parsing template: <where> element is missing a subject attribute");
+}
+
+var testid ="where - no subject";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where rel="startswith" value="d"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherenovalue.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherenovalue.xul
new file mode 100644
index 000000000..53507b0a3
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherenovalue.xul
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - no value
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+expectLoggedMessages = function()
+{
+ expectedConsoleMessages.push("Error parsing template: <where> element is missing a value attribute");
+}
+
+var testid ="where - no value";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="startswith"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherestartswith.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherestartswith.xul
new file mode 100644
index 000000000..6e86c981d
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherestartswith.xul
@@ -0,0 +1,108 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - startswith
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - startswith";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [
+ // step 1
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Arctic Hare'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 2
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Koala'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '4', true);
+ },
+ // step 3
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('Zebra'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.InsertElementAt(newnode, '1', true);
+ },
+ // step 4
+ function(targetds, root) {
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ var removednode = container.RemoveElementAt('4', true);
+ targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ },
+ // step 5
+ function(targetds, root) {
+ var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant');
+ targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
+ RDF.GetLiteral('African Elephant'), true);
+ var container = ContainerUtils.MakeSeq(targetds,
+ RDF.GetResource(ZOO_NS + 'mammals'));
+ container.AppendElement(newnode);
+ },
+ // step 6
+ function(targetds, root) {
+ targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'),
+ RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'),
+ RDF.GetLiteral('8'), true);
+ }
+];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="startswith" value="a"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithignorecase.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithignorecase.xul
new file mode 100644
index 000000000..434ba40c4
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithignorecase.xul
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - startswith ignore case
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - startswith ignore case";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="startswith" ignorecase="true" value="a"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithmultiple.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithmultiple.xul
new file mode 100644
index 000000000..4876ed383
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithmultiple.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - startswith multiple
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - startswith multiple";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="startswith" multiple="true" value="L,A"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithnegation.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithnegation.xul
new file mode 100644
index 000000000..4ab12c74d
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithnegation.xul
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - startswith negation
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - startswith negation";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="startswith" negate="true" value="L"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithunknownvariable.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithunknownvariable.xul
new file mode 100644
index 000000000..9fd794b92
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithunknownvariable.xul
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - startswith unknown variable
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output"/>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - startswith unknown variable";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="startswith" value="?unknown"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithvariable.xul b/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithvariable.xul
new file mode 100644
index 000000000..41e2be959
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wherestartswithvariable.xul
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - startswith variable
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+ <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - startswith variable";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="?name" rel="startswith" value="?name"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wheresubjectequalsvariable.xul b/dom/xul/templates/tests/chrome/test_tmpl_wheresubjectequalsvariable.xul
new file mode 100644
index 000000000..14c03898c
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wheresubjectequalsvariable.xul
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - subject equals variable
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - subject equals variable";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="African Elephant" rel="equals" value="?name"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_wheresubjectstartswithvariable.xul b/dom/xul/templates/tests/chrome/test_tmpl_wheresubjectstartswithvariable.xul
new file mode 100644
index 000000000..dd93aa285
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_wheresubjectstartswithvariable.xul
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ where - subject startswith variable
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="where - subject startswith variable";
+var queryType = "rdf";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<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">
+<template id="template">
+<query id="query">
+<content uri="?uri"/>
+<member container="?uri" child="?animal"/>
+<triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
+</query>
+<rule>
+<conditions id="conditions">
+<where subject="African Elephantitis" rel="startswith" value="?name"/>
+</conditions>
+<action id="action">
+<label uri="?animal" value="?name"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerysimple.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerysimple.xul
new file mode 100644
index 000000000..9a576e370
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerysimple.xul
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query simple
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Chamaeleo-chamaelon" label="Chameleon 2"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Dromaius-novaehollandiae" label="Emu 12"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Tyto-alba" label="Barn Owl 4"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Corvus-corax" label="Raven 0"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query simple";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="animals.xml" querytype="xml" ref=".">
+<template expr="class/species">
+<button uri="?" label="?name ?specimens"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassign.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassign.xul
new file mode 100644
index 000000000..39992b43e
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassign.xul
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query with assign
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Chamaeleo-chamaelon">
+ <button label="Chameleon"/>
+ <label value="9"/>
+ </hbox>
+ <hbox id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Dromaius-novaehollandiae">
+ <button label="Emu"/>
+ <label value="3"/>
+ </hbox>
+ <hbox id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Tyto-alba">
+ <button label="Barn Owl"/>
+ <label value="8"/>
+ </hbox>
+ <hbox id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Corvus-corax">
+ <button label="Raven"/>
+ <label value="5"/>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query with assign";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="animals.xml" querytype="xml" ref=".">
+<template>
+<query expr="class/species">
+<assign var="?length" expr="string-length(@name)"/>
+</query>
+<action>
+<hbox uri="?">
+<button label="?name"/>
+<label value="?length"/>
+</hbox>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassignmentandcondition.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassignmentandcondition.xul
new file mode 100644
index 000000000..fdbbed321
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassignmentandcondition.xul
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query with assignment and condition
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox anyid="true" container="true" empty="false">
+ <label value="class"/>
+ <hbox anyid="true" container="true" empty="true">
+ <label value="name"/>
+ </hbox>
+ </hbox>
+ <hbox anyid="true" container="true" empty="false">
+ <label value="class"/>
+ <hbox anyid="true" container="true" empty="true">
+ <label value="name"/>
+ </hbox>
+ <hbox anyid="true" container="true" empty="true">
+ <label value="location"/>
+ </hbox>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query with assignment and condition";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="animals.xml" querytype="xml" ref=".">
+<template>
+<query>
+<assign var="?name" expr="name()"/>
+</query>
+<rule>
+<where subject="?name" rel="equals" negate="true" value="species"/>
+<action>
+<hbox uri="?">
+<label value="?name"/>
+</hbox>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassignmentandconditiondontrecurse.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassignmentandconditiondontrecurse.xul
new file mode 100644
index 000000000..8f7e747c3
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassignmentandconditiondontrecurse.xul
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query with assignment and condition dont-recurse
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <hbox anyid="true" container="true" empty="false">
+ <label value="class"/>
+ </hbox>
+ <hbox anyid="true" container="true" empty="false">
+ <label value="class"/>
+ </hbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query with assignment and condition dont-recurse";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="animals.xml" querytype="xml" ref="." flags="dont-recurse">
+<template>
+<query>
+<assign var="?name" expr="name()"/>
+</query>
+<rule>
+<where subject="?name" rel="equals" negate="true" value="species"/>
+<action>
+<hbox uri="?">
+<label value="?name"/>
+</hbox>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithbindinginbindings.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithbindinginbindings.xul
new file mode 100644
index 000000000..90372f62c
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithbindinginbindings.xul
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query with binding in bindings
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <checkbox anyid="true" container="true" empty="true" label="Reptiles"/>
+ <checkbox anyid="true" container="true" empty="true" label="Birds"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query with binding in bindings";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="animals.xml" querytype="xml" ref=".">
+<template>
+<query expr="class/name"/>
+<rule id="rule">
+<bindings>
+<binding subject="?" predicate="text()" object="?nm"/>
+</bindings>
+<action>
+<checkbox uri="?" label="?nm"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithbindinginrule.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithbindinginrule.xul
new file mode 100644
index 000000000..57ca2d838
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithbindinginrule.xul
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query with binding in rule
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <label anyid="true" container="true" empty="true" value="Class Reptiles"/>
+ <label anyid="true" container="true" empty="true" value="Class Birds"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query with binding in rule";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+Components.classes["@mozilla.org/consoleservice;1"].
+ getService(Components.interfaces.nsIConsoleService).reset();
+
+expectLoggedMessages = function()
+{
+ // check log to ensure that two rows have been added
+ var initialNumber = Number(document.getElementById("root").firstChild.nextSibling.id.substring(3));
+ expectConsoleMessage('', 'row' + initialNumber, true, true, '1 matching rule 1');
+ expectConsoleMessage('', 'row' + (initialNumber + 1), true, true, '1 matching rule 1');
+}
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root"
+ flags="logging" datasources="animals.xml" querytype="xml" ref=".">
+<template>
+<query expr="class/name"/>
+<rule id="rule">
+<binding subject="?" predicate="concat('Class ', text())" object="?text"/>
+<action>
+<label uri="?" value="?text"/>
+</action>
+</rule>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithdifferentmember.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithdifferentmember.xul
new file mode 100644
index 000000000..160d4bddb
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithdifferentmember.xul
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query with different member
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Chamaeleo-chamaelon" label="Chameleon 2"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Dromaius-novaehollandiae" label="Emu 12"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Tyto-alba" label="Barn Owl 4"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Corvus-corax" label="Raven 0"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query with different member";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="animals.xml" querytype="xml" ref=".">
+<template expr="class/species">
+<button uri="?memb" label="?name ?specimens"/>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithinlinedata.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithinlinedata.xul
new file mode 100644
index 000000000..010a6ba49
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithinlinedata.xul
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query with inline data
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button anyid="true" label="Nathan"/>
+ <button anyid="true" label="Marie"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query with inline data";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<people id="data" xmlns:test="http://www.mozilla.com/test">
+<test:person name="Nathan"/>
+<person name="Luke"/>
+<xt:person xmlns:xt="http://www.mozilla.com/test" name="Marie"/>
+</people>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="#data" querytype="xml" ref=".">
+<template expr="test:person">
+<button uri="?" label="?name"/>
+</template>
+<button id="row6" label="Nathan"/>
+<button id="row7" label="Marie"/>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithinlinedatawithmultiplequeries.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithinlinedatawithmultiplequeries.xul
new file mode 100644
index 000000000..d9640fbde
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithinlinedatawithmultiplequeries.xul
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query with inline data with multiple queries
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button anyid="true" label="Nathan"/>
+ <button anyid="true" label="Marie"/>
+ <checkbox anyid="true" label="Nathan"/>
+ <checkbox anyid="true" label="Luke"/>
+ <checkbox anyid="true" label="Marie"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query with inline data with multiple queries";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<people id="data" xmlns:test="http://www.mozilla.com/test">
+<test:person name="Nathan"/>
+<person name="Luke"/>
+<xt:person xmlns:xt="http://www.mozilla.com/test" name="Marie"/>
+</people>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="#data" querytype="xml" ref=".">
+<template>
+<queryset>
+<query expr="test:person"/>
+<action>
+<button uri="?" label="?name"/>
+</action>
+</queryset>
+<queryset>
+<query/>
+<action>
+<checkbox uri="?" label="?name"/>
+</action>
+</queryset>
+</template>
+<button id="row9" label="Nathan"/>
+<button id="row10" label="Marie"/>
+<checkbox id="row11" label="Nathan"/>
+<checkbox id="row12" label="Luke"/>
+<checkbox id="row13" label="Marie"/>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithmultiplequeries.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithmultiplequeries.xul
new file mode 100644
index 000000000..075d2c453
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithmultiplequeries.xul
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query with multiple queries
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Dromaius-novaehollandiae" label="(Dromaius-novaehollandiae) is a large bird"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Tyto-alba" label="(Tyto-alba) Barn Owl"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Corvus-corax" label="(Corvus-corax) Raven"/>
+ <label id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Chamaeleo-chamaelon" value="Chameleon"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query with multiple queries";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="animals.xml" querytype="xml" ref=".">
+<template>
+<queryset>
+<query expr="class[position()&gt;1]/species">
+<assign var="?id" expr="concat('(', @id, ')')"/>
+</query>
+<rule>
+<where subject="?id" rel="equals" value="(Dromaius-novaehollandiae)"/>
+<action>
+<button uri="?" label="?id is a large bird"/>
+</action>
+</rule>
+<rule>
+<binding subject="?" predicate="@name" object="?name"/>
+<action>
+<button uri="?" label="?id ?name"/>
+</action>
+</rule>
+</queryset>
+<queryset>
+<query expr="class[name/text()='Reptiles']/species"/>
+<action>
+<label uri="?" value="?name"/>
+</action>
+</queryset>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithothertypes.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithothertypes.xul
new file mode 100644
index 000000000..ce728b2b1
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithothertypes.xul
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query with other types
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <groupbox anyid="true" container="true" empty="false">
+ <caption label="Reptiles false"/>
+ <label id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Chamaeleo-chamaelon" value="Chameleon"/>
+ </groupbox>
+ <groupbox anyid="true" container="true" empty="false">
+ <caption label="Birds true"/>
+ <label id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Dromaius-novaehollandiae" value="Emu"/>
+ <label id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Tyto-alba" value="Barn Owl"/>
+ <label id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Corvus-corax" value="Raven"/>
+ </groupbox>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query with other types";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="animals.xml" querytype="xml" ref=".">
+<template>
+<queryset>
+<query expr="species">
+<assign var="?haschild" expr="boolean(location)"/>
+<assign var="?name" expr="@name"/>
+</query>
+<action>
+<label uri="?" value="?name"/>
+</action>
+</queryset>
+<queryset>
+<query>
+<assign var="?name" expr="name/text()"/>
+<assign var="?isbirds" expr="name/text() = 'Birds'"/>
+</query>
+<rule parent="vbox">
+<action>
+<groupbox uri="?">
+<caption label="?name ?isbirds"/>
+</groupbox>
+</action>
+</rule>
+</queryset>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithsort.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithsort.xul
new file mode 100644
index 000000000..b83fc3595
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithsort.xul
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query with sort
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Tyto-alba" label="Barn Owl"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Chamaeleo-chamaelon" label="Chameleon"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Dromaius-novaehollandiae" label="Emu"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Corvus-corax" label="Raven"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query with sort";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="animals.xml" querytype="xml" ref="." sort="?name" sortDirection="ascending">
+<template>
+<query expr="class/species"/>
+<action>
+<button uri="?" label="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>
diff --git a/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithsortotherfield.xul b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithsortotherfield.xul
new file mode 100644
index 000000000..ad1829d0d
--- /dev/null
+++ b/dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithsortotherfield.xul
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+
+<!--
+ xml query with sort other field
+-->
+
+<window title="XUL Template Tests" width="500" height="600"
+ onload="test_template();"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
+
+ <data id="output">
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Tyto-alba" label="Barn Owl"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Dromaius-novaehollandiae" label="Emu"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Corvus-corax" label="Raven"/>
+ <button id="chrome://mochitests/content/chrome/dom/xul/templates/tests/chrome/animals.xml#Chamaeleo-chamaelon" label="Chameleon"/>
+ </data>
+
+<script src="templates_shared.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+var testid ="xml query with sort other field";
+var queryType = "xml";
+var isTreeBuilder = false;
+var needsOpen = false;
+var notWorkingYet = false;
+var notWorkingYetDynamic = false;
+var expectedOutput = document.getElementById("output");
+
+var changes = [];
+]]>
+</script>
+
+<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="animals.xml" querytype="xml" ref="." sort="?id" sortDirection="descending">
+<template>
+<query expr="class/species"/>
+<action>
+<button uri="?" label="?name"/>
+</action>
+</template>
+</vbox>
+
+</window>