Bug 1364070 - Add performance settings section into the old organization r=jaws
authorEvan Tseng <evan@tseng.io>
Thu, 11 May 2017 10:35:09 -0400
changeset 359913 925f632c4c9986a0ac941513d88923abcf2bf9a0
parent 359912 b6be024548cd4e876e84569f9874c2056c4f0699
child 359914 3b98429334b7ab21f4b11038b29e038697566d90
push id43136
push userryanvm@gmail.com
push dateMon, 22 May 2017 13:50:40 +0000
treeherderautoland@925f632c4c99 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1364070
milestone55.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 1364070 - Add performance settings section into the old organization r=jaws MozReview-Commit-ID: Fv7yGDtxih9
browser/components/preferences/in-content-old/advanced.xul
browser/components/preferences/in-content-old/main.js
browser/components/preferences/in-content-old/main.xul
browser/components/preferences/in-content-old/tests/browser.ini
browser/components/preferences/in-content-old/tests/browser_performance.js
browser/locales/en-US/chrome/browser/preferences-old/advanced.dtd
browser/locales/en-US/chrome/browser/preferences-old/preferences.properties
--- a/browser/components/preferences/in-content-old/advanced.xul
+++ b/browser/components/preferences/in-content-old/advanced.xul
@@ -29,20 +29,16 @@
 #endif
 
   <preference id="general.autoScroll"
               name="general.autoScroll"
               type="bool"/>
   <preference id="general.smoothScroll"
               name="general.smoothScroll"
               type="bool"/>
-  <preference id="layers.acceleration.disabled"
-              name="layers.acceleration.disabled"
-              type="bool"
-              inverted="true"/>
 #ifdef XP_WIN
   <preference id="gfx.direct2d.disabled"
               name="gfx.direct2d.disabled"
               type="bool"
               inverted="true"/>
 #endif
   <preference id="layout.spellcheckDefault"
               name="layout.spellcheckDefault"
@@ -182,20 +178,16 @@
         <checkbox id="useAutoScroll"
                   label="&useAutoScroll.label;"
                   accesskey="&useAutoScroll.accesskey;"
                   preference="general.autoScroll"/>
         <checkbox id="useSmoothScrolling"
                   label="&useSmoothScrolling.label;"
                   accesskey="&useSmoothScrolling.accesskey;"
                   preference="general.smoothScroll"/>
-        <checkbox id="allowHWAccel"
-                  label="&allowHWAccel.label;"
-                  accesskey="&allowHWAccel.accesskey;"
-                  preference="layers.acceleration.disabled"/>
         <checkbox id="checkSpelling"
                   label="&checkUserSpelling.label;"
                   accesskey="&checkUserSpelling.accesskey;"
                   onsyncfrompreference="return gAdvancedPane.readCheckSpelling();"
                   onsynctopreference="return gAdvancedPane.writeCheckSpelling();"
                   preference="layout.spellcheckDefault"/>
       </groupbox>
     </tabpanel>
--- a/browser/components/preferences/in-content-old/main.js
+++ b/browser/components/preferences/in-content-old/main.js
@@ -39,16 +39,36 @@ var gMainPane = {
         // way to get all file type association prefs. So we don't know
         // when the user will select the default.  We refresh here periodically
         // in case the default changes. On other Windows OS's defaults can also
         // be set while the prefs are open.
         window.setInterval(this.updateSetDefaultBrowser.bind(this), 1000);
       }
     }
 
+    this.buildContentProcessCountMenuList();
+    let processCountPref =
+      document.getElementById("dom.ipc.processCount");
+    processCountPref.addEventListener("change", () => {
+      this.updateDefaultPerformanceSettingsPref();
+    });
+    let accelerationPref =
+      document.getElementById("layers.acceleration.disabled");
+    accelerationPref.addEventListener("change", () => {
+      this.updateDefaultPerformanceSettingsPref();
+    });
+    this.updateDefaultPerformanceSettingsPref();
+
+    let defaultPerformancePref =
+      document.getElementById("browser.preferences.defaultPerformanceSettings.enabled");
+    defaultPerformancePref.addEventListener("change", () => {
+      this.updatePerformanceSettingsBox();
+    });
+    this.updatePerformanceSettingsBox();
+
     // set up the "use current page" label-changing listener
     this._updateUseCurrentButton();
     window.addEventListener("focus", this._updateUseCurrentButton.bind(this));
 
     this.updateBrowserStartupLastSession();
 
     if (AppConstants.platform == "win") {
       // Functionality for "Show tabs in taskbar" on Windows 7 and up.
@@ -380,16 +400,53 @@ var gMainPane = {
   /**
    * Restores the default home page as the user's home page.
    */
   restoreDefaultHomePage() {
     var homePage = document.getElementById("browser.startup.homepage");
     homePage.value = homePage.defaultValue;
   },
 
+  updateDefaultPerformanceSettingsPref() {
+    let defaultPerformancePref =
+      document.getElementById("browser.preferences.defaultPerformanceSettings.enabled");
+    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() {
+    let defaultPerformancePref =
+      document.getElementById("browser.preferences.defaultPerformanceSettings.enabled");
+    let performanceSettings = document.getElementById("performanceSettings");
+    if (defaultPerformancePref.value) {
+      let processCountPref = document.getElementById("dom.ipc.processCount");
+      let accelerationPref = document.getElementById("layers.acceleration.disabled");
+      processCountPref.value = processCountPref.defaultValue;
+      accelerationPref.value = accelerationPref.defaultValue;
+      performanceSettings.hidden = true;
+    } else {
+      performanceSettings.hidden = false;
+    }
+  },
+
+  buildContentProcessCountMenuList() {
+    let processCountPref = document.getElementById("dom.ipc.processCount");
+    let bundlePreferences = document.getElementById("bundlePreferences");
+    let label = bundlePreferences.getFormattedString("defaultContentProcessCount",
+      [processCountPref.defaultValue]);
+    let contentProcessCount =
+      document.querySelector(`#contentProcessCount > menupopup >
+                              menuitem[value="${processCountPref.defaultValue}"]`);
+    contentProcessCount.label = label;
+  },
+
   // DOWNLOADS
 
   /*
    * Preferences:
    *
    * browser.download.useDownloadDir - bool
    *   True - Save files directly to the folder configured via the
    *   browser.download.folderList preference.
--- a/browser/components/preferences/in-content-old/main.xul
+++ b/browser/components/preferences/in-content-old/main.xul
@@ -2,16 +2,18 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 <!-- General panel -->
 
 <script type="application/javascript"
         src="chrome://browser/content/preferences/in-content-old/main.js"/>
 
+<stringbundle id="bundlePreferences" src="chrome://browser/locale/preferences.properties"/>
+
 <preferences id="mainPreferences" hidden="true" data-category="paneGeneral">
 
 #ifdef E10S_TESTING_ONLY
     <preference id="browser.tabs.remote.autostart"
                 name="browser.tabs.remote.autostart"
                 type="bool"/>
     <preference id="e10sTempPref"
                 name="browser.tabs.remote.autostart.2"
@@ -103,16 +105,29 @@
 #ifdef XP_WIN
     <preference id="browser.taskbar.previews.enable"
                 name="browser.taskbar.previews.enable"
                 type="bool"/>
 #endif
     <preference id="browser.ctrlTab.previews"
                 name="browser.ctrlTab.previews"
                 type="bool"/>
+
+  <preference id="browser.preferences.defaultPerformanceSettings.enabled"
+              name="browser.preferences.defaultPerformanceSettings.enabled"
+              type="bool"/>
+
+  <preference id="dom.ipc.processCount"
+              name="dom.ipc.processCount"
+              type="int"/>
+
+  <preference id="layers.acceleration.disabled"
+              name="layers.acceleration.disabled"
+              type="bool"
+              inverted="true"/>
 </preferences>
 
 <hbox id="header-general"
       class="header"
       hidden="true"
       data-category="paneGeneral">
   <label class="header-name" flex="1">&paneGeneral.title;</label>
   <html:a class="help-button" target="_blank" aria-label="&helpButton.label;"></html:a>
@@ -297,8 +312,41 @@
               preference="browser.tabs.loadInBackground"/>
 
 #ifdef XP_WIN
     <checkbox id="showTabsInTaskbar" label="&showTabsInTaskbar.label;"
               accesskey="&showTabsInTaskbar.accesskey;"
               preference="browser.taskbar.previews.enable"/>
 #endif
 </groupbox>
+
+<!-- Performance -->
+<groupbox id="performanceGroup" data-category="paneGeneral" hidden="true">
+  <caption><label>&performance.label;</label></caption>
+
+  <checkbox id="useRecommendedPerformanceSettings"
+            label="&useRecommendedPerformanceSettings.label;"
+            accesskey="&useRecommendedPerformanceSettings.accesskey;"
+            preference="browser.preferences.defaultPerformanceSettings.enabled"/>
+  <description class="indent">&useRecommendedPerformanceSettings.description;</description>
+
+  <vbox id="performanceSettings" class="indent" hidden="true">
+    <checkbox id="allowHWAccel"
+              label="&allowHWAccel.label;"
+              accesskey="&allowHWAccel.accesskey;"
+              preference="layers.acceleration.disabled"/>
+    <hbox align="center">
+      <label id="limitContentProcess" accesskey="&limitContentProcess.accesskey;" control="contentProcessCount">&limitContentProcess.label;</label>
+      <menulist id="contentProcessCount" preference="dom.ipc.processCount">
+        <menupopup>
+          <menuitem label="1" value="1"/>
+          <menuitem label="2" value="2"/>
+          <menuitem label="3" value="3"/>
+          <menuitem label="4" value="4"/>
+          <menuitem label="5" value="5"/>
+          <menuitem label="6" value="6"/>
+          <menuitem label="7" value="7"/>
+        </menupopup>
+      </menulist>
+    </hbox>
+    <description>&limitContentProcess.description;</description>
+  </vbox>
+</groupbox>
--- a/browser/components/preferences/in-content-old/tests/browser.ini
+++ b/browser/components/preferences/in-content-old/tests/browser.ini
@@ -25,16 +25,17 @@ skip-if = os != "win" # This test tests 
 [browser_connection.js]
 [browser_connection_bug388287.js]
 [browser_cookies_exceptions.js]
 [browser_defaultbrowser_alwayscheck.js]
 [browser_healthreport.js]
 skip-if = true || !healthreport # Bug 1185403 for the "true"
 [browser_homepages_filter_aboutpreferences.js]
 [browser_notifications_do_not_disturb.js]
+[browser_performance.js]
 [browser_permissions_urlFieldHidden.js]
 [browser_proxy_backup.js]
 [browser_privacypane_1.js]
 [browser_privacypane_3.js]
 [browser_privacypane_4.js]
 [browser_privacypane_5.js]
 [browser_privacypane_8.js]
 [browser_sanitizeOnShutdown_prefLocked.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/preferences/in-content-old/tests/browser_performance.js
@@ -0,0 +1,124 @@
+const DEFAULT_HW_ACCEL_PREF = Services.prefs.getDefaultBranch(null).getBoolPref("layers.acceleration.disabled");
+const DEFAULT_PROCESS_COUNT = Services.prefs.getDefaultBranch(null).getIntPref("dom.ipc.processCount");
+
+add_task(function*() {
+  yield SpecialPowers.pushPrefEnv({set: [
+    ["layers.acceleration.disabled", DEFAULT_HW_ACCEL_PREF],
+    ["dom.ipc.processCount", DEFAULT_PROCESS_COUNT],
+    ["browser.preferences.defaultPerformanceSettings.enabled", true],
+  ]});
+});
+
+add_task(function*() {
+  let prefs = yield 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 allowHWAccel = doc.querySelector("#allowHWAccel");
+  let allowHWAccelPref = Services.prefs.getBoolPref("layers.acceleration.disabled");
+  is(allowHWAccelPref, DEFAULT_HW_ACCEL_PREF,
+    "pref value should be the default value before clicking on checkbox");
+  is(allowHWAccel.checked, !DEFAULT_HW_ACCEL_PREF, "checkbox should show the invert of the default value");
+
+  let contentProcessCount = doc.querySelector("#contentProcessCount");
+  is(Services.prefs.getIntPref("dom.ipc.processCount"), DEFAULT_PROCESS_COUNT, "default pref value should be default value");
+  is(contentProcessCount.selectedItem.value, DEFAULT_PROCESS_COUNT, "selected item should be the default one");
+
+  allowHWAccel.click();
+  allowHWAccelPref = Services.prefs.getBoolPref("layers.acceleration.disabled");
+  is(allowHWAccelPref, !DEFAULT_HW_ACCEL_PREF,
+    "pref value should be opposite of the default value after clicking on checkbox");
+  is(allowHWAccel.checked, !allowHWAccelPref, "checkbox should show the invert of the current value");
+
+  contentProcessCount.value = 7;
+  contentProcessCount.doCommand();
+  is(Services.prefs.getIntPref("dom.ipc.processCount"), 7, "pref value should be 7");
+  is(contentProcessCount.selectedItem.value, 7, "selected item should be 7");
+
+  allowHWAccel.click();
+  allowHWAccelPref = Services.prefs.getBoolPref("layers.acceleration.disabled");
+  is(allowHWAccelPref, DEFAULT_HW_ACCEL_PREF,
+    "pref value should be the default value after clicking on checkbox");
+  is(allowHWAccel.checked, !allowHWAccelPref, "checkbox should show the invert of the current value");
+
+  contentProcessCount.value = DEFAULT_PROCESS_COUNT;
+  contentProcessCount.doCommand();
+  is(Services.prefs.getIntPref("dom.ipc.processCount"), DEFAULT_PROCESS_COUNT, "pref value should be default value");
+  is(contentProcessCount.selectedItem.value, DEFAULT_PROCESS_COUNT, "selected item should be default one");
+
+  is(performanceSettings.hidden, false, "performance settings section should be still shown");
+
+  Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
+  yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
+});
+
+add_task(function*() {
+  let prefs = yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
+  is(prefs.selectedPane, "paneGeneral", "General pane was selected");
+
+  let doc = gBrowser.contentDocument;
+  let performanceSettings = doc.querySelector("#performanceSettings");
+
+  is(performanceSettings.hidden, true, "performance settings section should not be shown");
+
+  Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", false);
+
+  is(performanceSettings.hidden, false, "performance settings section should be shown");
+
+  Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
+  yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
+});
+
+add_task(function*() {
+  Services.prefs.setIntPref("dom.ipc.processCount", 7);
+
+  let prefs = yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {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 should be shown");
+
+  let contentProcessCount = doc.querySelector("#contentProcessCount");
+  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);
+  yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
+});
+
+add_task(function*() {
+  Services.prefs.setBoolPref("layers.acceleration.disabled", true);
+
+  let prefs = yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {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 should be shown");
+
+  let allowHWAccel = doc.querySelector("#allowHWAccel");
+  is(Services.prefs.getBoolPref("layers.acceleration.disabled"), true,
+    "pref value is false");
+  ok(!allowHWAccel.checked, "checkbox should not be checked");
+
+  Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
+  yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
+});
--- a/browser/locales/en-US/chrome/browser/preferences-old/advanced.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences-old/advanced.dtd
@@ -18,18 +18,16 @@
 <!ENTITY useOnScreenKeyboard.accesskey   "k">
 
 <!ENTITY browsing.label                  "Browsing">
 
 <!ENTITY useAutoScroll.label             "Use autoscrolling">
 <!ENTITY useAutoScroll.accesskey         "a">
 <!ENTITY useSmoothScrolling.label        "Use smooth scrolling">
 <!ENTITY useSmoothScrolling.accesskey    "m">
-<!ENTITY allowHWAccel.label              "Use hardware acceleration when available">
-<!ENTITY allowHWAccel.accesskey          "r">
 <!ENTITY checkUserSpelling.label         "Check your spelling as you type">
 <!ENTITY checkUserSpelling.accesskey     "t">
 
 <!ENTITY dataChoicesTab.label            "Data Choices">
 
 <!ENTITY healthReportDesc.label          "Helps you understand your browser performance and shares data with &vendorShortName; about your browser health">
 <!ENTITY enableHealthReport.label        "Enable &brandShortName; Health Report">
 <!ENTITY enableHealthReport.accesskey    "R">
@@ -120,8 +118,22 @@
 <!ENTITY selectCerts.ask                 "Ask you every time">
 <!ENTITY selectCerts.ask.accesskey       "A">
 <!ENTITY enableOCSP.label                "Query OCSP responder servers to confirm the current validity of certificates">
 <!ENTITY enableOCSP.accesskey            "Q">
 <!ENTITY viewCerts.label                 "View Certificates">
 <!ENTITY viewCerts.accesskey             "C">
 <!ENTITY viewSecurityDevices.label       "Security Devices">
 <!ENTITY viewSecurityDevices.accesskey   "D">
+
+<!ENTITY performance.label               "Performance">
+<!ENTITY useRecommendedPerformanceSettings.label
+                                         "Use recommended performance settings">
+<!ENTITY useRecommendedPerformanceSettings.description
+                                         "These settings are tailored to your computer’s hardware and operating system.">
+<!ENTITY useRecommendedPerformanceSettings.accesskey
+                                         "U">
+<!ENTITY limitContentProcess.label       "Content process limit">
+<!ENTITY limitContentProcess.description
+                                         "Additional content processes can improve &brandShortName; performance when using multiple tabs, but will also use more memory.">
+<!ENTITY limitContentProcess.accesskey   "L">
+<!ENTITY allowHWAccel.label              "Use hardware acceleration when available">
+<!ENTITY allowHWAccel.accesskey          "r">
--- a/browser/locales/en-US/chrome/browser/preferences-old/preferences.properties
+++ b/browser/locales/en-US/chrome/browser/preferences-old/preferences.properties
@@ -249,8 +249,11 @@ removeContainerAlertTitle=Remove This Co
 
 # LOCALIZATION NOTE (removeContainerMsg): Semi-colon list of plural forms.
 # See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
 # #S is the number of container tabs
 removeContainerMsg=If you remove this Container now, #S container tab will be closed. Are you sure you want to remove this Container?;If you remove this Container now, #S container tabs will be closed. Are you sure you want to remove this Container?
 
 removeContainerOkButton=Remove this Container
 removeContainerButton2=Don’t remove this Container
+
+# LOCALIZATION NOTE %S is the default value of the `dom.ipc.processCount` pref.
+defaultContentProcessCount=%S (default)