Bug 1274712 - Add a mozscreenshots configuration for the DNT dialog. r=MattN
MozReview-Commit-ID: AoGYvnwHm37
--- 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();
+ });
});