Bug 1353036 - Update mozscreenshots to use new preference category names and locations. r?mattn draft
authorJared Wein <jwein@mozilla.com>
Mon, 03 Apr 2017 11:16:39 -0400
changeset 568258 36aef3b4b5be8bf3bcbd2cbd69a75996825c6700
parent 568252 3f0c8da53c5cb015933b10b52ded3f30432b378a
child 625863 86eed624ef1587ba9ecd391df8c6b70245937bb0
push id55803
push userbmo:jaws@mozilla.com
push dateTue, 25 Apr 2017 21:54:04 +0000
reviewersmattn
bugs1353036
milestone55.0a1
Bug 1353036 - Update mozscreenshots to use new preference category names and locations. r?mattn MozReview-Commit-ID: 3oifWlxUPfY
browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Preferences.jsm
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Preferences.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Preferences.jsm
@@ -12,51 +12,72 @@ Cu.import("resource://gre/modules/Servic
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://testing-common/TestUtils.jsm");
 Cu.import("resource://testing-common/ContentTask.jsm");
 
 this.Preferences = {
 
   init(libDir) {
     let panes = [
-      ["paneGeneral", null],
-      ["paneSearch", null],
-      ["paneContent", null],
-      ["paneApplications", null],
-      ["panePrivacy", null],
-      ["panePrivacy", null, DNTDialog],
-      ["panePrivacy", null, clearRecentHistoryDialog],
-      ["paneSecurity", null],
-      ["paneSync", null],
-      ["paneAdvanced", "generalTab"],
-      ["paneAdvanced", "dataChoicesTab"],
-      ["paneAdvanced", "networkTab"],
-      ["paneAdvanced", "networkTab", connectionDialog],
-      ["paneAdvanced", "updateTab"],
-      ["paneAdvanced", "encryptionTab"],
-      ["paneAdvanced", "encryptionTab", certManager],
-      ["paneAdvanced", "encryptionTab", deviceManager],
+      /* The "new" organization */
+      ["paneGeneral"],
+      ["paneGeneral", scrollToBrowsingGroup],
+      ["paneApplications"],
+      ["paneSync"],
+      ["panePrivacy"],
+      ["panePrivacy", scrollToCacheGroup],
+      ["panePrivacy", DNTDialog],
+      ["panePrivacy", clearRecentHistoryDialog],
+      ["panePrivacy", connectionDialog],
+      ["panePrivacy", certManager],
+      ["panePrivacy", deviceManager],
+      ["paneAdvanced"],
+
+      /* The "old" organization. The third argument says to
+         set the pref to show the old organization when
+         opening the preferences. */
+      ["paneGeneral", null, true],
+      ["paneSearch", null, true],
+      ["paneContent", null, true],
+      ["paneApplications", null, true],
+      ["panePrivacy", null, true],
+      ["panePrivacy", DNTDialog, true],
+      ["panePrivacy", clearRecentHistoryDialog, true],
+      ["paneSecurity", null, true],
+      ["paneSync", null, true],
+      ["paneAdvanced", null, true, "generalTab"],
+      ["paneAdvanced", null, true, "dataChoicesTab"],
+      ["paneAdvanced", null, true, "networkTab"],
+      ["paneAdvanced", connectionDialog, true, "networkTab"],
+      ["paneAdvanced", null, true, "updateTab"],
+      ["paneAdvanced", null, true, "encryptionTab"],
+      ["paneAdvanced", certManager, true, "encryptionTab"],
+      ["paneAdvanced", deviceManager, true, "encryptionTab"],
     ];
-    for (let [primary, advanced, customFn] of panes) {
+    for (let [primary, customFn, useOldOrg, advanced] of panes) {
       let configName = primary.replace(/^pane/, "prefs") + (advanced ? "-" + advanced : "");
       if (customFn) {
         configName += "-" + customFn.name;
       }
       this.configurations[configName] = {};
-      this.configurations[configName].applyConfig = prefHelper.bind(null, primary, advanced, customFn);
+      this.configurations[configName].applyConfig = prefHelper.bind(null, primary, customFn, useOldOrg, advanced);
     }
   },
 
   configurations: {},
 };
 
-let prefHelper = Task.async(function*(primary, advanced = null, customFn = null) {
+let prefHelper = Task.async(function*(primary, customFn = null, useOldOrg = false, advanced = null) {
   let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
   let selectedBrowser = browserWindow.gBrowser.selectedBrowser;
 
+  if (useOldOrg) {
+    Services.prefs.setBoolPref("browser.preferences.useOldOrganization", !!useOldOrg);
+  }
+
   // close any dialog that might still be open
   yield ContentTask.spawn(selectedBrowser, null, function*() {
     if (!content.window.gSubDialog) {
       return;
     }
     content.window.gSubDialog.close();
   });
 
@@ -67,39 +88,53 @@ let prefHelper = Task.async(function*(pr
       readyPromise = Promise.resolve();
     } else {
       readyPromise = paintPromise(browserWindow);
     }
   } else {
     readyPromise = TestUtils.topicObserved("advanced-pane-loaded");
   }
 
-  if (primary == "paneAdvanced") {
+  if (useOldOrg && primary == "paneAdvanced") {
     browserWindow.openAdvancedPreferences(advanced);
   } else {
     browserWindow.openPreferences(primary);
   }
 
   yield readyPromise;
 
   if (customFn) {
     let customPaintPromise = paintPromise(browserWindow);
     yield* customFn(selectedBrowser);
     yield customPaintPromise;
   }
+
+  Services.prefs.clearUserPref("browser.preferences.useOldOrganization");
 });
 
 function paintPromise(browserWindow) {
   return new Promise((resolve) => {
     browserWindow.addEventListener("MozAfterPaint", function() {
       resolve();
     }, {once: true});
   });
 }
 
+function* scrollToBrowsingGroup(aBrowser) {
+  yield ContentTask.spawn(aBrowser, null, function* () {
+    content.document.getElementById("browsingGroup").scrollIntoView();
+  });
+}
+
+function* scrollToCacheGroup(aBrowser) {
+  yield ContentTask.spawn(aBrowser, null, function* () {
+    content.document.getElementById("cacheGroup").scrollIntoView();
+  });
+}
+
 function* DNTDialog(aBrowser) {
   yield ContentTask.spawn(aBrowser, null, function* () {
     content.document.getElementById("doNotTrackSettings").click();
   });
 }
 
 function* connectionDialog(aBrowser) {
   yield ContentTask.spawn(aBrowser, null, function* () {