tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_listbox.xhtml (4776B)


      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"
      4                 type="text/css"?>
      5 
      6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
      7        title="Accessible XUL listbox hierarchy tests">
      8 
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
     10 
     11  <script type="application/javascript"
     12          src="../common.js" />
     13  <script type="application/javascript"
     14          src="../role.js" />
     15  <script type="application/javascript"
     16          src="../events.js" />
     17 
     18  <script type="application/javascript">
     19  <![CDATA[
     20    ////////////////////////////////////////////////////////////////////////////
     21    // Test
     22 
     23    function insertListitem(aListboxID)
     24    {
     25      this.listboxNode = getNode(aListboxID);
     26 
     27      this.listitemNode = document.createXULElement("richlistitem");
     28      var label = document.createXULElement("label");
     29      label.setAttribute("value", "item1");
     30      this.listitemNode.appendChild(label);
     31 
     32      this.eventSeq = [
     33        new invokerChecker(EVENT_SHOW, this.listitemNode),
     34        new invokerChecker(EVENT_REORDER, this.listboxNode)
     35      ];
     36 
     37      this.invoke = function insertListitem_invoke()
     38      {
     39        this.listboxNode.insertBefore(this.listitemNode,
     40                                      this.listboxNode.firstChild);
     41      }
     42 
     43      this.finalCheck = function insertListitem_finalCheck()
     44      {
     45        var tree =
     46          { LISTBOX: [
     47            {
     48              role: ROLE_RICH_OPTION,
     49              name: "item1"
     50            },
     51            {
     52              role: ROLE_RICH_OPTION,
     53              name: "item2"
     54            },
     55            {
     56              role: ROLE_RICH_OPTION,
     57              name: "item3"
     58            },
     59            {
     60              role: ROLE_RICH_OPTION,
     61              name: "item4"
     62            }
     63          ] };
     64        testAccessibleTree(this.listboxNode, tree);
     65      }
     66 
     67      this.getID = function insertListitem_getID()
     68      {
     69        return "insert listitem ";
     70      }
     71    }
     72 
     73    function removeListitem(aListboxID)
     74    {
     75      this.listboxNode = getNode(aListboxID);
     76      this.listitemNode = null;
     77      this.listitem;
     78 
     79      function getListitem(aThisObj)
     80      {
     81        return aThisObj.listitem;
     82      }
     83 
     84      this.eventSeq = [
     85        new invokerChecker(EVENT_HIDE, getListitem, this),
     86        new invokerChecker(EVENT_REORDER, this.listboxNode)
     87      ];
     88 
     89      this.invoke = function removeListitem_invoke()
     90      {
     91        this.listitemNode = this.listboxNode.firstChild;
     92        this.listitem = getAccessible(this.listitemNode);
     93 
     94        this.listboxNode.removeChild(this.listitemNode);
     95      }
     96 
     97      this.finalCheck = function removeListitem_finalCheck()
     98      {
     99        var tree =
    100          { LISTBOX: [
    101            {
    102              role: ROLE_RICH_OPTION,
    103              name: "item2"
    104            },
    105            {
    106              role: ROLE_RICH_OPTION,
    107              name: "item3"
    108            },
    109            {
    110              role: ROLE_RICH_OPTION,
    111              name: "item4"
    112            }
    113          ] };
    114        testAccessibleTree(this.listboxNode, tree);
    115      }
    116 
    117      this.getID = function removeListitem_getID()
    118      {
    119        return "remove listitem ";
    120      }
    121    }
    122 
    123    //gA11yEventDumpToConsole = true; // debug stuff
    124 
    125    var gQueue = null;
    126    function doTest()
    127    {
    128      var tree =
    129        { LISTBOX: [
    130          {
    131            role: ROLE_RICH_OPTION,
    132            name: "item2"
    133          },
    134          {
    135            role: ROLE_RICH_OPTION,
    136            name: "item3"
    137          },
    138          {
    139            role: ROLE_RICH_OPTION,
    140            name: "item4"
    141          }
    142        ] };
    143      testAccessibleTree("listbox", tree);
    144 
    145      gQueue = new eventQueue();
    146      gQueue.push(new insertListitem("listbox"));
    147      gQueue.push(new removeListitem("listbox"));
    148      gQueue.invoke(); // Will call SimpleTest.finish()
    149    }
    150 
    151    SimpleTest.waitForExplicitFinish();
    152    addA11yLoadEvent(doTest);
    153  ]]>
    154  </script>
    155 
    156  <hbox flex="1" style="overflow: auto;">
    157    <body xmlns="http://www.w3.org/1999/xhtml">
    158      <a target="_blank"
    159         href="https://bugzilla.mozilla.org/show_bug.cgi?id=656225"
    160         title="XUL listbox accessible tree doesn't get updated">
    161        Mozilla Bug 656225
    162      </a>
    163      <br/>
    164      <p id="display"></p>
    165      <div id="content" style="display: none">
    166      </div>
    167      <pre id="test">
    168      </pre>
    169    </body>
    170 
    171    <vbox flex="1">
    172      <richlistbox id="listbox">
    173        <richlistitem><label value="item2"/></richlistitem>
    174        <richlistitem><label value="item3"/></richlistitem>
    175        <richlistitem><label value="item4"/></richlistitem>
    176      </richlistbox>
    177    </vbox>
    178  </hbox>
    179 
    180 </window>