Bug 1384962 - Don't set process count for user on Preferences page load, r=jaws
☠☠ backed out by 09a412e3cc3b ☠ ☠
authorTimothy Guan-tin Chien <timdream@gmail.com>
Thu, 27 Jul 2017 23:41:31 +0800
changeset 422653 9bba40accbf61384715d963df18e05227676591f
parent 422652 847e0a72b2766a90ced8727574c27f596ca29872
child 422654 6d372311a32e5cb4dc24f93cdac71dc1cd2ae9b2
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1384962, 1382649
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
browser/components/preferences/in-content-new/main.js
browser/components/preferences/in-content-new/tests/browser_performance.js
browser/components/preferences/in-content/main.js
browser/components/preferences/in-content/tests/browser_performance.js
--- a/browser/components/preferences/in-content-new/main.js
+++ b/browser/components/preferences/in-content-new/main.js
@@ -187,19 +187,19 @@ var gMainPane = {
     let performanceSettingsUrl = Services.urlFormatter.formatURLPref("app.support.baseURL") + "performance";
     performanceSettingsLink.setAttribute("href", performanceSettingsUrl);
 
     this.updateDefaultPerformanceSettingsPref();
 
     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();
     window.addEventListener("focus", this._updateUseCurrentButton.bind(this));
 
     this.updateBrowserStartupLastSession();
 
     if (AppConstants.platform == "win") {
@@ -1109,33 +1109,34 @@ var gMainPane = {
     let processCountPref = document.getElementById("dom.ipc.processCount");
     let accelerationPref = document.getElementById("layers.acceleration.disabled");
     if (processCountPref.value != processCountPref.defaultValue ||
         accelerationPref.value != accelerationPref.defaultValue) {
       defaultPerformancePref.value = false;
     }
   },
 
-  updatePerformanceSettingsBox() {
+  updatePerformanceSettingsBox({duringChangeEvent}) {
     let defaultPerformancePref =
       document.getElementById("browser.preferences.defaultPerformanceSettings.enabled");
     let performanceSettings = document.getElementById("performanceSettings");
     let processCountPref = document.getElementById("dom.ipc.processCount");
     if (defaultPerformancePref.value) {
       let accelerationPref = document.getElementById("layers.acceleration.disabled");
       // Unset the value so process count will be decided by e10s rollout.
       processCountPref.value = processCountPref.defaultValue;
       accelerationPref.value = accelerationPref.defaultValue;
       performanceSettings.hidden = true;
     } else {
       let e10sRolloutProcessCountPref =
         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;
       }
       performanceSettings.hidden = false;
     }
   },
 
   buildContentProcessCountMenuList() {
--- a/browser/components/preferences/in-content-new/tests/browser_performance.js
+++ b/browser/components/preferences/in-content-new/tests/browser_performance.js
@@ -131,16 +131,108 @@ add_task(async function() {
   is(Services.prefs.getIntPref("dom.ipc.processCount"), 7, "pref value should be 7");
   is(contentProcessCount.selectedItem.value, 7, "selected item should be 7");
 
   Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
   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);
 
   let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
   is(prefs.selectedPane, "paneGeneral", "General pane was selected");
 
   let doc = gBrowser.contentDocument;
 
   let performanceSettings = doc.querySelector("#performanceSettings");
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -45,19 +45,19 @@ var gMainPane = {
     }
 
     this.buildContentProcessCountMenuList();
     this.updateDefaultPerformanceSettingsPref();
 
     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";
     performanceSettingsLink.setAttribute("href", performanceSettingsUrl);
 
     // set up the "use current page" label-changing listener
     this._updateUseCurrentButton();
     window.addEventListener("focus", this._updateUseCurrentButton.bind(this));
@@ -420,33 +420,34 @@ var gMainPane = {
     let processCountPref = document.getElementById("dom.ipc.processCount");
     let accelerationPref = document.getElementById("layers.acceleration.disabled");
     if (processCountPref.value != processCountPref.defaultValue ||
         accelerationPref.value != accelerationPref.defaultValue) {
       defaultPerformancePref.value = false;
     }
   },
 
-  updatePerformanceSettingsBox() {
+  updatePerformanceSettingsBox({duringChangeEvent}) {
     let defaultPerformancePref =
       document.getElementById("browser.preferences.defaultPerformanceSettings.enabled");
     let performanceSettings = document.getElementById("performanceSettings");
     let processCountPref = document.getElementById("dom.ipc.processCount");
     if (defaultPerformancePref.value) {
       let accelerationPref = document.getElementById("layers.acceleration.disabled");
       // Unset the value so process count will be decided by e10s rollout.
       processCountPref.value = processCountPref.defaultValue;
       accelerationPref.value = accelerationPref.defaultValue;
       performanceSettings.hidden = true;
     } else {
       let e10sRolloutProcessCountPref =
         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;
       }
       performanceSettings.hidden = false;
     }
   },
 
   buildContentProcessCountMenuList() {
--- a/browser/components/preferences/in-content/tests/browser_performance.js
+++ b/browser/components/preferences/in-content/tests/browser_performance.js
@@ -131,16 +131,108 @@ add_task(async function() {
   is(Services.prefs.getIntPref("dom.ipc.processCount"), 7, "pref value should be 7");
   is(contentProcessCount.selectedItem.value, 7, "selected item should be 7");
 
   Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
   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);
 
   let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
   is(prefs.selectedPane, "paneGeneral", "General pane was selected");
 
   let doc = gBrowser.contentDocument;
 
   let performanceSettings = doc.querySelector("#performanceSettings");