toolkit/content/tests/chrome/test_button.xul

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

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

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

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
michael@0 4 <!--
michael@0 5 XUL Widget Test for button
michael@0 6 -->
michael@0 7 <window title="Button Test"
michael@0 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 9 <script type="application/javascript"
michael@0 10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 11 <script type="application/javascript"
michael@0 12 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 13
michael@0 14 <button id="one" label="One" />
michael@0 15 <button id="two" label="Two"/>
michael@0 16 <hbox>
michael@0 17 <button id="three" label="Three" open="true"/>
michael@0 18 </hbox>
michael@0 19 <hbox>
michael@0 20 <button id="four" type="menu" label="Four"/>
michael@0 21 <button id="five" type="panel" label="Five"/>
michael@0 22 <button id="six" label="Six"/>
michael@0 23 </hbox>
michael@0 24
michael@0 25 <!-- test results are displayed in the html:body -->
michael@0 26 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
michael@0 27
michael@0 28 <script type="application/javascript">
michael@0 29 <![CDATA[
michael@0 30
michael@0 31 SimpleTest.waitForExplicitFinish();
michael@0 32
michael@0 33 function test_button()
michael@0 34 {
michael@0 35 synthesizeMouseExpectEvent($("one"), 2, 2, {}, $("one"), "command", "button press");
michael@0 36 $("one").focus();
michael@0 37 synthesizeKeyExpectEvent("VK_SPACE", { }, $("one"), "command", "key press");
michael@0 38 $("two").disabled = true;
michael@0 39 synthesizeMouseExpectEvent($("two"), 2, 2, {}, $("two"), "!command", "button press command when disabled");
michael@0 40 synthesizeMouseExpectEvent($("two"), 2, 2, {}, $("two"), "click", "button press click when disabled");
michael@0 41
michael@0 42 if (navigator.platform.indexOf("Mac") == -1) {
michael@0 43 $("one").focus();
michael@0 44 synthesizeKey("VK_DOWN", { });
michael@0 45 is(document.activeElement, $("three"), "key cursor down on button");
michael@0 46
michael@0 47 synthesizeKey("VK_RIGHT", { });
michael@0 48 is(document.activeElement, $("four"), "key cursor right on button");
michael@0 49 synthesizeKey("VK_DOWN", { });
michael@0 50 is(document.activeElement, $("four"), "key cursor down on menu button");
michael@0 51 $("five").focus();
michael@0 52 synthesizeKey("VK_DOWN", { });
michael@0 53 is(document.activeElement, $("five"), "key cursor down on panel button");
michael@0 54
michael@0 55 $("three").focus();
michael@0 56 synthesizeKey("VK_UP", { });
michael@0 57 is(document.activeElement, $("one"), "key cursor up on button");
michael@0 58 }
michael@0 59
michael@0 60 $("two").focus();
michael@0 61 ok(document.activeElement != $("two"), "focus disabled button");
michael@0 62
michael@0 63 SimpleTest.finish();
michael@0 64 }
michael@0 65
michael@0 66 SimpleTest.waitForFocus(test_button);
michael@0 67
michael@0 68 ]]>
michael@0 69 </script>
michael@0 70
michael@0 71 </window>

mercurial