Bug 1384962 - Don't set process count for user on Preferences page load, r=jaws

This is a follow-up to incomplete fix in bug 1382649. In that bug, I attempted to
set the process count value to the e10s rollout value, when the user unchecks
"Use default performance settings". The same function updatePerformanceSettingsBox()
is actually run during page load, resulting the user set value being changed to
e10s rollout value if the user decided to use the default process count.

Tests are written for both patches.

MozReview-Commit-ID: 4CLLcEKbS58

--HG--
extra : rebase_source : 15d2082612415363e0f69a1880efb702adcece24
extra : source : 5f81b547cd433d1a9056e5fe144ba56b13f15cc1
This commit is contained in:
Timothy Guan-tin Chien 2017-07-27 23:41:31 +08:00
Родитель 8939798d4b
Коммит c3f031892f
4 изменённых файлов: 194 добавлений и 8 удалений

Просмотреть файл

@ -192,9 +192,9 @@ var gMainPane = {
let defaultPerformancePref =
document.getElementById("browser.preferences.defaultPerformanceSettings.enabled");
defaultPerformancePref.addEventListener("change", () => {
this.updatePerformanceSettingsBox();
this.updatePerformanceSettingsBox({duringChangeEvent: true});
});
this.updatePerformanceSettingsBox();
this.updatePerformanceSettingsBox({duringChangeEvent: false});
// set up the "use current page" label-changing listener
this._updateUseCurrentButton();
@ -1114,7 +1114,7 @@ var gMainPane = {
}
},
updatePerformanceSettingsBox() {
updatePerformanceSettingsBox({duringChangeEvent}) {
let defaultPerformancePref =
document.getElementById("browser.preferences.defaultPerformanceSettings.enabled");
let performanceSettings = document.getElementById("performanceSettings");
@ -1130,7 +1130,8 @@ var gMainPane = {
document.getElementById("dom.ipc.processCount.web");
// Take the e10s rollout value as the default value (if it exists),
// but don't overwrite the user set value.
if (e10sRolloutProcessCountPref.value &&
if (duringChangeEvent &&
e10sRolloutProcessCountPref.value &&
processCountPref.value == processCountPref.defaultValue) {
processCountPref.value = e10sRolloutProcessCountPref.value;
}

Просмотреть файл

@ -135,6 +135,98 @@ add_task(async function() {
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
add_task(async function() {
Services.prefs.clearUserPref("dom.ipc.processCount");
Services.prefs.setIntPref("dom.ipc.processCount.web", DEFAULT_PROCESS_COUNT + 1);
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.contentDocument;
let useRecommendedPerformanceSettings = doc.querySelector("#useRecommendedPerformanceSettings");
is(Services.prefs.getBoolPref("browser.preferences.defaultPerformanceSettings.enabled"), true,
"pref value should be true before clicking on checkbox");
ok(useRecommendedPerformanceSettings.checked, "checkbox should be checked before clicking on checkbox");
useRecommendedPerformanceSettings.click();
let performanceSettings = doc.querySelector("#performanceSettings");
is(performanceSettings.hidden, false, "performance settings section is shown");
is(Services.prefs.getBoolPref("browser.preferences.defaultPerformanceSettings.enabled"), false,
"pref value should be false after clicking on checkbox");
ok(!useRecommendedPerformanceSettings.checked, "checkbox should not be checked after clicking on checkbox");
let contentProcessCount = doc.querySelector("#contentProcessCount");
is(contentProcessCount.disabled, false, "process count control should be enabled");
is(Services.prefs.getIntPref("dom.ipc.processCount"), DEFAULT_PROCESS_COUNT + 1, "e10s rollout value should be default value");
is(contentProcessCount.selectedItem.value, DEFAULT_PROCESS_COUNT + 1, "selected item should be the default one");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
Services.prefs.clearUserPref("dom.ipc.processCount");
Services.prefs.clearUserPref("dom.ipc.processCount.web");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
});
add_task(async function() {
Services.prefs.clearUserPref("dom.ipc.processCount");
Services.prefs.setIntPref("dom.ipc.processCount.web", DEFAULT_PROCESS_COUNT + 1);
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", false);
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.contentDocument;
let performanceSettings = doc.querySelector("#performanceSettings");
is(performanceSettings.hidden, false, "performance settings section is shown");
let contentProcessCount = doc.querySelector("#contentProcessCount");
is(contentProcessCount.disabled, false, "process count control should be enabled");
is(Services.prefs.getIntPref("dom.ipc.processCount"), DEFAULT_PROCESS_COUNT, "default value should be the current value");
is(contentProcessCount.selectedItem.value, DEFAULT_PROCESS_COUNT, "selected item should be the default one");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
Services.prefs.clearUserPref("dom.ipc.processCount");
Services.prefs.clearUserPref("dom.ipc.processCount.web");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
});
add_task(async function() {
Services.prefs.setIntPref("dom.ipc.processCount", DEFAULT_PROCESS_COUNT + 2);
Services.prefs.setIntPref("dom.ipc.processCount.web", DEFAULT_PROCESS_COUNT + 1);
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", false);
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.contentDocument;
let performanceSettings = doc.querySelector("#performanceSettings");
is(performanceSettings.hidden, false, "performance settings section is shown");
let contentProcessCount = doc.querySelector("#contentProcessCount");
is(contentProcessCount.disabled, false, "process count control should be enabled");
is(Services.prefs.getIntPref("dom.ipc.processCount"), DEFAULT_PROCESS_COUNT + 2, "process count should be the set value");
is(contentProcessCount.selectedItem.value, DEFAULT_PROCESS_COUNT + 2, "selected item should be the set one");
let useRecommendedPerformanceSettings = doc.querySelector("#useRecommendedPerformanceSettings");
useRecommendedPerformanceSettings.click();
is(Services.prefs.getBoolPref("browser.preferences.defaultPerformanceSettings.enabled"), true,
"pref value should be true after clicking on checkbox");
is(Services.prefs.getIntPref("dom.ipc.processCount"), DEFAULT_PROCESS_COUNT,
"process count should be default value");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
Services.prefs.clearUserPref("dom.ipc.processCount");
Services.prefs.clearUserPref("dom.ipc.processCount.web");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
});
add_task(async function() {
Services.prefs.setBoolPref("layers.acceleration.disabled", true);

Просмотреть файл

@ -50,9 +50,9 @@ var gMainPane = {
let defaultPerformancePref =
document.getElementById("browser.preferences.defaultPerformanceSettings.enabled");
defaultPerformancePref.addEventListener("change", () => {
this.updatePerformanceSettingsBox();
this.updatePerformanceSettingsBox({duringChangeEvent: true});
});
this.updatePerformanceSettingsBox();
this.updatePerformanceSettingsBox({duringChangeEvent: false});
let performanceSettingsLink = document.getElementById("performanceSettingsLearnMore");
let performanceSettingsUrl = Services.urlFormatter.formatURLPref("app.support.baseURL") + "performance";
@ -425,7 +425,7 @@ var gMainPane = {
}
},
updatePerformanceSettingsBox() {
updatePerformanceSettingsBox({duringChangeEvent}) {
let defaultPerformancePref =
document.getElementById("browser.preferences.defaultPerformanceSettings.enabled");
let performanceSettings = document.getElementById("performanceSettings");
@ -441,7 +441,8 @@ var gMainPane = {
document.getElementById("dom.ipc.processCount.web");
// Take the e10s rollout value as the default value (if it exists),
// but don't overwrite the user set value.
if (e10sRolloutProcessCountPref.value &&
if (duringChangeEvent &&
e10sRolloutProcessCountPref.value &&
processCountPref.value == processCountPref.defaultValue) {
processCountPref.value = e10sRolloutProcessCountPref.value;
}

Просмотреть файл

@ -135,6 +135,98 @@ add_task(async function() {
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
add_task(async function() {
Services.prefs.clearUserPref("dom.ipc.processCount");
Services.prefs.setIntPref("dom.ipc.processCount.web", DEFAULT_PROCESS_COUNT + 1);
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.selectedBrowser.contentDocument;
let useRecommendedPerformanceSettings = doc.querySelector("#useRecommendedPerformanceSettings");
is(Services.prefs.getBoolPref("browser.preferences.defaultPerformanceSettings.enabled"), true,
"pref value should be true before clicking on checkbox");
ok(useRecommendedPerformanceSettings.checked, "checkbox should be checked before clicking on checkbox");
useRecommendedPerformanceSettings.click();
let performanceSettings = doc.querySelector("#performanceSettings");
is(performanceSettings.hidden, false, "performance settings section is shown");
is(Services.prefs.getBoolPref("browser.preferences.defaultPerformanceSettings.enabled"), false,
"pref value should be false after clicking on checkbox");
ok(!useRecommendedPerformanceSettings.checked, "checkbox should not be checked after clicking on checkbox");
let contentProcessCount = doc.querySelector("#contentProcessCount");
is(contentProcessCount.disabled, false, "process count control should be enabled");
is(Services.prefs.getIntPref("dom.ipc.processCount"), DEFAULT_PROCESS_COUNT + 1, "e10s rollout value should be default value");
is(contentProcessCount.selectedItem.value, DEFAULT_PROCESS_COUNT + 1, "selected item should be the default one");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
Services.prefs.clearUserPref("dom.ipc.processCount");
Services.prefs.clearUserPref("dom.ipc.processCount.web");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
});
add_task(async function() {
Services.prefs.clearUserPref("dom.ipc.processCount");
Services.prefs.setIntPref("dom.ipc.processCount.web", DEFAULT_PROCESS_COUNT + 1);
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", false);
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.selectedBrowser.contentDocument;
let performanceSettings = doc.querySelector("#performanceSettings");
is(performanceSettings.hidden, false, "performance settings section is shown");
let contentProcessCount = doc.querySelector("#contentProcessCount");
is(contentProcessCount.disabled, false, "process count control should be enabled");
is(Services.prefs.getIntPref("dom.ipc.processCount"), DEFAULT_PROCESS_COUNT, "default value should be the current value");
is(contentProcessCount.selectedItem.value, DEFAULT_PROCESS_COUNT, "selected item should be the default one");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
Services.prefs.clearUserPref("dom.ipc.processCount");
Services.prefs.clearUserPref("dom.ipc.processCount.web");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
});
add_task(async function() {
Services.prefs.setIntPref("dom.ipc.processCount", DEFAULT_PROCESS_COUNT + 2);
Services.prefs.setIntPref("dom.ipc.processCount.web", DEFAULT_PROCESS_COUNT + 1);
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", false);
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.selectedBrowser.contentDocument;
let performanceSettings = doc.querySelector("#performanceSettings");
is(performanceSettings.hidden, false, "performance settings section is shown");
let contentProcessCount = doc.querySelector("#contentProcessCount");
is(contentProcessCount.disabled, false, "process count control should be enabled");
is(Services.prefs.getIntPref("dom.ipc.processCount"), DEFAULT_PROCESS_COUNT + 2, "process count should be the set value");
is(contentProcessCount.selectedItem.value, DEFAULT_PROCESS_COUNT + 2, "selected item should be the set one");
let useRecommendedPerformanceSettings = doc.querySelector("#useRecommendedPerformanceSettings");
useRecommendedPerformanceSettings.click();
is(Services.prefs.getBoolPref("browser.preferences.defaultPerformanceSettings.enabled"), true,
"pref value should be true after clicking on checkbox");
is(Services.prefs.getIntPref("dom.ipc.processCount"), DEFAULT_PROCESS_COUNT,
"process count should be default value");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
Services.prefs.clearUserPref("dom.ipc.processCount");
Services.prefs.clearUserPref("dom.ipc.processCount.web");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
});
add_task(async function() {
Services.prefs.setBoolPref("layers.acceleration.disabled", true);