toolkit/content/tests/chrome/test_button.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/tests/chrome/test_button.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     1.7 +<!--
     1.8 +  XUL Widget Test for button
     1.9 +  -->
    1.10 +<window title="Button Test"
    1.11 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.12 +  <script type="application/javascript"
    1.13 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
    1.14 +  <script type="application/javascript"
    1.15 +          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>      
    1.16 +
    1.17 +<button id="one" label="One" />
    1.18 +<button id="two" label="Two"/>
    1.19 +<hbox>
    1.20 +  <button id="three" label="Three" open="true"/>
    1.21 +</hbox>
    1.22 +<hbox>
    1.23 +  <button id="four" type="menu" label="Four"/>
    1.24 +  <button id="five" type="panel" label="Five"/>
    1.25 +  <button id="six" label="Six"/>
    1.26 +</hbox>
    1.27 +
    1.28 +  <!-- test results are displayed in the html:body -->
    1.29 +  <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
    1.30 +
    1.31 +<script type="application/javascript">
    1.32 +<![CDATA[
    1.33 +
    1.34 +SimpleTest.waitForExplicitFinish();
    1.35 +
    1.36 +function test_button()
    1.37 +{
    1.38 +  synthesizeMouseExpectEvent($("one"), 2, 2, {}, $("one"), "command", "button press");
    1.39 +  $("one").focus();
    1.40 +  synthesizeKeyExpectEvent("VK_SPACE", { }, $("one"), "command", "key press");
    1.41 +  $("two").disabled = true;
    1.42 +  synthesizeMouseExpectEvent($("two"), 2, 2, {}, $("two"), "!command", "button press command when disabled");
    1.43 +  synthesizeMouseExpectEvent($("two"), 2, 2, {}, $("two"), "click", "button press click when disabled");
    1.44 +
    1.45 +  if (navigator.platform.indexOf("Mac") == -1) {
    1.46 +    $("one").focus();
    1.47 +    synthesizeKey("VK_DOWN", { });
    1.48 +    is(document.activeElement, $("three"), "key cursor down on button");
    1.49 +
    1.50 +    synthesizeKey("VK_RIGHT", { });
    1.51 +    is(document.activeElement, $("four"), "key cursor right on button");
    1.52 +    synthesizeKey("VK_DOWN", { });
    1.53 +    is(document.activeElement, $("four"), "key cursor down on menu button");
    1.54 +    $("five").focus();
    1.55 +    synthesizeKey("VK_DOWN", { });
    1.56 +    is(document.activeElement, $("five"), "key cursor down on panel button");
    1.57 +
    1.58 +    $("three").focus();
    1.59 +    synthesizeKey("VK_UP", { });
    1.60 +    is(document.activeElement, $("one"), "key cursor up on button");
    1.61 +  }
    1.62 +
    1.63 +  $("two").focus();
    1.64 +  ok(document.activeElement != $("two"), "focus disabled button");
    1.65 +
    1.66 +  SimpleTest.finish();
    1.67 +}
    1.68 +
    1.69 +SimpleTest.waitForFocus(test_button);
    1.70 +
    1.71 +]]>
    1.72 +</script>
    1.73 +
    1.74 +</window>

mercurial