browser_bug731866.js (3931B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 const browserContainersGroupDisabled = !SpecialPowers.getBoolPref( 5 "privacy.userContext.ui.enabled" 6 ); 7 const cookieBannerHandlingDisabled = !SpecialPowers.getBoolPref( 8 "cookiebanners.ui.desktop.enabled" 9 ); 10 const backupSectionDisabled = !( 11 SpecialPowers.getBoolPref("browser.backup.archive.enabled") || 12 SpecialPowers.getBoolPref("browser.backup.restore.enabled") 13 ); 14 const ipProtectionEnabled = SpecialPowers.getBoolPref( 15 "browser.ipProtection.enabled", 16 false 17 ); 18 const profilesGroupDisabled = !SelectableProfileService.isEnabled; 19 const updatePrefContainers = ["updatesCategory", "updateApp"]; 20 const updateContainersGroupDisabled = 21 AppConstants.platform === "win" && 22 Services.sysinfo.getProperty("hasWinPackageId"); 23 24 function test() { 25 waitForExplicitFinish(); 26 open_preferences(runTest); 27 } 28 29 var gElements; 30 31 function checkElements(expectedPane) { 32 for (let element of gElements) { 33 // keyset elements fail is_element_visible checks because they are never visible. 34 // special-case the drmGroup item because its visibility depends on pref + OS version 35 if (element.nodeName == "keyset" || element.id === "drmGroup") { 36 continue; 37 } 38 39 // The browserContainersGroup is still only pref-on on Nightly 40 if ( 41 element.id == "browserContainersGroup" && 42 browserContainersGroupDisabled 43 ) { 44 is_element_hidden( 45 element, 46 "Disabled browserContainersGroup should be hidden" 47 ); 48 continue; 49 } 50 51 // Cookie Banner Handling is currently disabled by default (bug 1800679) 52 if ( 53 element.id == "cookieBannerHandlingGroup" && 54 cookieBannerHandlingDisabled 55 ) { 56 is_element_hidden( 57 element, 58 "Disabled cookieBannerHandlingGroup should be hidden" 59 ); 60 continue; 61 } 62 63 // Update prefs are hidden when running an MSIX build 64 if ( 65 updatePrefContainers.includes(element.id) && 66 updateContainersGroupDisabled 67 ) { 68 is_element_hidden(element, "Disabled " + element + " should be hidden"); 69 continue; 70 } 71 72 // Backup is currently disabled by default. (bug 1895791) 73 if ( 74 (element.id == "dataBackupGroup" || element.id == "backupCategory") && 75 backupSectionDisabled 76 ) { 77 is_element_hidden(element, "Disabled dataBackupSection should be hidden"); 78 continue; 79 } 80 81 // Profiles is only enabled in Nightly by default (bug 1947633) 82 if (element.id === "profilesGroup" && profilesGroupDisabled) { 83 is_element_hidden(element, "Disabled profilesGroup should be hidden"); 84 continue; 85 } 86 87 // IP Protection section is gated by browser.ipProtection.enabled 88 if (element.id === "dataIPProtectionGroup" && !ipProtectionEnabled) { 89 is_element_hidden(element, "Disabled ipProtection should be hidden"); 90 continue; 91 } 92 93 if (element.getAttribute("data-hidden-from-search") == "true") { 94 is_element_hidden(element, "Hidden from search element should be hidden"); 95 continue; 96 } 97 98 let attributeValue = element.getAttribute("data-category"); 99 let suffix = " (id=" + element.id + ")"; 100 if (attributeValue == "pane" + expectedPane) { 101 is_element_visible( 102 element, 103 expectedPane + " elements should be visible" + suffix 104 ); 105 } else { 106 is_element_hidden( 107 element, 108 "Elements not in " + expectedPane + " should be hidden" + suffix 109 ); 110 } 111 } 112 } 113 114 async function runTest(win) { 115 is(gBrowser.currentURI.spec, "about:preferences", "about:preferences loaded"); 116 117 let tab = win.document; 118 gElements = tab.getElementById("mainPrefPane").children; 119 120 let panes = ["General", "Search", "Privacy", "Sync"]; 121 122 for (let pane of panes) { 123 await win.gotoPref("pane" + pane); 124 checkElements(pane); 125 } 126 127 gBrowser.removeCurrentTab(); 128 win.close(); 129 finish(); 130 }