diff options
Diffstat (limited to 'toolkit/components/xulstore/tests/chrome')
5 files changed, 284 insertions, 0 deletions
diff --git a/toolkit/components/xulstore/tests/chrome/.eslintrc.js b/toolkit/components/xulstore/tests/chrome/.eslintrc.js new file mode 100644 index 0000000000..8c0f4f574c --- /dev/null +++ b/toolkit/components/xulstore/tests/chrome/.eslintrc.js @@ -0,0 +1,7 @@ +"use strict"; + +module.exports = { + "extends": [ + "../../../../../testing/mochitest/chrome.eslintrc.js" + ] +}; diff --git a/toolkit/components/xulstore/tests/chrome/animals.rdf b/toolkit/components/xulstore/tests/chrome/animals.rdf new file mode 100644 index 0000000000..c7319e641c --- /dev/null +++ b/toolkit/components/xulstore/tests/chrome/animals.rdf @@ -0,0 +1,142 @@ +<?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:name>Tarantula</ANIMALS:name> + </RDF:Description> + + <ANIMALS:Class RDF:about="http://www.some-fictitious-zoo.com/birds"> + <ANIMALS:name>Birds</ANIMALS:name> + </ANIMALS:Class> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/birds/emu"> + <ANIMALS:name>Emu</ANIMALS:name> + </RDF:Description> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/birds/barnowl"> + <ANIMALS:name>Barn Owl</ANIMALS:name> + </RDF:Description> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/birds/raven"> + <ANIMALS:name>Raven</ANIMALS:name> + </RDF:Description> + + <ANIMALS:Class RDF:about="http://www.some-fictitious-zoo.com/crustaceans"> + <ANIMALS:name>Crustaceans</ANIMALS:name> + </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:name>Cod</ANIMALS:name> + </RDF:Description> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/fish/swordfish"> + <ANIMALS:name>Swordfish</ANIMALS:name> + </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> + </RDF:Description> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/hippopotamus"> + <ANIMALS:name>HIPPOPOTAMUS</ANIMALS:name> + </RDF:Description> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/africanelephant"> + <ANIMALS:name>African Elephant</ANIMALS:name> + </RDF:Description> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/llama"> + <ANIMALS:name>LLAMA</ANIMALS:name> + </RDF:Description> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/polarbear"> + <ANIMALS:name>Polar Bear</ANIMALS:name> + </RDF:Description> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/aardvark"> + <ANIMALS:name>aardvark</ANIMALS:name> + </RDF:Description> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo"> + <ANIMALS:name>Nine-banded Armadillo</ANIMALS:name> + </RDF:Description> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/mammals/gorilla"> + <ANIMALS:name>Gorilla</ANIMALS:name> + </RDF:Description> + + <ANIMALS:Class RDF:about="http://www.some-fictitious-zoo.com/reptiles"> + <ANIMALS:name>Reptiles</ANIMALS:name> + </ANIMALS:Class> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/reptiles/anaconda"> + <ANIMALS:name>Anaconda</ANIMALS:name> + </RDF:Description> + + <RDF:Description RDF:about="http://www.some-fictitious-zoo.com/reptiles/chameleon"> + <ANIMALS:name>Chameleon</ANIMALS:name> + </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:RDF> diff --git a/toolkit/components/xulstore/tests/chrome/chrome.ini b/toolkit/components/xulstore/tests/chrome/chrome.ini new file mode 100644 index 0000000000..91efd5455a --- /dev/null +++ b/toolkit/components/xulstore/tests/chrome/chrome.ini @@ -0,0 +1,6 @@ +[DEFAULT] +support-files = + window_persistence.xul + animals.rdf + +[test_persistence.xul] diff --git a/toolkit/components/xulstore/tests/chrome/test_persistence.xul b/toolkit/components/xulstore/tests/chrome/test_persistence.xul new file mode 100644 index 0000000000..736a067edd --- /dev/null +++ b/toolkit/components/xulstore/tests/chrome/test_persistence.xul @@ -0,0 +1,31 @@ +<?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 title="Persistence Tests" + 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> + SimpleTest.waitForExplicitFinish(); + function runTest() { + window.openDialog("window_persistence.xul", "_blank", "chrome", true); + } + + function windowOpened() { + window.openDialog("window_persistence.xul", "_blank", "chrome", false); + } + + function testDone() { + SimpleTest.finish(); + } + </script> + +<body xmlns="http://www.w3.org/1999/xhtml"> + <p id="display"/> +</body> + +</window> diff --git a/toolkit/components/xulstore/tests/chrome/window_persistence.xul b/toolkit/components/xulstore/tests/chrome/window_persistence.xul new file mode 100644 index 0000000000..4d76fe11d1 --- /dev/null +++ b/toolkit/components/xulstore/tests/chrome/window_persistence.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"?> + +<window title="Persistence Tests" + onload="opened()" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + persist="screenX screenY width height"> + +<button id="button1" label="Button1" persist="value"/> +<button id="button2" label="Button2" value="Normal" persist="value"/> + +<tree id="tree" datasources="animals.rdf" ref="http://www.some-fictitious-zoo.com/all-animals" + flags="dont-build-content" width="200" height="200"> + <treecols orient="horizontal" id="treecols"> + <treecol id="treecol" primary="true" label="Name" flex="1"/> + </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> + +<script> +<![CDATA[ + +var Cc = Components.classes; +var Ci = Components.interfaces; + +let XULStore = Cc["@mozilla.org/xul/xulstore;1"].getService(Ci.nsIXULStore); +let URI = "chrome://mochitests/content/chrome/toolkit/components/xulstore/tests/chrome/window_persistence.xul"; + +function opened() +{ + // If the data in the tree has not been loaded yet, wait a bit and try again. + var treeView = document.getElementById("tree").view; + if (treeView.rowCount != 6 && treeView.rowCount != 17) { + setTimeout(opened, 50); + return; + } + + runTest(treeView); +} + +function runTest(treeView) +{ + var firstRun = window.arguments[0]; + if (firstRun) { + document.getElementById("button1").setAttribute("value", "Pressed"); + document.getElementById("button2").removeAttribute("value"); + + document.getElementById("button2").setAttribute("foo", "bar"); + document.persist("button2", "foo"); + is(XULStore.getValue(URI, "button2", "foo"), "bar", "attribute persisted") + document.getElementById("button2").removeAttribute("foo"); + document.persist("button2", "foo"); + is(XULStore.hasValue(URI, "button2", "foo"), false, "attribute removed") + + is(treeView.rowCount, 6, "tree rows are closed"); + treeView.toggleOpenState(1); + treeView.toggleOpenState(7); + + window.close(); + window.opener.windowOpened(); + } + else { + is(document.getElementById("button1").getAttribute("value"), "Pressed", + "Attribute set"); + is(document.getElementById("button2").hasAttribute("value"), true, + "Attribute cleared"); + is(document.getElementById("button2").getAttribute("value"), "", + "Attribute cleared"); + is(document.getElementById("button2").hasAttribute("foo"), false, + "Attribute cleared"); + is(document.getElementById("button2").getAttribute("foo"), "", + "Attribute cleared"); + + is(treeView.rowCount, 17, "tree rows are open"); + is(treeView.isContainerOpen(0), false, "first closed row"); + is(treeView.isContainerOpen(1), true, "first open row"); + is(treeView.isContainerOpen(7), true, "second open row"); + + window.close(); + window.opener.testDone(); + } +} + +function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); } + +]]></script> + +</window> |