accessible/tests/mochitest/events/test_focus_tree.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/events/test_focus_tree.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,122 @@
     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="XUL tree focus testing">
    1.11 +
    1.12 +  <script type="application/javascript" 
    1.13 +          src="chrome://mochikit/content/MochiKit/packed.js" />
    1.14 +  <script type="application/javascript"
    1.15 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    1.16 +  <script type="application/javascript"
    1.17 +          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    1.18 +
    1.19 +  <script type="application/javascript"
    1.20 +          src="../treeview.js" />
    1.21 +
    1.22 +  <script type="application/javascript"
    1.23 +          src="../common.js" />
    1.24 +  <script type="application/javascript"
    1.25 +          src="../role.js" />
    1.26 +  <script type="application/javascript"
    1.27 +          src="../states.js" />
    1.28 +  <script type="application/javascript"
    1.29 +          src="../events.js" />
    1.30 +
    1.31 +  <script type="application/javascript">
    1.32 +  <![CDATA[
    1.33 +
    1.34 +    ////////////////////////////////////////////////////////////////////////////
    1.35 +    // Invokers
    1.36 +
    1.37 +    function focusTree(aTreeID)
    1.38 +    {
    1.39 +      var checker = new focusChecker(getFirstTreeItem, aTreeID);
    1.40 +      this.__proto__ = new synthFocus(aTreeID, [ checker ]);
    1.41 +    }
    1.42 +
    1.43 +    function moveToNextItem(aTreeID)
    1.44 +    {
    1.45 +      var checker = new focusChecker(getSecondTreeItem, aTreeID);
    1.46 +      this.__proto__ = new synthDownKey(aTreeID, [ checker ]);
    1.47 +    }
    1.48 +
    1.49 +    ////////////////////////////////////////////////////////////////////////////
    1.50 +    // Helpers
    1.51 +
    1.52 +    function getTreeItemAt(aTreeID, aIdx)
    1.53 +      { return getAccessible(aTreeID).getChildAt(aIdx + 1); }
    1.54 +
    1.55 +    function getFirstTreeItem(aTreeID)
    1.56 +      { return getTreeItemAt(aTreeID, 0); }
    1.57 +
    1.58 +    function getSecondTreeItem(aTreeID)
    1.59 +      { return getTreeItemAt(aTreeID, 1); }
    1.60 +
    1.61 +    ////////////////////////////////////////////////////////////////////////////
    1.62 +    // Test
    1.63 +
    1.64 +    var gQueue = null;
    1.65 +
    1.66 +    //gA11yEventDumpID = "debug"; // debugging
    1.67 +    //gA11yEventDumpToConsole = true; // debugging
    1.68 +
    1.69 +    function doTest()
    1.70 +    {
    1.71 +      gQueue = new eventQueue();
    1.72 +
    1.73 +      gQueue.push(new focusTree("tree"));
    1.74 +      gQueue.push(new moveToNextItem("tree"));
    1.75 +      gQueue.push(new synthFocus("emptytree"));
    1.76 +
    1.77 +      // no focus event for changed current item for unfocused tree
    1.78 +      gQueue.push(new changeCurrentItem("tree", 0));
    1.79 +
    1.80 +      gQueue.invoke();
    1.81 +    }
    1.82 +
    1.83 +    SimpleTest.waitForExplicitFinish();
    1.84 +    addA11yXULTreeLoadEvent(doTest, "tree", new nsTableTreeView(5));
    1.85 +  ]]>
    1.86 +  </script>
    1.87 +
    1.88 +  <hbox flex="1" style="overflow: auto;">
    1.89 +    <body xmlns="http://www.w3.org/1999/xhtml">
    1.90 +      <a target="_blank"
    1.91 +         href="https://bugzilla.mozilla.org/show_bug.cgi?id=386821"
    1.92 +         title="Need better solution for firing delayed event against xul tree">
    1.93 +        Mozilla Bug 386821
    1.94 +      </a>
    1.95 +      <a target="_blank"
    1.96 +         href="https://bugzilla.mozilla.org/show_bug.cgi?id=406308"
    1.97 +         title="Don't fire accessible focus events if widget is not actually in focus, confuses screen readers">
    1.98 +        Mozilla Bug 406308
    1.99 +      </a>
   1.100 +      <p id="display"></p>
   1.101 +      <div id="content" style="display: none">
   1.102 +      </div>
   1.103 +      <pre id="test">
   1.104 +      </pre>
   1.105 +    </body>
   1.106 +
   1.107 +    <vbox id="debug"/>
   1.108 +    <tree id="tree" flex="1">
   1.109 +      <treecols>
   1.110 +        <treecol id="col1" flex="1" primary="true" label="column"/>
   1.111 +        <treecol id="col2" flex="1" label="column 2"/>
   1.112 +      </treecols>
   1.113 +      <treechildren id="treechildren"/>
   1.114 +    </tree>
   1.115 +    <tree id="emptytree" flex="1">
   1.116 +      <treecols>
   1.117 +        <treecol id="emptytree_col1" flex="1" primary="true" label="column"/>
   1.118 +        <treecol id="emptytree_col2" flex="1" label="column 2"/>
   1.119 +      </treecols>
   1.120 +      <treechildren id="emptytree_treechildren"/>
   1.121 +    </tree>
   1.122 +  </hbox>
   1.123 +
   1.124 +</window>
   1.125 +

mercurial