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 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=375008 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug 375008</title> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=375008">Mozilla Bug 375008</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <div id="content"> |
michael@0 | 17 | <div> |
michael@0 | 18 | <input id='witness'> |
michael@0 | 19 | </div> |
michael@0 | 20 | |
michael@0 | 21 | <div id='not-focusable'> |
michael@0 | 22 | <!-- Disabled elements --> |
michael@0 | 23 | <button hidden disabled>foo</button> |
michael@0 | 24 | <input hidden disabled> |
michael@0 | 25 | <fieldset hidden disabled>foo</fieldset> |
michael@0 | 26 | <select hidden disabled><option>foo</option></select> |
michael@0 | 27 | <textarea hidden disabled></textarea> |
michael@0 | 28 | <optgroup hidden disabled><option>foo</option></optgroup> |
michael@0 | 29 | <option hidden disabled>foo</option> |
michael@0 | 30 | </div> |
michael@0 | 31 | |
michael@0 | 32 | <div id='focusable'> |
michael@0 | 33 | <button hidden>foo</button> |
michael@0 | 34 | <input hidden> |
michael@0 | 35 | <select hidden><option>foo</option></select> |
michael@0 | 36 | <textarea hidden></textarea> |
michael@0 | 37 | |
michael@0 | 38 | <!-- Those elements are not focusable by default. --> |
michael@0 | 39 | <fieldset tabindex=1 hidden>foo</fieldset> |
michael@0 | 40 | <optgroup tabindex=1 hidden><option>foo</option></optgroup> |
michael@0 | 41 | <option tabindex=1 hidden>foo</option> |
michael@0 | 42 | </div> |
michael@0 | 43 | |
michael@0 | 44 | <!-- Hidden elements, they have a frame but focus will go through them. --> |
michael@0 | 45 | <div id='hidden' style='visibility: hidden;'> |
michael@0 | 46 | <button hidden>foo</button> |
michael@0 | 47 | <input hidden> |
michael@0 | 48 | <fieldset hidden>foo</fieldset> |
michael@0 | 49 | <select hidden><option>foo</option></select> |
michael@0 | 50 | <textarea hidden></textarea> |
michael@0 | 51 | <optgroup hidden><option>foo</option></optgroup> |
michael@0 | 52 | <option hidden>foo</option> |
michael@0 | 53 | </div> |
michael@0 | 54 | |
michael@0 | 55 | </div> |
michael@0 | 56 | <pre id="test"> |
michael@0 | 57 | <script type="application/javascript"> |
michael@0 | 58 | |
michael@0 | 59 | /** Test for Bug 375008 **/ |
michael@0 | 60 | |
michael@0 | 61 | /* |
michael@0 | 62 | * This test is divided in three parts: |
michael@0 | 63 | * - cases where focus isn't doable but blur should not happen; |
michael@0 | 64 | * - cases where focus is doable; |
michael@0 | 65 | * - cases where focus isn't doable but blur should still happen. |
michael@0 | 66 | */ |
michael@0 | 67 | |
michael@0 | 68 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 69 | SimpleTest.waitForFocus(function() { |
michael@0 | 70 | // On Mac, this preference needs to be turned on to be able to focus all the |
michael@0 | 71 | // form controls we want to focus. |
michael@0 | 72 | SpecialPowers.pushPrefEnv({"set": [[ "accessibility.mouse_focuses_formcontrol", true ]]}, |
michael@0 | 73 | runTest); |
michael@0 | 74 | }); |
michael@0 | 75 | |
michael@0 | 76 | function runTest() |
michael@0 | 77 | { |
michael@0 | 78 | var witness = document.getElementById('witness'); |
michael@0 | 79 | witness.focus(); |
michael@0 | 80 | |
michael@0 | 81 | var notFocusableElements = document.getElementById('not-focusable').children; |
michael@0 | 82 | for (var i=0; i<notFocusableElements.length; ++i) { |
michael@0 | 83 | var element = notFocusableElements[i]; |
michael@0 | 84 | element.hidden = false; |
michael@0 | 85 | synthesizeMouseAtCenter(element, {}); |
michael@0 | 86 | is(document.activeElement, witness, |
michael@0 | 87 | "[" + element.tagName + "] witness should still be focused"); |
michael@0 | 88 | |
michael@0 | 89 | // Cleanup. |
michael@0 | 90 | element.hidden = true; |
michael@0 | 91 | witness.focus(); |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | var focusableElements = document.getElementById('focusable').children; |
michael@0 | 95 | for (var i=0; i<focusableElements.length; ++i) { |
michael@0 | 96 | var element = focusableElements[i]; |
michael@0 | 97 | element.hidden = false; |
michael@0 | 98 | synthesizeMouseAtCenter(element, {}); |
michael@0 | 99 | is(document.activeElement, element, "focus should have moved to " + element); |
michael@0 | 100 | |
michael@0 | 101 | // Cleanup. |
michael@0 | 102 | element.hidden = true; |
michael@0 | 103 | witness.focus(); |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | var hiddenElements = document.getElementById('hidden').children; |
michael@0 | 107 | for (var i=0; i<hiddenElements.length; ++i) { |
michael@0 | 108 | var element = hiddenElements[i]; |
michael@0 | 109 | element.hidden = false; |
michael@0 | 110 | synthesizeMouseAtCenter(element, {}); |
michael@0 | 111 | is(document.activeElement, document.body, |
michael@0 | 112 | "focus should have moved to the body"); |
michael@0 | 113 | |
michael@0 | 114 | // Cleanup. |
michael@0 | 115 | element.hidden = true; |
michael@0 | 116 | witness.focus(); |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | SimpleTest.finish(); |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | </script> |
michael@0 | 123 | </pre> |
michael@0 | 124 | </body> |
michael@0 | 125 | </html> |