toolkit/content/tests/chrome/test_props.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/tests/chrome/test_props.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,91 @@
     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 basic properties - this test checks that the basic
     1.9 +  properties defined in general.xml and inherited by a number of elements
    1.10 +  work properly.
    1.11 +  -->
    1.12 +<window title="Basic Properties Test"
    1.13 +        onload="setTimeout(test_props, 0);"
    1.14 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.15 +  <script type="application/javascript"
    1.16 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
    1.17 +  <script type="application/javascript"
    1.18 +          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>      
    1.19 +
    1.20 +<command id="cmd_nothing"/>
    1.21 +<command id="cmd_action"/>
    1.22 +
    1.23 +<button id="button" label="Button" accesskey="B"
    1.24 +        crop="end" image="happy.png" command="cmd_nothing"/>
    1.25 +<checkbox id="checkbox" label="Checkbox" accesskey="B"
    1.26 +          crop="end" image="happy.png" command="cmd_nothing"/>
    1.27 +<radiogroup>
    1.28 +  <radio id="radio" label="Radio Button" value="rb1" accesskey="B"
    1.29 +         crop="end" image="happy.png" command="cmd_nothing"/>
    1.30 +</radiogroup>
    1.31 +
    1.32 +  <!-- test results are displayed in the html:body -->
    1.33 +  <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
    1.34 +
    1.35 +  <!-- test code goes here -->
    1.36 +  <script type="application/javascript"><![CDATA[
    1.37 +
    1.38 +SimpleTest.waitForExplicitFinish();
    1.39 +
    1.40 +function test_props()
    1.41 +{
    1.42 +  test_props_forelement($("button"), "Button", null);
    1.43 +  test_props_forelement($("checkbox"), "Checkbox", null);
    1.44 +  test_props_forelement($("radio"), "Radio Button", "rb1");
    1.45 +
    1.46 +  SimpleTest.finish();
    1.47 +}
    1.48 +
    1.49 +function test_props_forelement(element, label, value)
    1.50 +{
    1.51 +  // check the initial values
    1.52 +  is(element.label, label, "element label");
    1.53 +  if (value)
    1.54 +    is(element.value, value, "element value");
    1.55 +  is(element.accessKey, "B", "element accessKey");
    1.56 +  is(element.crop, "end", "element crop");
    1.57 +  is(element.image, "happy.png", "element image");
    1.58 +  is(element.command, "cmd_nothing", "element command");
    1.59 +  ok(element.tabIndex === 0, "element tabIndex");
    1.60 +
    1.61 +  synthesizeMouseExpectEvent(element, 4, 4, { }, $("cmd_nothing"), "command", "element");
    1.62 +
    1.63 +  // make sure that setters return the value
    1.64 +  is(element.label = "Label", "Label", "element label setter return");
    1.65 +  if (value)
    1.66 +    is(element.value = "lb", "lb", "element value setter return");
    1.67 +  is(element.accessKey = "L", "L", "element accessKey setter return");
    1.68 +  is(element.crop = "start", "start", "element crop setter return");
    1.69 +  is(element.image = "sad.png", "sad.png", "element image setter return");
    1.70 +  is(element.command = "cmd_action", "cmd_action", "element command setter return");
    1.71 +
    1.72 +  // check the value after it was changed
    1.73 +  is(element.label, "Label", "element label after set");
    1.74 +  if (value)
    1.75 +    is(element.value, "lb", "element value after set");
    1.76 +  is(element.accessKey, "L", "element accessKey after set");
    1.77 +  is(element.crop, "start", "element crop after set");
    1.78 +  is(element.image, "sad.png", "element image after set");
    1.79 +  is(element.command, "cmd_action", "element command after set");
    1.80 +
    1.81 +  synthesizeMouseExpectEvent(element, 4, 4, { }, $("cmd_action"), "command", "element");
    1.82 +
    1.83 +  // check that clicks on disabled items don't fire a command event
    1.84 +  ok((element.disabled = true) === true, "element disabled setter return");
    1.85 +  ok(element.disabled === true, "element disabled after set");
    1.86 +  synthesizeMouseExpectEvent(element, 4, 4, { }, $("cmd_action"), "!command", "element");
    1.87 +
    1.88 +  element.disabled = false;
    1.89 +}
    1.90 +
    1.91 +]]>
    1.92 +</script>
    1.93 +
    1.94 +</window>

mercurial