Sat, 03 Jan 2015 20:18:00 +0100
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 | <style xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 13 | /* This makes the richlistbox about 4.5 rows high */ |
michael@0 | 14 | richlistitem { |
michael@0 | 15 | height: 30px; |
michael@0 | 16 | } |
michael@0 | 17 | richlistbox { |
michael@0 | 18 | height: 135px; |
michael@0 | 19 | } |
michael@0 | 20 | </style> |
michael@0 | 21 | |
michael@0 | 22 | <!-- test results are displayed in the html:body --> |
michael@0 | 23 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 24 | <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=317422" |
michael@0 | 25 | target="_blank">Mozilla Bug 317422</a> |
michael@0 | 26 | </body> |
michael@0 | 27 | |
michael@0 | 28 | <richlistbox id="richlistbox" seltype="multiple"> |
michael@0 | 29 | <richlistitem id="richlistbox_item1"><label value="Item 1"/></richlistitem> |
michael@0 | 30 | <richlistitem id="richlistbox_item2"><label value="Item 2"/></richlistitem> |
michael@0 | 31 | <richlistitem id="richlistbox_item3" hidden="true"><label value="Item 3"/></richlistitem> |
michael@0 | 32 | <richlistitem id="richlistbox_item4"><label value="Item 4"/></richlistitem> |
michael@0 | 33 | <richlistitem id="richlistbox_item5" collapsed="true"><label value="Item 5"/></richlistitem> |
michael@0 | 34 | <richlistitem id="richlistbox_item6"><label value="Item 6"/></richlistitem> |
michael@0 | 35 | <richlistitem id="richlistbox_item7"><label value="Item 7"/></richlistitem> |
michael@0 | 36 | <richlistitem id="richlistbox_item8"><label value="Item 8"/></richlistitem> |
michael@0 | 37 | <richlistitem id="richlistbox_item9"><label value="Item 9"/></richlistitem> |
michael@0 | 38 | <richlistitem id="richlistbox_item10"><label value="Item 10"/></richlistitem> |
michael@0 | 39 | <richlistitem id="richlistbox_item11"><label value="Item 11"/></richlistitem> |
michael@0 | 40 | <richlistitem id="richlistbox_item12"><label value="Item 12"/></richlistitem> |
michael@0 | 41 | <richlistitem id="richlistbox_item13"><label value="Item 13"/></richlistitem> |
michael@0 | 42 | <richlistitem id="richlistbox_item14"><label value="Item 14"/></richlistitem> |
michael@0 | 43 | <richlistitem id="richlistbox_item15" hidden="true"><label value="Item 15"/></richlistitem> |
michael@0 | 44 | </richlistbox> |
michael@0 | 45 | |
michael@0 | 46 | <listbox id="listbox" seltype="multiple" rows="5"> |
michael@0 | 47 | <listitem id="listbox_item1" label="Item 1"/> |
michael@0 | 48 | <listitem id="listbox_item2" label="Item 2"/> |
michael@0 | 49 | <listitem id="listbox_item3" label="Item 3" hidden="true"/> |
michael@0 | 50 | <listitem id="listbox_item4" label="Item 4"/> |
michael@0 | 51 | <listitem id="listbox_item5" label="Item 5" hidden="true"/> |
michael@0 | 52 | <listitem id="listbox_item6" label="Item 6"/> |
michael@0 | 53 | <listitem id="listbox_item7" label="Item 7"/> |
michael@0 | 54 | <listitem id="listbox_item8" label="Item 8"/> |
michael@0 | 55 | <listitem id="listbox_item9" label="Item 9"/> |
michael@0 | 56 | <listitem id="listbox_item10" label="Item 10"/> |
michael@0 | 57 | <listitem id="listbox_item11" label="Item 11"/> |
michael@0 | 58 | <listitem id="listbox_item12" label="Item 12"/> |
michael@0 | 59 | <listitem id="listbox_item13" label="Item 13"/> |
michael@0 | 60 | <listitem id="listbox_item14" label="Item 14"/> |
michael@0 | 61 | <listitem id="listbox_item15" label="Item 15" hidden="true"/> |
michael@0 | 62 | </listbox> |
michael@0 | 63 | |
michael@0 | 64 | <!-- test code goes here --> |
michael@0 | 65 | <script type="application/javascript"><![CDATA[ |
michael@0 | 66 | |
michael@0 | 67 | /** Test for Bug 317422 **/ |
michael@0 | 68 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 69 | |
michael@0 | 70 | function testRichlistbox() |
michael@0 | 71 | { |
michael@0 | 72 | var id = "richlistbox"; |
michael@0 | 73 | var listbox = document.getElementById(id); |
michael@0 | 74 | listbox.focus(); |
michael@0 | 75 | listbox.selectedIndex = 0; |
michael@0 | 76 | sendKey("PAGE_DOWN"); |
michael@0 | 77 | is(listbox.selectedItem.id, id + "_item7", id + ": Page down should go to the item one visible page away"); |
michael@0 | 78 | is(listbox.getIndexOfFirstVisibleRow(), 6, id + ": Page down should have scrolled down a visible page"); |
michael@0 | 79 | sendKey("PAGE_DOWN"); |
michael@0 | 80 | is(listbox.selectedItem.id, id + "_item11", id + ": Second page down should go to the item two visible pages away"); |
michael@0 | 81 | is(listbox.getIndexOfFirstVisibleRow(), 9, id + ": Second page down should not scroll beyond the end"); |
michael@0 | 82 | sendKey("PAGE_DOWN"); |
michael@0 | 83 | is(listbox.selectedItem.id, id + "_item14", id + ": Third page down should go to the last visible item"); |
michael@0 | 84 | is(listbox.getIndexOfFirstVisibleRow(), 9, id + ": Third page down should not have scrolled at all"); |
michael@0 | 85 | sendKey("PAGE_UP"); |
michael@0 | 86 | is(listbox.selectedItem.id, id + "_item10", id + ": Page up should go to the item one visible page away"); |
michael@0 | 87 | is(listbox.getIndexOfFirstVisibleRow(), 5, id + ": Page up should scroll up a visible page"); |
michael@0 | 88 | sendKey("PAGE_UP"); |
michael@0 | 89 | is(listbox.selectedItem.id, id + "_item6", id + ": Second page up should go to the item two visible pages away"); |
michael@0 | 90 | is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Second page up should not scroll beyond the start"); |
michael@0 | 91 | sendKey("PAGE_UP"); |
michael@0 | 92 | is(listbox.selectedItem.id, id + "_item1", id + ": Third page up should return to the first visible item"); |
michael@0 | 93 | is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Third page up should not have scrolled at all"); |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | function testListbox() |
michael@0 | 97 | { |
michael@0 | 98 | var id = "listbox"; |
michael@0 | 99 | var listbox = document.getElementById(id); |
michael@0 | 100 | |
michael@0 | 101 | if (!window.matchMedia("(-moz-overlay-scrollbars)").matches) { |
michael@0 | 102 | // Check that a scrollbar is visible by comparing the width of the listitem |
michael@0 | 103 | // with the width of the listbox. This is a simple way to do this without |
michael@0 | 104 | // checking the anonymous content. |
michael@0 | 105 | ok(listbox.firstChild.getBoundingClientRect().width < listbox.getBoundingClientRect().width - 10, |
michael@0 | 106 | id + ": Scrollbar visible"); |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | var rowHeight = listbox.firstChild.getBoundingClientRect().height; |
michael@0 | 110 | |
michael@0 | 111 | listbox.focus(); |
michael@0 | 112 | listbox.selectedIndex = 0; |
michael@0 | 113 | sendKey("PAGE_DOWN"); |
michael@0 | 114 | is(listbox.selectedItem.id, id + "_item8", id + ": Page down should go to the item one visible page away"); |
michael@0 | 115 | is(listbox.getIndexOfFirstVisibleRow(), 7, id + ": Page down should have scrolled down a visible page"); |
michael@0 | 116 | sendKey("PAGE_DOWN"); |
michael@0 | 117 | is(listbox.selectedItem.id, id + "_item13", id + ": Second page down should go to the item two visible pages away"); |
michael@0 | 118 | is(listbox.getIndexOfFirstVisibleRow(), 9, id + ": Second page down should not scroll beyond the end"); |
michael@0 | 119 | sendKey("PAGE_DOWN"); |
michael@0 | 120 | is(listbox.selectedItem.id, id + "_item14", id + ": Third page down should go to the last visible item"); |
michael@0 | 121 | is(listbox.getIndexOfFirstVisibleRow(), 9, id + ": Third page down should not have scrolled at all"); |
michael@0 | 122 | sendKey("PAGE_UP"); |
michael@0 | 123 | is(listbox.selectedItem.id, id + "_item9", id + ": Page up should go to the item one visible page away"); |
michael@0 | 124 | // the listScrollbox seems to go haywire when scrolling up with hidden listitems |
michael@0 | 125 | todo_is(listbox.getIndexOfFirstVisibleRow(), 3, id + ": Page up should scroll up a visible page"); |
michael@0 | 126 | sendKey("PAGE_UP"); |
michael@0 | 127 | is(listbox.selectedItem.id, id + "_item2", id + ": Second page up should go to the item two visible pages away"); |
michael@0 | 128 | is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Second page up should not scroll beyond the start"); |
michael@0 | 129 | sendKey("PAGE_UP"); |
michael@0 | 130 | is(listbox.selectedItem.id, id + "_item1", id + ": Third page up should return to the first visible item"); |
michael@0 | 131 | is(listbox.getIndexOfFirstVisibleRow(), 0, id + ": Third page up should not have scrolled at all"); |
michael@0 | 132 | |
michael@0 | 133 | var scrollHeight = document.getAnonymousNodes(listbox)[1].lastChild.scrollHeight; |
michael@0 | 134 | is(scrollHeight, rowHeight * 15, id + ": scrollHeight when rows set"); |
michael@0 | 135 | |
michael@0 | 136 | listbox.minHeight = 50; |
michael@0 | 137 | scrollHeight = document.getAnonymousNodes(listbox)[1].lastChild.scrollHeight; |
michael@0 | 138 | is(scrollHeight, rowHeight * 15, id + ": scrollHeight when rows and minimium height set"); |
michael@0 | 139 | |
michael@0 | 140 | listbox.removeAttribute("rows"); |
michael@0 | 141 | |
michael@0 | 142 | var availHeight = document.getAnonymousNodes(listbox)[1].lastChild.getBoundingClientRect().height; |
michael@0 | 143 | // The listbox layout adds this extra height in GetPrefSize. Not sure what it's for though. |
michael@0 | 144 | var e = (rowHeight * 15 - availHeight) % rowHeight; |
michael@0 | 145 | var extraHeight = (e == 0) ? 0 : rowHeight - e; |
michael@0 | 146 | |
michael@0 | 147 | scrollHeight = document.getAnonymousNodes(listbox)[1].lastChild.scrollHeight; |
michael@0 | 148 | is(scrollHeight, rowHeight * 15 + extraHeight, id + ": scrollHeight when minimium height set"); |
michael@0 | 149 | |
michael@0 | 150 | listbox.removeAttribute("minheight"); |
michael@0 | 151 | scrollHeight = document.getAnonymousNodes(listbox)[1].lastChild.scrollHeight; |
michael@0 | 152 | is(scrollHeight, rowHeight * 15 + extraHeight, id + ": scrollHeight"); |
michael@0 | 153 | } |
michael@0 | 154 | |
michael@0 | 155 | window.onload = function runTests() { |
michael@0 | 156 | testRichlistbox(); |
michael@0 | 157 | testListbox(); |
michael@0 | 158 | SimpleTest.finish(); |
michael@0 | 159 | }; |
michael@0 | 160 | ]]></script> |
michael@0 | 161 | </window> |