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 | XUL Widget Test for listbox direction |
michael@0 | 6 | --> |
michael@0 | 7 | <window title="Listbox direction test" |
michael@0 | 8 | onload="test_richlistbox()" |
michael@0 | 9 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 10 | <script type="application/javascript" |
michael@0 | 11 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 12 | <script type="application/javascript" |
michael@0 | 13 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 14 | |
michael@0 | 15 | <richlistbox seltype="multiple" id="richlistbox" flex="1" minheight="80" maxheight="80" height="80" /> |
michael@0 | 16 | |
michael@0 | 17 | <!-- test results are displayed in the html:body --> |
michael@0 | 18 | <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> |
michael@0 | 19 | |
michael@0 | 20 | <script type="application/javascript"> |
michael@0 | 21 | <![CDATA[ |
michael@0 | 22 | |
michael@0 | 23 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 24 | |
michael@0 | 25 | var richListBox = document.getElementById("richlistbox"); |
michael@0 | 26 | |
michael@0 | 27 | function getScrollIndexAmount(aDirection) { |
michael@0 | 28 | return (4 * aDirection + richListBox.currentIndex); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | function test_richlistbox() |
michael@0 | 32 | { |
michael@0 | 33 | richListBox.minHeight = richListBox.maxHeight = richListBox.height = |
michael@0 | 34 | 80 + (80 - richListBox.scrollBoxObject.height); |
michael@0 | 35 | var height = richListBox.scrollBoxObject.height; |
michael@0 | 36 | var item; |
michael@0 | 37 | do { |
michael@0 | 38 | item = richListBox.appendItem("Test", ""); |
michael@0 | 39 | item.height = item.minHeight = item.maxHeight = Math.floor(height / 4); |
michael@0 | 40 | } while (item.getBoundingClientRect().bottom < (height * 2)) |
michael@0 | 41 | richListBox.appendItem("Test", ""); |
michael@0 | 42 | richListBox.firstChild.nextSibling.id = "list-box-first"; |
michael@0 | 43 | richListBox.lastChild.previousSibling.id = "list-box-last"; |
michael@0 | 44 | |
michael@0 | 45 | // direction = "reverse", the values here are backwards due to the fact that |
michael@0 | 46 | // richlistboxes respond differently when a user initiates a selection |
michael@0 | 47 | richListBox.dir = "reverse"; |
michael@0 | 48 | var count = richListBox.itemCount; |
michael@0 | 49 | richListBox.focus(); |
michael@0 | 50 | richListBox.selectedIndex = count - 1; |
michael@0 | 51 | sendKey("DOWN"); |
michael@0 | 52 | is(richListBox.currentIndex, count - 2, "Selection should move to the next item"); |
michael@0 | 53 | sendKey("UP"); |
michael@0 | 54 | is(richListBox.currentIndex, count - 1, "Selection should move to the previous item"); |
michael@0 | 55 | sendKey("END"); |
michael@0 | 56 | is(richListBox.currentIndex, 0, "Selection should move to the last item"); |
michael@0 | 57 | sendKey("HOME"); |
michael@0 | 58 | is(richListBox.currentIndex, count - 1, "Selection should move to the first item"); |
michael@0 | 59 | var currentIndex = richListBox.currentIndex; |
michael@0 | 60 | var index = getScrollIndexAmount(-1); |
michael@0 | 61 | sendKey("PAGE_DOWN"); |
michael@0 | 62 | is(richListBox.currentIndex, index, "Selection should move to one page down"); |
michael@0 | 63 | ok(richListBox.currentIndex < currentIndex, "Selection should move downwards"); |
michael@0 | 64 | sendKey("END"); |
michael@0 | 65 | currentIndex = richListBox.currentIndex; |
michael@0 | 66 | index = getScrollIndexAmount(1); |
michael@0 | 67 | sendKey("PAGE_UP"); |
michael@0 | 68 | is(richListBox.currentIndex, index, "Selection should move to one page up"); |
michael@0 | 69 | ok(richListBox.currentIndex > currentIndex, "Selection should move upwards"); |
michael@0 | 70 | richListBox.selectedItem = richListBox.lastChild; |
michael@0 | 71 | richListBox.focus(); |
michael@0 | 72 | synthesizeKey("VK_DOWN", {shiftKey: true, type: "keypress"}, window); |
michael@0 | 73 | let items = [richListBox.selectedItems[0], |
michael@0 | 74 | richListBox.selectedItems[1]]; |
michael@0 | 75 | is(items[0], richListBox.lastChild, "The last element should still be selected"); |
michael@0 | 76 | is(items[1], richListBox.lastChild.previousSibling, "Both elements should now be selected"); |
michael@0 | 77 | richListBox.clearSelection(); |
michael@0 | 78 | richListBox.selectedItem = richListBox.lastChild; |
michael@0 | 79 | sendMouseEvent({type: "click", shiftKey: true, clickCount: 1}, |
michael@0 | 80 | "list-box-last", |
michael@0 | 81 | window); |
michael@0 | 82 | items = [richListBox.selectedItems[0], |
michael@0 | 83 | richListBox.selectedItems[1]]; |
michael@0 | 84 | is(items[0], richListBox.lastChild, "The last element should still be selected"); |
michael@0 | 85 | is(items[1], richListBox.lastChild.previousSibling, "Both elements should now be selected"); |
michael@0 | 86 | richListBox.addEventListener("keypress", function(aEvent) { |
michael@0 | 87 | richListBox.removeEventListener("keypress", arguments.callee, true); |
michael@0 | 88 | aEvent.preventDefault(); |
michael@0 | 89 | }, true); |
michael@0 | 90 | richListBox.selectedIndex = 1; |
michael@0 | 91 | sendKey("HOME"); |
michael@0 | 92 | is(richListBox.selectedIndex, 1, "A stopped event should return indexing to normal"); |
michael@0 | 93 | |
michael@0 | 94 | // direction = "normal" |
michael@0 | 95 | richListBox.dir = "normal"; |
michael@0 | 96 | richListBox.selectedIndex = 0; |
michael@0 | 97 | sendKey("DOWN"); |
michael@0 | 98 | is(richListBox.currentIndex, 1, "Selection should move to the next item"); |
michael@0 | 99 | sendKey("UP"); |
michael@0 | 100 | is(richListBox.currentIndex, 0, "Selection should move to the previous item"); |
michael@0 | 101 | sendKey("END"); |
michael@0 | 102 | is(richListBox.currentIndex, count - 1, "Selection should move to the last item"); |
michael@0 | 103 | sendKey("HOME"); |
michael@0 | 104 | is(richListBox.currentIndex, 0, "Selection should move to the first item"); |
michael@0 | 105 | var currentIndex = richListBox.currentIndex; |
michael@0 | 106 | var index = richListBox.scrollOnePage(1); |
michael@0 | 107 | sendKey("PAGE_DOWN"); |
michael@0 | 108 | is(richListBox.currentIndex, index, "Selection should move to one page down"); |
michael@0 | 109 | ok(richListBox.currentIndex > currentIndex, "Selection should move downwards"); |
michael@0 | 110 | sendKey("END"); |
michael@0 | 111 | currentIndex = richListBox.currentIndex; |
michael@0 | 112 | index = richListBox.scrollOnePage(-1) + richListBox.currentIndex; |
michael@0 | 113 | sendKey("PAGE_UP"); |
michael@0 | 114 | is(richListBox.currentIndex, index, "Selection should move to one page up"); |
michael@0 | 115 | ok(richListBox.currentIndex < currentIndex, "Selection should move upwards"); |
michael@0 | 116 | richListBox.selectedItem = richListBox.firstChild; |
michael@0 | 117 | richListBox.focus(); |
michael@0 | 118 | synthesizeKey("VK_DOWN", {shiftKey: true, type: "keypress"}, window); |
michael@0 | 119 | items = [richListBox.selectedItems[0], |
michael@0 | 120 | richListBox.selectedItems[1]]; |
michael@0 | 121 | is(items[0], richListBox.firstChild, "The last element should still be selected"); |
michael@0 | 122 | is(items[1], richListBox.firstChild.nextSibling, "Both elements should now be selected"); |
michael@0 | 123 | richListBox.clearSelection(); |
michael@0 | 124 | richListBox.selectedItem = richListBox.firstChild; |
michael@0 | 125 | sendMouseEvent({type: "click", shiftKey: true, clickCount: 1}, |
michael@0 | 126 | "list-box-first", |
michael@0 | 127 | window); |
michael@0 | 128 | items = [richListBox.selectedItems[0], |
michael@0 | 129 | richListBox.selectedItems[1]]; |
michael@0 | 130 | is(items[0], richListBox.firstChild, "The last element should still be selected"); |
michael@0 | 131 | is(items[1], richListBox.firstChild.nextSibling, "Both elements should now be selected"); |
michael@0 | 132 | SimpleTest.finish(); |
michael@0 | 133 | } |
michael@0 | 134 | |
michael@0 | 135 | ]]> |
michael@0 | 136 | </script> |
michael@0 | 137 | |
michael@0 | 138 | </window> |