browser_performance.js (6779B)
1 const DEFAULT_HW_ACCEL_PREF = Services.prefs 2 .getDefaultBranch(null) 3 .getBoolPref("layers.acceleration.disabled"); 4 const DEFAULT_PROCESS_COUNT = Services.prefs 5 .getDefaultBranch(null) 6 .getIntPref("dom.ipc.processCount"); 7 8 add_task(async function () { 9 // We must temporarily disable `Once` StaticPrefs check for the duration of 10 // this test (see bug 1556131). We must do so in a separate operation as 11 // pushPrefEnv doesn't set the preferences in the order one could expect. 12 await SpecialPowers.pushPrefEnv({ 13 set: [["preferences.force-disable.check.once.policy", true]], 14 }); 15 await SpecialPowers.pushPrefEnv({ 16 set: [ 17 ["layers.acceleration.disabled", DEFAULT_HW_ACCEL_PREF], 18 ["dom.ipc.processCount", DEFAULT_PROCESS_COUNT], 19 ["browser.preferences.defaultPerformanceSettings.enabled", true], 20 ], 21 }); 22 }); 23 24 add_task(async function () { 25 let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", { 26 leaveOpen: true, 27 }); 28 is(prefs.selectedPane, "paneGeneral", "General pane was selected"); 29 30 let doc = gBrowser.contentDocument; 31 let useRecommendedPerformanceSettings = doc.querySelector( 32 "#useRecommendedPerformanceSettings" 33 ); 34 let allowHWAccel = doc.querySelector("#allowHWAccel"); 35 36 is( 37 Services.prefs.getBoolPref( 38 "browser.preferences.defaultPerformanceSettings.enabled" 39 ), 40 true, 41 "pref value should be true before clicking on checkbox" 42 ); 43 ok( 44 useRecommendedPerformanceSettings.checked, 45 "checkbox should be checked before clicking on checkbox" 46 ); 47 48 useRecommendedPerformanceSettings.click(); 49 await allowHWAccel.updateComplete; 50 51 ok(BrowserTestUtils.isVisible(allowHWAccel), "allowHWAccel setting is shown"); 52 53 is( 54 Services.prefs.getBoolPref( 55 "browser.preferences.defaultPerformanceSettings.enabled" 56 ), 57 false, 58 "pref value should be false after clicking on checkbox" 59 ); 60 ok( 61 !useRecommendedPerformanceSettings.checked, 62 "checkbox should not be checked after clicking on checkbox" 63 ); 64 65 let allowHWAccelPref = Services.prefs.getBoolPref( 66 "layers.acceleration.disabled" 67 ); 68 is( 69 allowHWAccelPref, 70 DEFAULT_HW_ACCEL_PREF, 71 "pref value should be the default value before clicking on checkbox" 72 ); 73 is( 74 allowHWAccel.checked, 75 !DEFAULT_HW_ACCEL_PREF, 76 "checkbox should show the invert of the default value" 77 ); 78 79 allowHWAccel.click(); 80 allowHWAccelPref = Services.prefs.getBoolPref("layers.acceleration.disabled"); 81 is( 82 allowHWAccelPref, 83 !DEFAULT_HW_ACCEL_PREF, 84 "pref value should be opposite of the default value after clicking on checkbox" 85 ); 86 is( 87 allowHWAccel.checked, 88 !allowHWAccelPref, 89 "checkbox should show the invert of the current value" 90 ); 91 92 allowHWAccel.click(); 93 allowHWAccelPref = Services.prefs.getBoolPref("layers.acceleration.disabled"); 94 is( 95 allowHWAccelPref, 96 DEFAULT_HW_ACCEL_PREF, 97 "pref value should be the default value after clicking on checkbox" 98 ); 99 is( 100 allowHWAccel.checked, 101 !allowHWAccelPref, 102 "checkbox should show the invert of the current value" 103 ); 104 105 ok( 106 BrowserTestUtils.isVisible(allowHWAccel), 107 "allowHWAccel setting should be still shown" 108 ); 109 110 Services.prefs.setBoolPref( 111 "browser.preferences.defaultPerformanceSettings.enabled", 112 true 113 ); 114 BrowserTestUtils.removeTab(gBrowser.selectedTab); 115 }); 116 117 add_task(async function () { 118 let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", { 119 leaveOpen: true, 120 }); 121 is(prefs.selectedPane, "paneGeneral", "General pane was selected"); 122 123 let doc = gBrowser.contentDocument; 124 let useRecommendedPerformanceSettings = doc.querySelector( 125 "#useRecommendedPerformanceSettings" 126 ); 127 let allowHWAccel = doc.querySelector("#allowHWAccel"); 128 129 useRecommendedPerformanceSettings.click(); 130 131 await allowHWAccel.updateComplete; 132 allowHWAccel.click(); 133 134 useRecommendedPerformanceSettings.click(); 135 await allowHWAccel.updateComplete; 136 137 is( 138 Services.prefs.getBoolPref( 139 "browser.preferences.defaultPerformanceSettings.enabled" 140 ), 141 true, 142 "pref value should be true before clicking on checkbox" 143 ); 144 ok( 145 useRecommendedPerformanceSettings.checked, 146 "checkbox should be checked before clicking on checkbox" 147 ); 148 ok( 149 !BrowserTestUtils.isVisible(allowHWAccel), 150 "allowHWAccel setting should not be shown" 151 ); 152 153 Services.prefs.setBoolPref( 154 "browser.preferences.defaultPerformanceSettings.enabled", 155 true 156 ); 157 BrowserTestUtils.removeTab(gBrowser.selectedTab); 158 }); 159 160 add_task(async function () { 161 let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", { 162 leaveOpen: true, 163 }); 164 is(prefs.selectedPane, "paneGeneral", "General pane was selected"); 165 166 let doc = gBrowser.contentDocument; 167 let allowHWAccel = doc.querySelector("#allowHWAccel"); 168 169 ok( 170 !BrowserTestUtils.isVisible(allowHWAccel), 171 "allowHWAccel setting should not be shown" 172 ); 173 174 Services.prefs.setBoolPref( 175 "browser.preferences.defaultPerformanceSettings.enabled", 176 false 177 ); 178 await allowHWAccel.updateComplete; 179 180 ok( 181 BrowserTestUtils.isVisible(allowHWAccel), 182 "allowHWAccel setting should be shown" 183 ); 184 185 Services.prefs.setBoolPref( 186 "browser.preferences.defaultPerformanceSettings.enabled", 187 true 188 ); 189 BrowserTestUtils.removeTab(gBrowser.selectedTab); 190 }); 191 192 add_task(async function () { 193 Services.prefs.setIntPref("dom.ipc.processCount", 7); 194 195 let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", { 196 leaveOpen: true, 197 }); 198 is(prefs.selectedPane, "paneGeneral", "General pane was selected"); 199 200 let doc = gBrowser.contentDocument; 201 202 let allowHWAccel = doc.querySelector("#allowHWAccel"); 203 ok( 204 BrowserTestUtils.isVisible(allowHWAccel), 205 "allowHWAccel setting should be shown" 206 ); 207 208 Services.prefs.setBoolPref( 209 "browser.preferences.defaultPerformanceSettings.enabled", 210 true 211 ); 212 BrowserTestUtils.removeTab(gBrowser.selectedTab); 213 }); 214 215 add_task(async function () { 216 Services.prefs.setBoolPref("layers.acceleration.disabled", true); 217 218 let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", { 219 leaveOpen: true, 220 }); 221 is(prefs.selectedPane, "paneGeneral", "General pane was selected"); 222 223 let doc = gBrowser.contentDocument; 224 225 let allowHWAccel = doc.querySelector("#allowHWAccel"); 226 ok( 227 BrowserTestUtils.isVisible(allowHWAccel), 228 "allowHWAccel setting should be shown" 229 ); 230 231 is( 232 Services.prefs.getBoolPref("layers.acceleration.disabled"), 233 true, 234 "pref value is false" 235 ); 236 ok(!allowHWAccel.checked, "checkbox should not be checked"); 237 238 Services.prefs.setBoolPref( 239 "browser.preferences.defaultPerformanceSettings.enabled", 240 true 241 ); 242 BrowserTestUtils.removeTab(gBrowser.selectedTab); 243 });