accessible/tests/mochitest/states/test_tree.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/states/test_tree.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,153 @@
     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 +<?xml-stylesheet href="../treeview.css"
     1.9 +                 type="text/css"?>
    1.10 +
    1.11 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.12 +        title="Accessible XUL tree states tests">
    1.13 +
    1.14 +  <script type="application/javascript"
    1.15 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    1.16 +
    1.17 +  <script type="application/javascript"
    1.18 +          src="../treeview.js" />
    1.19 +
    1.20 +  <script type="application/javascript"
    1.21 +          src="../common.js" />
    1.22 +  <script type="application/javascript"
    1.23 +          src="../role.js" />
    1.24 +  <script type="application/javascript"
    1.25 +          src="../states.js" />
    1.26 +  <script type="application/javascript"
    1.27 +          src="../events.js" />
    1.28 +
    1.29 +  <script type="application/javascript">
    1.30 +  <![CDATA[
    1.31 +    ////////////////////////////////////////////////////////////////////////////
    1.32 +    // Test
    1.33 +
    1.34 +    /**
    1.35 +     * Event queue invoker object to test accessible states for XUL tree
    1.36 +     * accessible.
    1.37 +     */
    1.38 +    function statesChecker(aTreeID, aView)
    1.39 +    {
    1.40 +      this.DOMNode = getNode(aTreeID);
    1.41 +
    1.42 +      this.invoke = function statesChecker_invoke()
    1.43 +      {
    1.44 +        this.DOMNode.treeBoxObject.view = aView;
    1.45 +      }
    1.46 +
    1.47 +      this.check = function statesChecker_check()
    1.48 +      {
    1.49 +        var tree = getAccessible(this.DOMNode);
    1.50 +
    1.51 +        // tree states
    1.52 +        testStates(tree, STATE_READONLY);
    1.53 +
    1.54 +        if (this.DOMNode.getAttribute("seltype") != "single")
    1.55 +          testStates(tree, STATE_MULTISELECTABLE);
    1.56 +        else
    1.57 +          testStates(tree, 0, 0, STATE_MULTISELECTABLE);
    1.58 +
    1.59 +        // tree item states
    1.60 +        var expandedItem = tree.getChildAt(2);
    1.61 +        testStates(expandedItem,
    1.62 +                   STATE_SELECTABLE | STATE_FOCUSABLE | STATE_EXPANDED);
    1.63 +
    1.64 +        var collapsedItem = tree.getChildAt(5);
    1.65 +        testStates(collapsedItem,
    1.66 +                   STATE_SELECTABLE | STATE_FOCUSABLE | STATE_COLLAPSED);
    1.67 +
    1.68 +        // cells states if any
    1.69 +        var cells = collapsedItem.children;
    1.70 +        if (cells && cells.length) {
    1.71 +          for (var idx = 0; idx < cells.length; idx++) {
    1.72 +            var cell = cells.queryElementAt(idx, nsIAccessible);
    1.73 +            testStates(cell, STATE_SELECTABLE);
    1.74 +          }
    1.75 +
    1.76 +          var checkboxCell = cells.queryElementAt(3, nsIAccessible);
    1.77 +          testStates(checkboxCell, STATE_CHECKABLE | STATE_CHECKED);
    1.78 +        }
    1.79 +      }
    1.80 +
    1.81 +      this.getID = function statesChecker_getID()
    1.82 +      {
    1.83 +        return "tree processor for " + prettyName(aTreeID);
    1.84 +      }
    1.85 +    }
    1.86 +
    1.87 +    gA11yEventDumpToConsole = true; // debug stuff
    1.88 +
    1.89 +    var gQueue = null;
    1.90 +
    1.91 +    function doTest()
    1.92 +    {
    1.93 +      gQueue = new eventQueue(EVENT_REORDER);
    1.94 +      gQueue.push(new statesChecker("tree", new nsTreeTreeView()));
    1.95 +      gQueue.push(new statesChecker("treesingle", new nsTreeTreeView()));
    1.96 +      gQueue.push(new statesChecker("tabletree", new nsTreeTreeView()));
    1.97 +
    1.98 +      gQueue.invoke(); // Will call SimpleTest.finish();
    1.99 +    }
   1.100 +
   1.101 +    if (MAC && (navigator.userAgent.indexOf("Mac OS X 10.6") != -1)) {
   1.102 +      todo(false,
   1.103 +           "Re-enable on Mac OS 10.6 after fixing bug 845095 - intermittent orange");
   1.104 +    } else {
   1.105 +    SimpleTest.waitForExplicitFinish();
   1.106 +    addA11yLoadEvent(doTest);
   1.107 +    }
   1.108 +  ]]>
   1.109 +  </script>
   1.110 +
   1.111 +  <hbox flex="1" style="overflow: auto;">
   1.112 +    <body xmlns="http://www.w3.org/1999/xhtml">
   1.113 +      <a target="_blank"
   1.114 +         href="https://bugzilla.mozilla.org/show_bug.cgi?id=503727"
   1.115 +         title="Reorganize implementation of XUL tree accessibility">
   1.116 +        Mozilla Bug 503727
   1.117 +      </a><br/>
   1.118 +      <p id="display"></p>
   1.119 +      <div id="content" style="display: none">
   1.120 +      </div>
   1.121 +      <pre id="test">
   1.122 +      </pre>
   1.123 +    </body>
   1.124 +
   1.125 +    <vbox flex="1">
   1.126 +      <tree id="tree" flex="1">
   1.127 +        <treecols>
   1.128 +          <treecol id="col" flex="1" primary="true" label="column"/>
   1.129 +        </treecols>
   1.130 +        <treechildren/>
   1.131 +      </tree>
   1.132 +
   1.133 +      <tree id="treesingle" flex="1" seltype="single">
   1.134 +        <treecols>
   1.135 +          <treecol id="col_single" flex="1" primary="true" label="column"/>
   1.136 +        </treecols>
   1.137 +        <treechildren/>
   1.138 +      </tree>
   1.139 +
   1.140 +      <tree id="tabletree" flex="1" editable="true">
   1.141 +        <treecols>
   1.142 +          <treecol id="tabletree_col1" cycler="true" label="cycler"/>
   1.143 +          <treecol id="tabletree_col2" flex="1" primary="true" label="column1"/>
   1.144 +          <treecol id="tabletree_col3" flex="1" label="column2"/>
   1.145 +          <treecol id="tabletree_col4" flex="1" label="checker"
   1.146 +                   type="checkbox" editable="true"/>
   1.147 +        </treecols>
   1.148 +        <treechildren/>
   1.149 +      </tree>
   1.150 +
   1.151 +      <vbox id="debug"/>
   1.152 +    </vbox>
   1.153 +  </hbox>
   1.154 +
   1.155 +</window>
   1.156 +

mercurial