From 83d5691cbcb7ae46226d9ba177b2b207b52f01dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 17 Mar 2021 22:34:55 +0000 Subject: [PATCH] Bug 1614658 - Enable accessibility.mouse_focuses_formcontrol by default. r=mac-reviewers,bradwerth,mstange This aligns Mac's focus model with other platforms. Matches Chromium, but not Safari. Reasons why I think it's worth making this change: * Consistency with all other platforms. * Makes the :focus-visible implementation more useful. * Fixes focus navigation after e.g. clicking a button. * Shouldn't cause a lot more outlines to show up (at least not by default). An example of the second point: data:text/html, In non-macOS platforms, we won't show an outline for the button in that case, which matches the developer expectations (links below). We don't show the outline because the focus comes from an element that has been focused by mouse (and thus didn't show an outline). But on macOS that doesn't work, because the button is not focused. For completeness, the actual heuristics for :focus-visible may change a bit as a result of the discussions in: * https://github.com/w3c/csswg-drafts/issues/5885 * https://github.com/web-platform-tests/wpt/pull/27806 But it's not clear to me how to best define this so it works on the macOS focus model. An example of the third point: data:text/html, On Safari and Chrome (and Firefox on non-macOS platforms), clicking the button, then pressing tab, goes to the input on the right. In Firefox on macOS it doesn't because the button doesn't gain focus nor is selectable. Differential Revision: https://phabricator.services.mozilla.com/D108808 --- dom/events/test/bug656379-1.html | 2 +- dom/html/test/test_focusshift_button.html | 8 +--- dom/tests/mochitest/chrome/test_focus.xhtml | 3 +- .../mochitest/general/test_focusrings.xhtml | 8 +++- modules/libpref/init/all.js | 2 +- .../css/selectors/focus-visible-003.html.ini | 39 ------------------- .../css/selectors/focus-visible-004.html.ini | 31 --------------- 7 files changed, 11 insertions(+), 82 deletions(-) delete mode 100644 testing/web-platform/meta/css/selectors/focus-visible-003.html.ini delete mode 100644 testing/web-platform/meta/css/selectors/focus-visible-004.html.ini diff --git a/dom/events/test/bug656379-1.html b/dom/events/test/bug656379-1.html index bfff2e2cd0772..708a3ef33a22d 100644 --- a/dom/events/test/bug656379-1.html +++ b/dom/events/test/bug656379-1.html @@ -128,7 +128,7 @@ // Release. sendMouseEvent("mouseup", label); yield undefined; - var focusOnMouse = (navigator.platform.indexOf("Mac") != 0); + var focusOnMouse = navigator.platform.indexOf("Mac") != 0 || SpecialPowers.getBoolPref("accessibility.mouse_focuses_formcontrol"); compareSnapshots_(focusOnMouse ? normalFocusedButtonCanvas : normalButtonCanvas, currentSnapshot, true, "Releasing the mouse over the label should have unpressed" + (focusOnMouse ? " (and focused)" : "") + " the button."); diff --git a/dom/html/test/test_focusshift_button.html b/dom/html/test/test_focusshift_button.html index 9a60974d8eac5..90fadd4827c2e 100644 --- a/dom/html/test/test_focusshift_button.html +++ b/dom/html/test/test_focusshift_button.html @@ -19,13 +19,7 @@ SimpleTest.waitForExplicitFinish(); SimpleTest.waitForFocus(function() { synthesizeMouseAtCenter(document.getElementById("button"), { }); - if (/Mac/.test(navigator.platform)) { - // Buttons don't focus when clicked on Mac. - is(result, "", "Focus button then input"); - } - else { - is(result, "(focus button)(blur button)(focus input)", "Focus button then input"); - } + is(result, "(focus button)(blur button)(focus input)", "Focus button then input"); SimpleTest.finish(); }); diff --git a/dom/tests/mochitest/chrome/test_focus.xhtml b/dom/tests/mochitest/chrome/test_focus.xhtml index cff366f5addf0..01b3e82d4a790 100644 --- a/dom/tests/mochitest/chrome/test_focus.xhtml +++ b/dom/tests/mochitest/chrome/test_focus.xhtml @@ -14,8 +14,9 @@ if (navigator.platform.startsWith("Win")) { } SimpleTest.waitForExplicitFinish(); -function runTest() +async function runTest() { + await SpecialPowers.pushPrefEnv({"set": [['accessibility.mouse_focuses_formcontrol', false]]}); window.openDialog("window_focus.xhtml", "_blank", "chrome,width=600,height=550,noopener", window); } diff --git a/dom/tests/mochitest/general/test_focusrings.xhtml b/dom/tests/mochitest/general/test_focusrings.xhtml index 18b416744ed57..80cec266b3921 100644 --- a/dom/tests/mochitest/general/test_focusrings.xhtml +++ b/dom/tests/mochitest/general/test_focusrings.xhtml @@ -27,7 +27,11 @@ function snapShot(element) { function initTest() { - SpecialPowers.pushPrefEnv({"set": [['accessibility.tabfocus', 7]]}, runTest); + SpecialPowers.pushPrefEnv({ + "set": [ + ['accessibility.mouse_focuses_formcontrol', false], + ] + }, runTest); } function runTest() @@ -179,7 +183,7 @@ function testHTMLElements(list, isMac, expectedNoRingsOnWin) } } -SimpleTest.waitForFocus(runTest); +SimpleTest.waitForFocus(initTest); ]]> diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 339335fb04deb..3d2bf6e056c82 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -720,7 +720,7 @@ pref("accessibility.force_disabled", 0); pref("focusmanager.testmode", false); pref("accessibility.usetexttospeech", ""); -pref("accessibility.mouse_focuses_formcontrol", false); +pref("accessibility.mouse_focuses_formcontrol", true); // Type Ahead Find pref("accessibility.typeaheadfind", true); diff --git a/testing/web-platform/meta/css/selectors/focus-visible-003.html.ini b/testing/web-platform/meta/css/selectors/focus-visible-003.html.ini deleted file mode 100644 index ff0f26d16541b..0000000000000 --- a/testing/web-platform/meta/css/selectors/focus-visible-003.html.ini +++ /dev/null @@ -1,39 +0,0 @@ -[focus-visible-003.html] - expected: - if os == "mac": TIMEOUT - [Focus element BUTTON#el-4 via mouse should NOT match :focus-visible as it does NOT support keyboard input] - expected: - if os == "mac": TIMEOUT - - [Focus element INPUT#el-10 via mouse should NOT match :focus-visible as it does NOT support keyboard input] - expected: - if os == "mac": NOTRUN - - [Focus element INPUT#el-13 via mouse should NOT match :focus-visible as it does NOT support keyboard input] - expected: - if os == "mac": NOTRUN - - [Focus element INPUT#el-8 via mouse should NOT match :focus-visible as it does NOT support keyboard input] - expected: - if os == "mac": NOTRUN - - [Focus element INPUT#el-5 via mouse should NOT match :focus-visible as it does NOT support keyboard input] - expected: - if os == "mac": NOTRUN - - [Focus element INPUT#el-7 via mouse should NOT match :focus-visible as it does NOT support keyboard input] - expected: - if os == "mac": NOTRUN - - [Focus element INPUT#el-12 via mouse should NOT match :focus-visible as it does NOT support keyboard input] - expected: - if os == "mac": NOTRUN - - [Focus element INPUT#el-9 via mouse should NOT match :focus-visible as it does NOT support keyboard input] - expected: - if os == "mac": NOTRUN - - [Focus element INPUT#el-6 via mouse should NOT match :focus-visible as it does NOT support keyboard input] - expected: - if os == "mac": NOTRUN - diff --git a/testing/web-platform/meta/css/selectors/focus-visible-004.html.ini b/testing/web-platform/meta/css/selectors/focus-visible-004.html.ini deleted file mode 100644 index 788a09c80d0f7..0000000000000 --- a/testing/web-platform/meta/css/selectors/focus-visible-004.html.ini +++ /dev/null @@ -1,31 +0,0 @@ -[focus-visible-004.html] - expected: - if os == "mac": TIMEOUT - [Focus element BUTTON#el-4 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"] - expected: - if os == "mac": TIMEOUT - - [Focus element INPUT#el-5 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"] - expected: - if os == "mac": NOTRUN - - [Focus element INPUT#el-6 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"] - expected: - if os == "mac": NOTRUN - - [Focus element INPUT#el-7 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"] - expected: - if os == "mac": NOTRUN - - [Focus element INPUT#el-8 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"] - expected: - if os == "mac": NOTRUN - - [Focus element INPUT#el-10 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"] - expected: - if os == "mac": NOTRUN - - [Focus element INPUT#el-11 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"] - expected: - if os == "mac": NOTRUN -