summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/chrome/test_menuitem_commands.xul
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 /toolkit/content/tests/chrome/test_menuitem_commands.xul
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 'toolkit/content/tests/chrome/test_menuitem_commands.xul')
-rw-r--r--toolkit/content/tests/chrome/test_menuitem_commands.xul104
1 files changed, 104 insertions, 0 deletions
diff --git a/toolkit/content/tests/chrome/test_menuitem_commands.xul b/toolkit/content/tests/chrome/test_menuitem_commands.xul
new file mode 100644
index 000000000..e31774ccc
--- /dev/null
+++ b/toolkit/content/tests/chrome/test_menuitem_commands.xul
@@ -0,0 +1,104 @@
+<?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="Menuitem Commands Test"
+ onload="runOrOpen()"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+<script>
+<![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+function checkAttributes(elem, label, accesskey, disabled, hidden, isAfter)
+{
+ var is = window.opener.wrappedJSObject.SimpleTest.is;
+
+ is(elem.getAttribute("label"), label, elem.id + " label " + (isAfter ? "after" : "before") + " open");
+ is(elem.getAttribute("accesskey"), accesskey, elem.id + " accesskey " + (isAfter ? "after" : "before") + " open");
+ is(elem.getAttribute("disabled"), disabled, elem.id + " disabled " + (isAfter ? "after" : "before") + " open");
+ is(elem.getAttribute("hidden"), hidden, elem.id + " hidden " + (isAfter ? "after" : "before") + " open");
+}
+
+function runOrOpen()
+{
+ if (window.opener) {
+ SimpleTest.waitForFocus(runTest);
+ }
+ else {
+ window.open("test_menuitem_commands.xul", "", "chrome");
+ }
+}
+
+function runTest()
+{
+ runTestSet("");
+ runTestSet("bar");
+ window.close();
+ window.opener.wrappedJSObject.SimpleTest.finish();
+}
+
+function runTestSet(suffix)
+{
+ var isMac = (navigator.platform.indexOf("Mac") >= 0);
+
+ var one = $("one" + suffix);
+ var two = $("two" + suffix);
+ var three = $("three" + suffix);
+ var four = $("four" + suffix);
+
+ checkAttributes(one, "One", "", "", "true", false);
+ checkAttributes(two, "", "", "false", "", false);
+ checkAttributes(three, "Three", "T", "true", "", false);
+ checkAttributes(four, "Four", "F", "", "", false);
+
+ if (isMac && suffix) {
+ var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
+ getInterface(Components.interfaces.nsIDOMWindowUtils);
+ utils.forceUpdateNativeMenuAt("0");
+ }
+ else {
+ $("menu" + suffix).open = true;
+ }
+
+ checkAttributes(one, "One", "", "", "false", true);
+ checkAttributes(two, "Cat", "C", "", "", true);
+ checkAttributes(three, "Dog", "D", "false", "true", true);
+ checkAttributes(four, "Four", "F", "true", "", true);
+
+ $("menu" + suffix).open = false;
+}
+]]>
+</script>
+
+<command id="cmd_one" hidden="false"/>
+<command id="cmd_two" label="Cat" accesskey="C"/>
+<command id="cmd_three" label="Dog" accesskey="D" disabled="false" hidden="true"/>
+<command id="cmd_four" disabled="true"/>
+
+<button id="menu" type="menu">
+ <menupopup>
+ <menuitem id="one" label="One" hidden="true" command="cmd_one"/>
+ <menuitem id="two" disabled="false" command="cmd_two"/>
+ <menuitem id="three" label="Three" accesskey="T" disabled="true" command="cmd_three"/>
+ <menuitem id="four" label="Four" accesskey="F" command="cmd_four"/>
+ </menupopup>
+</button>
+
+<menubar>
+ <menu id="menubar" label="Sample">
+ <menupopup>
+ <menuitem id="onebar" label="One" hidden="true" command="cmd_one"/>
+ <menuitem id="twobar" disabled="false" command="cmd_two"/>
+ <menuitem id="threebar" label="Three" accesskey="T" disabled="true" command="cmd_three"/>
+ <menuitem id="fourbar" label="Four" accesskey="F" command="cmd_four"/>
+ </menupopup>
+ </menu>
+</menubar>
+
+<body xmlns="http://www.w3.org/1999/xhtml"><p id="display"/></body>
+
+</window>