accessible/tests/mochitest/tree/test_txtctrl.xul
author Coroiu Cristina <ccoroiu@mozilla.com>
Mon, 13 May 2019 08:50:28 +0300
changeset 535455 fa3cfee27619ddc9bcbcf70555bda4eb1e815146
parent 535264 c5798de806e28251aeda7d23123ab2b05eb7e8fb
child 535566 5a993bd3862b7a5b40771c25d962ba9c30ce76de
permissions -rw-r--r--
Backed out changeset c5798de806e2 (bug 1521280) for crashing when searching about:config for upcoming beta (bug 1551013)

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                 type="text/css"?>

<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        title="Accessible XUL textbox and textarea hierarchy tests">

  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />

  <script type="application/javascript"
          src="../common.js" />
  <script type="application/javascript"
          src="../role.js" />
  <script type="application/javascript"
          src="../events.js" />

  <script type="application/javascript">
  <![CDATA[
    //gA11yEventDumpToConsole = true;
    //enableLogging("tree,verbose"); // debug stuff

    ////////////////////////////////////////////////////////////////////////////
    // Test

    function doTest()
    {
      //////////////////////////////////////////////////////////////////////////
      // textboxes

      var accTree =
        { SECTION: [
          { ENTRY: [ { TEXT_LEAF: [] } ] },
          { MENUPOPUP: [] }
        ] };

      // default textbox
      testAccessibleTree("txc", accTree);

      //////////////////////////////////////////////////////////////////////////
      // search textbox
      accTree =
        { SECTION: [
          { ENTRY: [ { TEXT_LEAF: [] } ] },
          { MENUPOPUP: [] }
        ] };
      testAccessibleTree("txc_search", accTree);

      //////////////////////////////////////////////////////////////////////////
      // search textbox with search button

      if (MAC) {
        accTree =
          { SECTION: [
            { ENTRY: [ { TEXT_LEAF: [] } ] },
            { MENUPOPUP: [] }
          ] };
      } else {
        accTree =
          { SECTION: [
            { ENTRY: [ { TEXT_LEAF: [] } ] },
            { PUSHBUTTON: [] },
            { MENUPOPUP: [] }
          ] };
      }

      testAccessibleTree("txc_search_searchbutton", accTree);

      //////////////////////////////////////////////////////////////////////////
      // number textbox

      accTree =
        { SECTION: [
          { SPINBUTTON: [
            { ENTRY: [ { TEXT_LEAF: [] } ] },
            { PUSHBUTTON: [ ] },
            { PUSHBUTTON: [ ] }
          ] },
          { MENUPOPUP: [] },
        ] };

      testAccessibleTree("txc_number", accTree);

      //////////////////////////////////////////////////////////////////////////
      // password textbox

      accTree =
        { SECTION: [
          { PASSWORD_TEXT: [ { TEXT_LEAF: [] } ] },
          { MENUPOPUP: [] }
        ] };

      testAccessibleTree("txc_password", accTree);

      //////////////////////////////////////////////////////////////////////////
      // autocomplete textbox

      accTree = {
        // textbox
        role: ROLE_AUTOCOMPLETE,
        children: [
          {
            // html:input
            role: ROLE_ENTRY,
            children: [
              {
                // #text
                role: ROLE_TEXT_LEAF,
                children: []
              }
            ]
          },
          {
            // xul:menupopup
            role: ROLE_COMBOBOX_LIST,
            children: []
          },
          {
            // xul:richlistbox
            role: ROLE_COMBOBOX_LIST,
            children: []
          }
        ]
      };

      var txc = document.getElementById("txc_autocomplete");
      SimpleTest.ok(txc, "Testing (New) Toolkit autocomplete widget.");

      // Dumb access to trigger popup lazy creation.
      dump("Trigget popup lazy creation");
      waitForEvent(EVENT_REORDER, txc, () => {
        testAccessibleTree("txc_autocomplete", accTree);
        SimpleTest.finish();
      });
      txc.popup.initialize();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  ]]>
  </script>

  <hbox flex="1" style="overflow: auto;">
    <body xmlns="http://www.w3.org/1999/xhtml">
      <a target="_blank"
         href="https://bugzilla.mozilla.org/show_bug.cgi?id=542824"
         title="Create child accessibles for text controls from native anonymous content">
        Mozilla Bug 542824
      </a><br/>
      <p id="display"></p>
      <div id="content" style="display: none">
      </div>
      <pre id="test">
      </pre>
    </body>

    <vbox flex="1">
      <textbox id="txc" value="hello"/>
      <textbox id="txc_search" type="search" value="hello"/>
      <textbox id="txc_search_searchbutton" searchbutton="true" type="search" value="hello"/>
      <textbox id="txc_number" type="number" value="44"/>
      <textbox id="txc_password" type="password" value="hello"/>
      <textbox id="txc_autocomplete" type="autocomplete" value="hello"/>
    </vbox>
  </hbox>

</window>