diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/components/preferences/tests/browser_keyboardfocus.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/preferences/tests/browser_keyboardfocus.js')
-rw-r--r-- | browser/components/preferences/tests/browser_keyboardfocus.js | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/browser/components/preferences/tests/browser_keyboardfocus.js b/browser/components/preferences/tests/browser_keyboardfocus.js new file mode 100644 index 0000000000..bed452b679 --- /dev/null +++ b/browser/components/preferences/tests/browser_keyboardfocus.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); +}); |