browser_keyboardfocus.js (2220B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 async function launchPreferences() { 5 let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", { 6 leaveOpen: true, 7 }); 8 Assert.equal(prefs.selectedPane, "paneGeneral", "General pane was selected"); 9 } 10 11 add_task(async function () { 12 await launchPreferences(); 13 let checkbox = gBrowser.contentDocument.querySelector( 14 "#useFullKeyboardNavigation" 15 ); 16 Assert.equal( 17 Services.prefs.getIntPref("accessibility.tabfocus"), 18 7, 19 "default should be full keyboard access" 20 ); 21 Assert.ok( 22 checkbox.checked, 23 "checkbox should be checked before clicking on checkbox" 24 ); 25 26 checkbox.click(); 27 28 Assert.equal( 29 Services.prefs.getIntPref("accessibility.tabfocus"), 30 1, 31 "Prefstore should reflect checkbox's associated numeric value" 32 ); 33 Assert.ok( 34 !checkbox.checked, 35 "checkbox should be unchecked after clicking on checkbox" 36 ); 37 38 checkbox.click(); 39 40 Assert.ok( 41 checkbox.checked, 42 "checkbox should be checked after clicking on checkbox" 43 ); 44 Assert.equal( 45 Services.prefs.getIntPref("accessibility.tabfocus"), 46 7, 47 "Should restore default value" 48 ); 49 50 BrowserTestUtils.removeTab(gBrowser.selectedTab); 51 await SpecialPowers.pushPrefEnv({ set: [["accessibility.tabfocus", 4]] }); 52 await launchPreferences(); 53 checkbox = gBrowser.contentDocument.querySelector( 54 "#useFullKeyboardNavigation" 55 ); 56 57 Assert.ok( 58 !checkbox.checked, 59 "checkbox should stay unchecked after setting non-7 pref value" 60 ); 61 Assert.equal( 62 Services.prefs.getIntPref("accessibility.tabfocus"), 63 4, 64 "pref should have value in store" 65 ); 66 67 BrowserTestUtils.removeTab(gBrowser.selectedTab); 68 await SpecialPowers.pushPrefEnv({ set: [["accessibility.tabfocus", 7]] }); 69 await launchPreferences(); 70 checkbox = gBrowser.contentDocument.querySelector( 71 "#useFullKeyboardNavigation" 72 ); 73 74 Assert.equal( 75 Services.prefs.getIntPref("accessibility.tabfocus"), 76 7, 77 "Pref value should update after modification" 78 ); 79 Assert.ok(checkbox.checked, "checkbox should be checked"); 80 81 BrowserTestUtils.removeTab(gBrowser.selectedTab); 82 });