accessible/tests/mochitest/selectable/test_listbox.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" type="text/css"?>
     7 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     8         title="XUL tree selectable tests">
    10   <script type="application/javascript"
    11           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    13   <script type="application/javascript"
    14           src="../common.js" />
    15   <script type="application/javascript"
    16           src="../role.js" />
    17   <script type="application/javascript"
    18           src="../states.js" />
    19   <script type="application/javascript"
    20           src="../selectable.js" />
    22   <script type="application/javascript">
    23   <![CDATA[
    25     ////////////////////////////////////////////////////////////////////////////
    26     // Test
    28     //gA11yEventDumpID = "debug";
    30     var gQueue = null;
    32     function doTest()
    33     {
    34       //////////////////////////////////////////////////////////////////////////
    35       // single selectable listbox
    37       var id = "listbox";
    38       ok(isAccessible(id, [nsIAccessibleSelectable]),
    39          "No selectable accessible for list of " + id);
    41       var select = getAccessible(id, [nsIAccessibleSelectable]);
    42       testSelectableSelection(select, [ ]);
    44       select.addItemToSelection(1);
    45       testSelectableSelection(select, [ "lb1_item2" ], "addItemToSelect(1): ");
    47       select.removeItemFromSelection(1);
    48       testSelectableSelection(select, [ ],
    49                               "removeItemFromSelection(1): ");
    51       todo(select.selectAll() == false,
    52            "No way to select all items in listbox '" + id + "'");
    53       testSelectableSelection(select, [ "lb1_item1" ], "selectAll: ");
    55       select.addItemToSelection(1);
    56       select.unselectAll();
    57       testSelectableSelection(select, [ ], "unselectAll: ");
    59       //////////////////////////////////////////////////////////////////////////
    60       // multiple selectable listbox
    62       var id = "listbox2";
    63       ok(isAccessible(id, [nsIAccessibleSelectable]),
    64          "No selectable accessible for list of " + id);
    66       var select = getAccessible(id, [nsIAccessibleSelectable]);
    67       testSelectableSelection(select, [ ]);
    69       select.addItemToSelection(1);
    70       testSelectableSelection(select, [ "lb2_item2" ], "addItemToSelect(1): ");
    72       select.removeItemFromSelection(1);
    73       testSelectableSelection(select, [ ],
    74                               "removeItemFromSelection(1): ");
    76       is(select.selectAll(), true,
    77          "All items should be selected in listbox '" + id + "'");
    78       testSelectableSelection(select, [ "lb2_item1", "lb2_item2" ],
    79                               "selectAll: ");
    81       select.unselectAll();
    82       testSelectableSelection(select, [ ], "unselectAll: ");
    84       //////////////////////////////////////////////////////////////////////////
    85       // listbox with headers
    87       // XXX: addItemToSelection/removeItemFromSelection don't work correctly
    88       // on listboxes with headers because header is inserted into hierarchy
    89       // and child indexes that are used in these methods are shifted (see bug
    90       // 591939).
    91       todo(false,
    92            "Fix addItemToSelection/removeItemFromSelection on listboxes with headers.");
    94       SimpleTest.finish();
    95     }
    97     SimpleTest.waitForExplicitFinish();
    98     addA11yLoadEvent(doTest);
    99   ]]>
   100   </script>
   102   <hbox flex="1" style="overflow: auto;">
   103     <body xmlns="http://www.w3.org/1999/xhtml">
   104       <a target="_blank"
   105         href="https://bugzilla.mozilla.org/show_bug.cgi?id=590176"
   106         title="add pseudo SelectAccessible interface">
   107        Mozilla Bug 590176
   108       </a><br/>
   109       <p id="display"></p>
   110       <div id="content" style="display: none">
   111       </div>
   112       <pre id="test">
   113       </pre>
   114     </body>
   116     <vbox flex="1">
   117       <listbox id="listbox">
   118         <listcols>
   119           <listcol flex="1"/>
   120           <listcol flex="1"/>
   121         </listcols>
   122         <listitem id="lb1_item1">
   123           <listcell label="cell0"/>
   124           <listcell label="cell1"/>
   125         </listitem>
   126         <listitem id="lb1_item2">
   127           <listcell label="cell3"/>
   128           <listcell label="cell4"/>
   129         </listitem>
   130       </listbox>
   132       <listbox id="listbox2" seltype="multiple">
   133         <listcols>
   134           <listcol flex="1"/>
   135           <listcol flex="1"/>
   136         </listcols>
   137         <listitem id="lb2_item1">
   138           <listcell label="cell0"/>
   139           <listcell label="cell1"/>
   140         </listitem>
   141         <listitem id="lb2_item2">
   142           <listcell label="cell3"/>
   143           <listcell label="cell4"/>
   144         </listitem>
   145       </listbox>
   147       <vbox id="debug"/>
   148     </vbox>
   149   </hbox>
   151 </window>

mercurial