tor-browser

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

test_treegrid.xhtml (5375B)


      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 <?xml-stylesheet href="../treeview.css"
      6                 type="text/css"?>
      7 
      8 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
      9        title="Accessible XUL tree actions tests">
     10 
     11  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
     12 
     13  <script type="application/javascript"
     14          src="../treeview.js" />
     15 
     16  <script type="application/javascript"
     17          src="../common.js" />
     18  <script type="application/javascript"
     19          src="../role.js" />
     20  <script type="application/javascript"
     21          src="../states.js" />
     22  <script type="application/javascript"
     23          src="../events.js" />
     24  <script type="application/javascript"
     25          src="../actions.js" />
     26 
     27  <script type="application/javascript">
     28  <![CDATA[
     29    ////////////////////////////////////////////////////////////////////////////
     30    // Accessible tree testers
     31 
     32    function focusChecker(aAcc, aStates)
     33    {
     34      this.type = EVENT_FOCUS;
     35      this.target = aAcc;
     36      this.getID = function focusChecker_getID()
     37      {
     38        return "focus handling";
     39      }
     40      this.check = function focusChecker_check()
     41      {
     42        var states = aStates ? aStates : 0;
     43        testStates(this.target, STATE_FOCUSED | STATE_SELECTED | states);
     44      }
     45    }
     46 
     47    function stateChangeChecker(aAcc, aIsEnabled)
     48    {
     49      this.type = EVENT_STATE_CHANGE;
     50      this.target = aAcc;
     51      this.getID = function stateChangeChecker_getID()
     52      {
     53        return "state change handling";
     54      }
     55      this.check = function stateChangeChecker_check()
     56      {
     57        if (aIsEnabled)
     58          testStates(this.target, STATE_CHECKED);
     59        else
     60          testStates(this.target, STATE_CHECKABLE, 0, STATE_CHECKED);
     61      }
     62    }
     63 
     64    ////////////////////////////////////////////////////////////////////////////
     65    // Test
     66 
     67    function doTestActions()
     68    {
     69      var treeNode = getNode("tabletree");
     70 
     71      var treeBodyNode = treeNode.treeBody;
     72      treeNode.focus();
     73 
     74      var tree = getAccessible(treeNode);
     75 
     76      var expandedTreeItem = tree.getChildAt(2);
     77      var collapsedTreeItem = tree.getChildAt(5);
     78      var cycleCell = expandedTreeItem.getChildAt(0);
     79      var checkableCell = expandedTreeItem.getChildAt(3);
     80 
     81      var actions = [
     82        {
     83          ID: expandedTreeItem,
     84          actionName: "activate",
     85          actionIndex: 0,
     86          events: CLICK_EVENTS,
     87          targetID: treeBodyNode,
     88          eventSeq: [
     89            new focusChecker(expandedTreeItem, STATE_EXPANDED)
     90          ]
     91        },
     92        {
     93          ID: collapsedTreeItem,
     94          actionName: "expand",
     95          actionIndex: 1,
     96          events: CLICK_EVENTS,
     97          targetID: treeBodyNode,
     98          check: function check()
     99          {
    100            testStates(this.ID, STATE_EXPANDED);
    101          }
    102        },
    103        {
    104          ID: collapsedTreeItem,
    105          actionName: "collapse",
    106          actionIndex: 1,
    107          events: CLICK_EVENTS,
    108          targetID: treeBodyNode,
    109          check: function check()
    110          {
    111            testStates(this.ID, STATE_COLLAPSED);
    112          }
    113        },
    114        {
    115          ID: cycleCell,
    116          actionName: "cycle",
    117          actionIndex: 0,
    118          events: CLICK_EVENTS,
    119          targetID: treeBodyNode
    120        },
    121        {
    122          ID: checkableCell,
    123          actionName: "uncheck",
    124          actionIndex: 0,
    125          events: CLICK_EVENTS,
    126          targetID: treeBodyNode,
    127          eventSeq: [
    128            new stateChangeChecker(checkableCell, false)
    129          ]
    130        },
    131        {
    132          ID: checkableCell,
    133          actionName: "check",
    134          actionIndex: 0,
    135          events: CLICK_EVENTS,
    136          targetID: treeBodyNode,
    137          eventSeq: [
    138            new stateChangeChecker(checkableCell, true)
    139          ]
    140        }
    141      ];
    142 
    143      testActions(actions); // Will call SimpleTest.finish();
    144    }
    145 
    146    // gA11yEventDumpID = "debug";
    147 
    148    function doTest()
    149    {
    150      var treeNode = getNode("tabletree");
    151      waitForEvent(EVENT_REORDER, treeNode, doTestActions);
    152      treeNode.view = new nsTreeTreeView();
    153    }
    154 
    155    SimpleTest.waitForExplicitFinish();
    156    addA11yLoadEvent(doTest);
    157  ]]>
    158  </script>
    159 
    160  <hbox flex="1" style="overflow: auto;">
    161    <body xmlns="http://www.w3.org/1999/xhtml">
    162      <a target="_blank" rel="opener"
    163         href="https://bugzilla.mozilla.org/show_bug.cgi?id=503727"
    164         title="Reorganize implementation of XUL tree accessibility">
    165        Mozilla Bug 503727
    166      </a><br/>
    167      <p id="display"></p>
    168      <div id="content" style="display: none">
    169      </div>
    170      <pre id="test">
    171      </pre>
    172    </body>
    173 
    174    <vbox flex="1">
    175      <tree id="tabletree" flex="1" editable="true">
    176        <treecols>
    177          <treecol id="tabletree_col1" cycler="true" label="cycler"/>
    178          <treecol id="tabletree_col2" flex="1" primary="true" label="column1"/>
    179          <treecol id="tabletree_col3" flex="1" label="column2"/>
    180          <treecol id="tabletree_col4" flex="1" label="checker"
    181                   type="checkbox" editable="true"/>
    182        </treecols>
    183        <treechildren/>
    184      </tree>
    185 
    186      <vbox id="debug"/>
    187    </vbox>
    188  </hbox>
    189 
    190 </window>