Bug 1274712 - Add a mozscreenshots configuration for the DNT dialog. r=MattN draft
authorJohann Hofmann <jhofmann@mozilla.com>
Thu, 26 May 2016 23:27:02 +0200
changeset 373173 427e26d44d9c6d1136e70d69edfe75bafa2e2c4d
parent 371315 a33592050e2465ea62f9d62c42623c9c88b9808f
child 373174 bbe43290f24af1670e0edc869d1bcd7014625ed5
push id19697
push usermail@johann-hofmann.com
push dateTue, 31 May 2016 10:10:56 +0000
reviewersMattN
bugs1274712
milestone49.0a1
Bug 1274712 - Add a mozscreenshots configuration for the DNT dialog. r=MattN MozReview-Commit-ID: AoGYvnwHm37
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
@@ -7,16 +7,17 @@
 this.EXPORTED_SYMBOLS = ["Preferences"];
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/Timer.jsm");
 Cu.import("resource://testing-common/TestUtils.jsm");
+Cu.import("resource://testing-common/ContentTask.jsm");
 
 this.Preferences = {
 
   init(libDir) {
     Services.prefs.setBoolPref("browser.preferences.inContent", true);
 
     let panes = [
       ["paneGeneral", null],
@@ -34,17 +35,28 @@ this.Preferences = {
     ];
     for (let [primary, advanced] of panes) {
       let configName = primary.replace(/^pane/, "prefs") + (advanced ? "-" + advanced : "");
       this.configurations[configName] = {};
       this.configurations[configName].applyConfig = prefHelper.bind(null, primary, advanced);
     }
   },
 
-  configurations: {},
+  configurations: {
+    "panePrivacy-DNTDialog": {
+      applyConfig: Task.async(function*(){
+        let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+        yield prefHelper("panePrivacy", null);
+
+        yield ContentTask.spawn(browserWindow.gBrowser.selectedBrowser, null, function* () {
+          content.document.getElementById("doNotTrackSettings").click();
+        });
+      }),
+    },
+  },
 };
 
 let prefHelper = Task.async(function*(primary, advanced) {
   let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
   let selectedBrowser = browserWindow.gBrowser;
   let readyPromise = null;
   if (selectedBrowser.currentURI.specIgnoringRef == "about:preferences") {
     readyPromise = new Promise((resolve) => {
@@ -60,9 +72,14 @@ let prefHelper = Task.async(function*(pr
 
   if (primary == "paneAdvanced") {
     browserWindow.openAdvancedPreferences(advanced);
   } else {
     browserWindow.openPreferences(primary);
   }
 
   yield readyPromise;
+
+  // close any dialog that might still be open
+  yield ContentTask.spawn(selectedBrowser.selectedBrowser, null, function*() {
+    content.window.gSubDialog.close();
+  });
 });