diff options
Diffstat (limited to 'toolkit/components/xulstore/tests/chrome')
3 files changed, 101 insertions, 0 deletions
diff --git a/toolkit/components/xulstore/tests/chrome/chrome.toml b/toolkit/components/xulstore/tests/chrome/chrome.toml new file mode 100644 index 0000000000..9675799781 --- /dev/null +++ b/toolkit/components/xulstore/tests/chrome/chrome.toml @@ -0,0 +1,4 @@ +[DEFAULT] +support-files = ["window_persistence.xhtml"] + +["test_persistence.xhtml"] diff --git a/toolkit/components/xulstore/tests/chrome/test_persistence.xhtml b/toolkit/components/xulstore/tests/chrome/test_persistence.xhtml new file mode 100644 index 0000000000..b3e65fb050 --- /dev/null +++ b/toolkit/components/xulstore/tests/chrome/test_persistence.xhtml @@ -0,0 +1,30 @@ +<?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 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> + + <script> + SimpleTest.waitForExplicitFinish(); + function runTest() { + window.openDialog("window_persistence.xhtml", "_blank", "chrome,noopener", true, window); + } + + function windowOpened() { + window.openDialog("window_persistence.xhtml", "_blank", "chrome,noopener", false, window); + } + + 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.xhtml b/toolkit/components/xulstore/tests/chrome/window_persistence.xhtml new file mode 100644 index 0000000000..d474891cfc --- /dev/null +++ b/toolkit/components/xulstore/tests/chrome/window_persistence.xhtml @@ -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"?> + +<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"/> +<button id="button3" label="Button3" value="Normal" persist="hidden" hidden="true"/> + +<script> +<![CDATA[ + +const XULStore = Services.xulStore; +let URI = "chrome://mochitests/content/chrome/toolkit/components/xulstore/tests/chrome/window_persistence.xhtml"; + +function opened() +{ + runTest(); +} + +function runTest() +{ + var firstRun = window.arguments[0]; + var button1 = document.getElementById("button1"); + var button2 = document.getElementById("button2"); + var button3 = document.getElementById("button3"); + if (firstRun) { + button1.setAttribute("value", "Pressed"); + button2.removeAttribute("value"); + + button2.setAttribute("foo", "bar"); + XULStore.persist(button2, "foo"); + is(XULStore.getValue(URI, "button2", "foo"), "bar", "attribute persisted"); + button2.removeAttribute("foo"); + XULStore.persist(button2, "foo"); + is(XULStore.hasValue(URI, "button2", "foo"), false, "attribute removed"); + + button3.removeAttribute("hidden"); + + window.close(); + window.arguments[1].windowOpened(); + } + else { + is(button1.getAttribute("value"), "Pressed", + "Attribute set"); + is(button2.hasAttribute("value"), false, + "Attribute cleared"); + is(button2.hasAttribute("foo"), false, + "Attribute cleared"); + + is(button3.hasAttribute("hidden"), false, + "Attribute cleared"); + + window.close(); + window.arguments[1].testDone(); + } +} + +function is(l, r, n) { window.arguments[1].SimpleTest.is(l,r,n); } + +]]></script> + +</window> |