toolkit/content/tests/chrome/test_button.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial