accessible/tests/mochitest/tree/test_txtctrl.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/tree/test_txtctrl.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,205 @@
     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"
     1.7 +                 type="text/css"?>
     1.8 +
     1.9 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.10 +        title="Accessible XUL textbox and textarea hierarchy tests">
    1.11 +
    1.12 +  <script type="application/javascript"
    1.13 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    1.14 +
    1.15 +  <script type="application/javascript"
    1.16 +          src="../common.js" />
    1.17 +  <script type="application/javascript"
    1.18 +          src="../role.js" />
    1.19 +  <script type="application/javascript"
    1.20 +          src="../events.js" />
    1.21 +
    1.22 +  <script type="application/javascript">
    1.23 +  <![CDATA[
    1.24 +    ////////////////////////////////////////////////////////////////////////////
    1.25 +    // Test
    1.26 +
    1.27 +    function doTest()
    1.28 +    {
    1.29 +      //////////////////////////////////////////////////////////////////////////
    1.30 +      // textboxes
    1.31 +
    1.32 +      var accTree =
    1.33 +        { SECTION: [
    1.34 +          { ENTRY: [ { TEXT_LEAF: [] } ] },
    1.35 +          { MENUPOPUP: [] }
    1.36 +        ] };
    1.37 +
    1.38 +      // default textbox
    1.39 +      testAccessibleTree("txc", accTree);
    1.40 +
    1.41 +      // multiline
    1.42 +      testAccessibleTree("txc_multiline", accTree);
    1.43 +
    1.44 +      //////////////////////////////////////////////////////////////////////////
    1.45 +      // search textbox
    1.46 +
    1.47 +      if (MAC) {
    1.48 +        accTree =
    1.49 +          { SECTION: [
    1.50 +            { ENTRY: [ { TEXT_LEAF: [] } ] },
    1.51 +            { MENUPOPUP: [] }
    1.52 +          ] };
    1.53 +      } else {
    1.54 +        accTree =
    1.55 +          { SECTION: [
    1.56 +            { ENTRY: [ { TEXT_LEAF: [] } ] },
    1.57 +            { PUSHBUTTON: [] },
    1.58 +            { MENUPOPUP: [] }
    1.59 +          ] };
    1.60 +      }
    1.61 +
    1.62 +      testAccessibleTree("txc_search", accTree);
    1.63 +
    1.64 +      //////////////////////////////////////////////////////////////////////////
    1.65 +      // number textbox
    1.66 +
    1.67 +      accTree =
    1.68 +        { SECTION: [
    1.69 +          { ENTRY: [ { TEXT_LEAF: [] } ] },
    1.70 +          { MENUPOPUP: [] },
    1.71 +          { PUSHBUTTON: [] },
    1.72 +          { PUSHBUTTON: [] }
    1.73 +        ] };
    1.74 +
    1.75 +      testAccessibleTree("txc_number", accTree);
    1.76 +
    1.77 +      //////////////////////////////////////////////////////////////////////////
    1.78 +      // password textbox
    1.79 +
    1.80 +      accTree =
    1.81 +        { SECTION: [
    1.82 +          { PASSWORD_TEXT: [ { TEXT_LEAF: [] } ] },
    1.83 +          { MENUPOPUP: [] }
    1.84 +        ] };
    1.85 +
    1.86 +      testAccessibleTree("txc_password", accTree);
    1.87 +
    1.88 +      //////////////////////////////////////////////////////////////////////////
    1.89 +      // autocomplete textbox
    1.90 +
    1.91 +      accTree = {
    1.92 +        // textbox
    1.93 +        role: ROLE_AUTOCOMPLETE,
    1.94 +        children: [
    1.95 +          {
    1.96 +            // html:input
    1.97 +            role: ROLE_ENTRY,
    1.98 +            children: [
    1.99 +              {
   1.100 +                // #text
   1.101 +                role: ROLE_TEXT_LEAF,
   1.102 +                children: []
   1.103 +              }
   1.104 +            ]
   1.105 +          },
   1.106 +          {
   1.107 +            // xul:menupopup
   1.108 +            role: ROLE_COMBOBOX_LIST,
   1.109 +            children: []
   1.110 +          }
   1.111 +        ]
   1.112 +      };
   1.113 +
   1.114 +      function test_AutocompleteControl() {
   1.115 +        testAccessibleTree("txc_autocomplete", accTree);
   1.116 +        SimpleTest.finish();
   1.117 +      }
   1.118 +
   1.119 +      // XPFE and Toolkit autocomplete widgets differ.
   1.120 +      var txc = document.getElementById("txc_autocomplete");
   1.121 +      if ("clearResults" in txc) {
   1.122 +        SimpleTest.ok(true, "Testing (Old) XPFE autocomplete widget.");
   1.123 +
   1.124 +        // Popup is always created. (See code below.)
   1.125 +
   1.126 +        accTree.children.push(
   1.127 +          {
   1.128 +            // xul:panel
   1.129 +            role: ROLE_COMBOBOX_LIST,
   1.130 +            children: [
   1.131 +              {
   1.132 +                // xul:tree
   1.133 +                role: ROLE_TABLE,
   1.134 +                children: [
   1.135 +                  {
   1.136 +                    // xul:treecols
   1.137 +                    role: ROLE_LIST,
   1.138 +                    children: [
   1.139 +                      {
   1.140 +                        // xul:treecol
   1.141 +                        role: ROLE_COLUMNHEADER,
   1.142 +                        children: []
   1.143 +                      }
   1.144 +                    ]
   1.145 +                  }
   1.146 +                ]
   1.147 +              }
   1.148 +            ]
   1.149 +          }
   1.150 +        );
   1.151 +        test_AutocompleteControl();
   1.152 +
   1.153 +      } else {
   1.154 +        SimpleTest.ok(true, "Testing (New) Toolkit autocomplete widget.");
   1.155 +
   1.156 +        // Dumb access to trigger popup lazy creation.
   1.157 +        waitForEvent(EVENT_REORDER, txc, test_AutocompleteControl);
   1.158 +        txc.popup;
   1.159 +
   1.160 +        accTree.children.push(
   1.161 +          {
   1.162 +            role: ROLE_LIST,
   1.163 +            children: [
   1.164 +              {
   1.165 +                role: ROLE_LIST,
   1.166 +                children: [
   1.167 +                  {
   1.168 +                    role: ROLE_COLUMNHEADER,
   1.169 +                    children: []
   1.170 +                  }
   1.171 +                ]
   1.172 +              }
   1.173 +            ]
   1.174 +          }
   1.175 +        );
   1.176 +      }
   1.177 +    }
   1.178 +
   1.179 +    SimpleTest.waitForExplicitFinish();
   1.180 +    addA11yLoadEvent(doTest);
   1.181 +  ]]>
   1.182 +  </script>
   1.183 +
   1.184 +  <hbox flex="1" style="overflow: auto;">
   1.185 +    <body xmlns="http://www.w3.org/1999/xhtml">
   1.186 +      <a target="_blank"
   1.187 +         href="https://bugzilla.mozilla.org/show_bug.cgi?id=542824"
   1.188 +         title="Create child accessibles for text controls from native anonymous content">
   1.189 +        Mozilla Bug 542824
   1.190 +      </a><br/>
   1.191 +      <p id="display"></p>
   1.192 +      <div id="content" style="display: none">
   1.193 +      </div>
   1.194 +      <pre id="test">
   1.195 +      </pre>
   1.196 +    </body>
   1.197 +
   1.198 +    <vbox flex="1">
   1.199 +      <textbox id="txc" value="hello"/>
   1.200 +      <textbox id="txc_search" type="search" value="hello"/>
   1.201 +      <textbox id="txc_number" type="number" value="44"/>
   1.202 +      <textbox id="txc_password" type="password" value="hello"/>
   1.203 +      <textbox id="txc_multiline" multiline="true" value="hello"/>
   1.204 +      <textbox id="txc_autocomplete" type="autocomplete" value="hello"/>
   1.205 +    </vbox>
   1.206 +  </hbox>
   1.207 +
   1.208 +</window>

mercurial