accessible/tests/mochitest/actions/test_treegrid.xul

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial