Bug 1628476: Add keyboard navigation pref to allow focus mode changes on macOS r=Jamie,fluent-reviewers,settings-reviewers,flod,mconley
Differential Revision: https://phabricator.services.mozilla.com/D182266
This commit is contained in:
@@ -724,6 +724,11 @@
|
|||||||
<checkbox id="useCursorNavigation"
|
<checkbox id="useCursorNavigation"
|
||||||
data-l10n-id="browsing-use-cursor-navigation"
|
data-l10n-id="browsing-use-cursor-navigation"
|
||||||
preference="accessibility.browsewithcaret"/>
|
preference="accessibility.browsewithcaret"/>
|
||||||
|
#ifdef XP_MACOSX
|
||||||
|
<checkbox id="useFullKeyboardNavigation"
|
||||||
|
data-l10n-id="browsing-use-full-keyboard-navigation"
|
||||||
|
preference="accessibility.tabfocus" />
|
||||||
|
#endif
|
||||||
<checkbox id="searchStartTyping"
|
<checkbox id="searchStartTyping"
|
||||||
data-l10n-id="browsing-search-on-start-typing"
|
data-l10n-id="browsing-search-on-start-typing"
|
||||||
preference="accessibility.typeaheadfind"/>
|
preference="accessibility.typeaheadfind"/>
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ Preferences.addAll([
|
|||||||
{ id: "general.smoothScroll", type: "bool" },
|
{ id: "general.smoothScroll", type: "bool" },
|
||||||
{ id: "widget.gtk.overlay-scrollbars.enabled", type: "bool", inverted: true },
|
{ id: "widget.gtk.overlay-scrollbars.enabled", type: "bool", inverted: true },
|
||||||
{ id: "layout.spellcheckDefault", type: "int" },
|
{ id: "layout.spellcheckDefault", type: "int" },
|
||||||
|
{ id: "accessibility.tabfocus", type: "int" },
|
||||||
|
|
||||||
{
|
{
|
||||||
id: "browser.preferences.defaultPerformanceSettings.enabled",
|
id: "browser.preferences.defaultPerformanceSettings.enabled",
|
||||||
@@ -725,6 +726,14 @@ var gMainPane = {
|
|||||||
document.getElementById("defaultFont"),
|
document.getElementById("defaultFont"),
|
||||||
element => FontBuilder.readFontSelection(element)
|
element => FontBuilder.readFontSelection(element)
|
||||||
);
|
);
|
||||||
|
Preferences.addSyncFromPrefListener(
|
||||||
|
document.getElementById("useFullKeyboardNavigation"),
|
||||||
|
() => this.readUseFullKeyboardNavigation()
|
||||||
|
);
|
||||||
|
Preferences.addSyncToPrefListener(
|
||||||
|
document.getElementById("useFullKeyboardNavigation"),
|
||||||
|
() => this.writeUseFullKeyboardNavigation()
|
||||||
|
);
|
||||||
Preferences.addSyncFromPrefListener(
|
Preferences.addSyncFromPrefListener(
|
||||||
document.getElementById("checkSpelling"),
|
document.getElementById("checkSpelling"),
|
||||||
() => this.readCheckSpelling()
|
() => this.readCheckSpelling()
|
||||||
@@ -2181,6 +2190,50 @@ var gMainPane = {
|
|||||||
migrationWizardDialog.showModal();
|
migrationWizardDialog.showModal();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the original value of the tabfocus preference to enable proper
|
||||||
|
* restoration if unchanged (since we're mapping an int pref onto a checkbox).
|
||||||
|
*/
|
||||||
|
_storedFullKeyboardNavigation: Preferences.get("accessibility.tabfocus"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if any full keyboard nav is enabled and false otherwise, caching
|
||||||
|
* the current value to enable proper pref restoration if the checkbox is
|
||||||
|
* never changed.
|
||||||
|
*
|
||||||
|
* accessibility.tabfocus
|
||||||
|
* - an integer controlling the focusability of:
|
||||||
|
* 1 text controls
|
||||||
|
* 2 form elements
|
||||||
|
* 4 links
|
||||||
|
* 7 all of the above
|
||||||
|
*/
|
||||||
|
readUseFullKeyboardNavigation() {
|
||||||
|
var pref = Preferences.get("accessibility.tabfocus");
|
||||||
|
this._storedFullKeyboardNavigation = pref.value;
|
||||||
|
|
||||||
|
return pref.value == 7;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the full keyboard nav preference represented by UI,
|
||||||
|
* preserving the preference's "hidden" value if the preference is
|
||||||
|
* unchanged and represents a value not strictly allowed in UI.
|
||||||
|
*/
|
||||||
|
writeUseFullKeyboardNavigation() {
|
||||||
|
var checkbox = document.getElementById("useFullKeyboardNavigation");
|
||||||
|
if (checkbox.checked) {
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
if (this._storedFullKeyboardNavigation != 7) {
|
||||||
|
// 1/2/4 values set via about:config should persist
|
||||||
|
return this._storedFullKeyboardNavigation;
|
||||||
|
}
|
||||||
|
// When the checkbox is unchecked, this pref shouldn't exist
|
||||||
|
// at all.
|
||||||
|
return undefined;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the original value of the spellchecking preference to enable proper
|
* Stores the original value of the spellchecking preference to enable proper
|
||||||
* restoration if unchanged (since we're mapping a tristate onto a checkbox).
|
* restoration if unchanged (since we're mapping a tristate onto a checkbox).
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ https_first_disabled = true
|
|||||||
[browser_https_only_exceptions.js]
|
[browser_https_only_exceptions.js]
|
||||||
[browser_https_only_section.js]
|
[browser_https_only_section.js]
|
||||||
[browser_ignore_invalid_capability.js]
|
[browser_ignore_invalid_capability.js]
|
||||||
|
[browser_keyboardfocus.js]
|
||||||
|
skip-if = os != "mac"
|
||||||
[browser_languages_subdialog.js]
|
[browser_languages_subdialog.js]
|
||||||
[browser_layersacceleration.js]
|
[browser_layersacceleration.js]
|
||||||
[browser_localSearchShortcuts.js]
|
[browser_localSearchShortcuts.js]
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
async function launchPreferences() {
|
||||||
|
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", {
|
||||||
|
leaveOpen: true,
|
||||||
|
});
|
||||||
|
Assert.equal(prefs.selectedPane, "paneGeneral", "General pane was selected");
|
||||||
|
}
|
||||||
|
|
||||||
|
add_task(async function () {
|
||||||
|
await launchPreferences();
|
||||||
|
let checkbox = gBrowser.contentDocument.querySelector(
|
||||||
|
"#useFullKeyboardNavigation"
|
||||||
|
);
|
||||||
|
Assert.ok(
|
||||||
|
!Services.prefs.getIntPref("accessibility.tabfocus", undefined),
|
||||||
|
"no pref value should exist"
|
||||||
|
);
|
||||||
|
Assert.ok(
|
||||||
|
!checkbox.checked,
|
||||||
|
"checkbox should be unchecked before clicking on checkbox"
|
||||||
|
);
|
||||||
|
|
||||||
|
checkbox.click();
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getIntPref("accessibility.tabfocus"),
|
||||||
|
7,
|
||||||
|
"Prefstore should reflect checkbox's associated numeric value"
|
||||||
|
);
|
||||||
|
Assert.ok(
|
||||||
|
checkbox.checked,
|
||||||
|
"checkbox should be checked after clicking on checkbox"
|
||||||
|
);
|
||||||
|
|
||||||
|
checkbox.click();
|
||||||
|
|
||||||
|
Assert.ok(
|
||||||
|
!checkbox.checked,
|
||||||
|
"checkbox should be unchecked after clicking on checkbox"
|
||||||
|
);
|
||||||
|
Assert.ok(
|
||||||
|
!Services.prefs.getIntPref("accessibility.tabfocus", undefined),
|
||||||
|
"No pref value should exist"
|
||||||
|
);
|
||||||
|
|
||||||
|
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||||
|
SpecialPowers.pushPrefEnv({ set: [["accessibility.tabfocus", 4]] });
|
||||||
|
await launchPreferences();
|
||||||
|
checkbox = gBrowser.contentDocument.querySelector(
|
||||||
|
"#useFullKeyboardNavigation"
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.ok(
|
||||||
|
!checkbox.checked,
|
||||||
|
"checkbox should stay unchecked after setting non-7 pref value"
|
||||||
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getIntPref("accessibility.tabfocus", 0),
|
||||||
|
4,
|
||||||
|
"pref should have value in store"
|
||||||
|
);
|
||||||
|
|
||||||
|
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||||
|
SpecialPowers.pushPrefEnv({ set: [["accessibility.tabfocus", 7]] });
|
||||||
|
await launchPreferences();
|
||||||
|
checkbox = gBrowser.contentDocument.querySelector(
|
||||||
|
"#useFullKeyboardNavigation"
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getIntPref("accessibility.tabfocus", 0),
|
||||||
|
7,
|
||||||
|
"Pref value should update after modification"
|
||||||
|
);
|
||||||
|
Assert.ok(checkbox.checked, "checkbox should be checked");
|
||||||
|
|
||||||
|
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||||
|
});
|
||||||
@@ -583,6 +583,10 @@ browsing-use-cursor-navigation =
|
|||||||
.label = Always use the cursor keys to navigate within pages
|
.label = Always use the cursor keys to navigate within pages
|
||||||
.accesskey = k
|
.accesskey = k
|
||||||
|
|
||||||
|
browsing-use-full-keyboard-navigation =
|
||||||
|
.label = Use the tab key to move focus between form controls and links
|
||||||
|
.accesskey = t
|
||||||
|
|
||||||
browsing-search-on-start-typing =
|
browsing-search-on-start-typing =
|
||||||
.label = Search for text when you start typing
|
.label = Search for text when you start typing
|
||||||
.accesskey = x
|
.accesskey = x
|
||||||
|
|||||||
Reference in New Issue
Block a user