toolkit/content/tests/chrome/test_hiddenitems.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
michael@0 4 <!--
michael@0 5 https://bugzilla.mozilla.org/show_bug.cgi?id=317422
michael@0 6 -->
michael@0 7 <window title="Mozilla Bug 317422"
michael@0 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
michael@0 10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
michael@0 11
michael@0 12 <!-- test results are displayed in the html:body -->
michael@0 13 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 14 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=317422"
michael@0 15 target="_blank">Mozilla Bug 317422</a>
michael@0 16 </body>
michael@0 17
michael@0 18 <richlistbox id="richlistbox" seltype="multiple">
michael@0 19 <richlistitem id="richlistbox_item1"><label value="Item 1"/></richlistitem>
michael@0 20 <richlistitem id="richlistbox_item2"><label value="Item 2"/></richlistitem>
michael@0 21 <richlistitem id="richlistbox_item3" hidden="true"><label value="Item 3"/></richlistitem>
michael@0 22 <richlistitem id="richlistbox_item4"><label value="Item 4"/></richlistitem>
michael@0 23 <richlistitem id="richlistbox_item5" collapsed="true"><label value="Item 5"/></richlistitem>
michael@0 24 <richlistitem id="richlistbox_item6"><label value="Item 6"/></richlistitem>
michael@0 25 <richlistitem id="richlistbox_item7" hidden="true"><label value="Item 7"/></richlistitem>
michael@0 26 </richlistbox>
michael@0 27
michael@0 28 <listbox id="listbox" seltype="multiple">
michael@0 29 <listitem id="listbox_item1" label="Item 1"/>
michael@0 30 <listitem id="listbox_item2" label="Item 2"/>
michael@0 31 <listitem id="listbox_item3" label="Item 3" hidden="true"/>
michael@0 32 <listitem id="listbox_item4" label="Item 4"/>
michael@0 33 <listitem id="listbox_item5" label="Item 5" collapsed="true"/>
michael@0 34 <listitem id="listbox_item6" label="Item 6"/>
michael@0 35 <listitem id="listbox_item7" label="Item 7" hidden="true"/>
michael@0 36 </listbox>
michael@0 37
michael@0 38 <!-- test code goes here -->
michael@0 39 <script type="application/javascript"><![CDATA[
michael@0 40
michael@0 41 /** Test for Bug 317422 **/
michael@0 42 SimpleTest.waitForExplicitFinish();
michael@0 43
michael@0 44 function testListbox(id)
michael@0 45 {
michael@0 46 var listbox = document.getElementById(id);
michael@0 47 listbox.focus();
michael@0 48 is(listbox.getRowCount(), 7, id + ": Returned the wrong number of rows");
michael@0 49 is(listbox.getItemAtIndex(2).id, id + "_item3", id + ": Should still return hidden items");
michael@0 50 listbox.selectedIndex = 0;
michael@0 51 is(listbox.selectedItem.id, id + "_item1", id + ": First item was not selected");
michael@0 52 sendKey("DOWN");
michael@0 53 is(listbox.selectedItem.id, id + "_item2", id + ": Down didn't move to second item");
michael@0 54 sendKey("DOWN");
michael@0 55 is(listbox.selectedItem.id, id + "_item4", id + ": Down didn't skip hidden item");
michael@0 56 sendKey("DOWN");
michael@0 57 is(listbox.selectedItem.id, id + "_item6", id + ": Down didn't skip collapsed item");
michael@0 58 sendKey("UP");
michael@0 59 is(listbox.selectedItem.id, id + "_item4", id + ": Up didn't skip collapsed item");
michael@0 60 sendKey("UP");
michael@0 61 is(listbox.selectedItem.id, id + "_item2", id + ": Up didn't skip hidden item");
michael@0 62 listbox.selectAll();
michael@0 63 is(listbox.selectedItems.length, 7, id + ": Should have still selected all items");
michael@0 64 listbox.invertSelection();
michael@0 65 is(listbox.selectedItems.length, 0, id + ": Should have unselected all items");
michael@0 66 listbox.selectedIndex = 2;
michael@0 67 ok(listbox.selectedItem == listbox.getItemAtIndex(2), id + ": Should have selected the hidden item");
michael@0 68 listbox.selectedIndex = 0;
michael@0 69 sendKey("END");
michael@0 70 is(listbox.selectedItem.id, id + "_item6", id + ": Should have moved to the last unhidden item");
michael@0 71 sendMouseEvent({type: 'click'}, id + "_item1");
michael@0 72 ok(listbox.selectedItem == listbox.getItemAtIndex(0), id + ": Should have selected the first item");
michael@0 73 is(listbox.selectedItems.length, 1, id + ": Should only be one selected item");
michael@0 74 sendMouseEvent({type: 'click', shiftKey: true}, id + "_item6");
michael@0 75 is(listbox.selectedItems.length, 4, id + ": Should have selected all visible items");
michael@0 76 listbox.selectedIndex = 0;
michael@0 77 sendKey("PAGE_DOWN");
michael@0 78 is(listbox.selectedItem.id, id + "_item6", id + ": Page down should go to the last visible item");
michael@0 79 sendKey("PAGE_UP");
michael@0 80 is(listbox.selectedItem.id, id + "_item1", id + ": Page up should go to the first visible item");
michael@0 81 }
michael@0 82
michael@0 83 window.onload = function runTests() {
michael@0 84 testListbox("richlistbox");
michael@0 85 testListbox("listbox");
michael@0 86 SimpleTest.finish();
michael@0 87 };
michael@0 88 ]]></script>
michael@0 89 </window>

mercurial