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 | <window title="Autocomplete Widget Test" |
michael@0 | 6 | onload="setTimeout(keyCaretTest, 0);" |
michael@0 | 7 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 8 | |
michael@0 | 9 | <script type="application/javascript" |
michael@0 | 10 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 11 | <script type="application/javascript" |
michael@0 | 12 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
michael@0 | 13 | |
michael@0 | 14 | <textbox id="autocomplete" type="autocomplete"/> |
michael@0 | 15 | |
michael@0 | 16 | <script class="testbody" type="application/javascript"> |
michael@0 | 17 | <![CDATA[ |
michael@0 | 18 | |
michael@0 | 19 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 20 | |
michael@0 | 21 | function keyCaretTest() |
michael@0 | 22 | { |
michael@0 | 23 | var autocomplete = $("autocomplete"); |
michael@0 | 24 | |
michael@0 | 25 | autocomplete.focus(); |
michael@0 | 26 | checkKeyCaretTest("VK_UP", 0, 0, false, "no value up"); |
michael@0 | 27 | checkKeyCaretTest("VK_DOWN", 0, 0, false, "no value down"); |
michael@0 | 28 | |
michael@0 | 29 | autocomplete.value = "Sample"; |
michael@0 | 30 | |
michael@0 | 31 | autocomplete.selectionStart = 3; |
michael@0 | 32 | autocomplete.selectionEnd = 3; |
michael@0 | 33 | checkKeyCaretTest("VK_UP", 0, 0, true, "value up with caret in middle"); |
michael@0 | 34 | checkKeyCaretTest("VK_UP", 0, 0, false, "value up with caret in middle again"); |
michael@0 | 35 | |
michael@0 | 36 | autocomplete.selectionStart = 2; |
michael@0 | 37 | autocomplete.selectionEnd = 2; |
michael@0 | 38 | checkKeyCaretTest("VK_DOWN", 6, 6, true, "value down with caret in middle"); |
michael@0 | 39 | checkKeyCaretTest("VK_DOWN", 6, 6, false, "value down with caret in middle again"); |
michael@0 | 40 | |
michael@0 | 41 | autocomplete.selectionStart = 1; |
michael@0 | 42 | autocomplete.selectionEnd = 4; |
michael@0 | 43 | checkKeyCaretTest("VK_UP", 0, 0, true, "value up with selection"); |
michael@0 | 44 | |
michael@0 | 45 | autocomplete.selectionStart = 1; |
michael@0 | 46 | autocomplete.selectionEnd = 4; |
michael@0 | 47 | checkKeyCaretTest("VK_DOWN", 6, 6, true, "value down with selection"); |
michael@0 | 48 | |
michael@0 | 49 | SimpleTest.finish(); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | function checkKeyCaretTest(key, expectedStart, expectedEnd, result, testid) |
michael@0 | 53 | { |
michael@0 | 54 | var autocomplete = $("autocomplete"); |
michael@0 | 55 | |
michael@0 | 56 | var event = result ? "keypress" : "!keypress"; |
michael@0 | 57 | synthesizeKeyExpectEvent(key, { }, autocomplete.inputField, event, testid); |
michael@0 | 58 | is(autocomplete.selectionStart, expectedStart, testid + " selectionStart"); |
michael@0 | 59 | is(autocomplete.selectionEnd, expectedEnd, testid + " selectionEnd"); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | ]]> |
michael@0 | 63 | </script> |
michael@0 | 64 | |
michael@0 | 65 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 66 | <p id="display"> |
michael@0 | 67 | </p> |
michael@0 | 68 | <div id="content" style="display: none"> |
michael@0 | 69 | </div> |
michael@0 | 70 | <pre id="test"> |
michael@0 | 71 | </pre> |
michael@0 | 72 | </body> |
michael@0 | 73 | |
michael@0 | 74 | </window> |