--- a/browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
@@ -12,16 +12,17 @@ const APPLY_CONFIG_TIMEOUT_MS = 60 * 100
const HOME_PAGE = "chrome://mozscreenshots/content/lib/mozscreenshots.html";
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Timer.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/Geometry.jsm");
+Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "BrowserTestUtils",
"resource://testing-common/BrowserTestUtils.jsm");
// Screenshot.jsm must be imported this way for xpcshell tests to work
XPCOMUtils.defineLazyModuleGetter(this, "Screenshot", "chrome://mozscreenshots/content/Screenshot.jsm");
this.TestRunner = {
combos: null,
@@ -99,17 +100,45 @@ this.TestRunner = {
browserWindow.document.getElementById("main-window").removeAttribute("remotecontrol");
let selectedBrowser = browserWindow.gBrowser.selectedBrowser;
await BrowserTestUtils.loadURI(selectedBrowser, HOME_PAGE);
await BrowserTestUtils.browserLoaded(selectedBrowser);
for (let i = 0; i < this.combos.length; i++) {
this.currentComboIndex = i;
- await this._performCombo(this.combos.item(this.currentComboIndex));
+ await this._performCombo(this.combos.item(this.currentComboIndex),
+ browserWindow);
+ }
+
+ // If PrivateBrowsing is specified, run each config again on a private window
+ if (setNames.includes("PrivateBrowsing")) {
+ browserWindow.minimize();
+
+ // Open private window
+ let privateWindow = await BrowserTestUtils.openNewBrowserWindow({private: true});
+ // Remove automated notification in URL bar
+ privateWindow.document.getElementById("main-window").removeAttribute("remotecontrol");
+ // Set private window to about:privatebrowsing
+ selectedBrowser = privateWindow.gBrowser.selectedBrowser;
+ await BrowserTestUtils.loadURI(selectedBrowser, "about:privatebrowsing");
+ await BrowserTestUtils.browserLoaded(selectedBrowser);
+
+ for (let i = 0; i < this.combos.length; i++) {
+ this.currentComboIndex = i;
+ await this._performCombo(this.combos.item(this.currentComboIndex),
+ privateWindow);
+ }
+
+ // Close private window
+ await BrowserTestUtils.closeWindow(privateWindow);
+
+ // Restore browserWindow
+ browserWindow.restore();
+ browserWindow.focus();
}
this.mochitestScope.info("Done: Completed " + this.completedCombos + " out of " +
this.combos.length + " configurations.");
this.cleanup();
},
/**
@@ -135,16 +164,21 @@ this.TestRunner = {
/**
* Load sets of configurations from JSMs.
* @param {String[]} setNames - array of set names (e.g. ["Tabs", "WindowSize"].
* @return {Object[]} Array of sets containing `name` and `configurations` properties.
*/
loadSets(setNames) {
let sets = [];
for (let setName of setNames) {
+ // Don't load PrivateBrowsing to sets, TestRunner handles any necessary
+ // work for PrivateBrowsing config
+ if (setName == "PrivateBrowsing") {
+ continue;
+ }
let restrictions = null;
if (setName.includes("[")) {
let filteredData = this.filterRestrictions(setName);
setName = filteredData.trimmedSetName;
restrictions = filteredData.restrictions;
}
let imported = {};
Cu.import("chrome://mozscreenshots/content/configurations/" + setName + ".jsm",
@@ -172,16 +206,17 @@ this.TestRunner = {
}
}
sets.push(configurations);
}
return sets;
},
cleanup() {
+ // Revert main browserWindow to initial state
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
let gBrowser = browserWindow.gBrowser;
while (gBrowser.tabs.length > 1) {
gBrowser.removeTab(gBrowser.selectedTab, {animate: false});
}
gBrowser.unpinTab(gBrowser.selectedTab);
gBrowser.selectedBrowser.loadURI("data:text/html;charset=utf-8,<h1>Done!");
browserWindow.restore();
@@ -248,28 +283,28 @@ this.TestRunner = {
finalRect.left = Math.max(finalRect.left, windowLeft);
finalRect.top = Math.max(finalRect.top, windowTop);
finalRect.right = Math.min(finalRect.right, windowLeft + windowWidth);
finalRect.bottom = Math.min(finalRect.bottom, windowTop + windowHeight);
return finalRect;
},
- async _performCombo(combo) {
+ async _performCombo(combo, window) {
let paddedComboIndex = padLeft(this.currentComboIndex + 1, String(this.combos.length).length);
this.mochitestScope.info(
`Combination ${paddedComboIndex}/${this.combos.length}: ${this._comboName(combo).substring(1)}`
);
// Notice that this does need to be a closure, not a function, as otherwise
// "this" gets replaced and we lose access to this.mochitestScope.
const changeConfig = (config) => {
this.mochitestScope.info("calling " + config.name);
- let applyPromise = Promise.resolve(config.applyConfig());
+ let applyPromise = Promise.resolve(config.applyConfig({browserWindow: window}));
let timeoutPromise = new Promise((resolve, reject) => {
setTimeout(reject, APPLY_CONFIG_TIMEOUT_MS, "Timed out");
});
this.mochitestScope.info("called " + config.name);
// Add a default timeout of 500ms to avoid conflicts when configurations
// try to apply at the same time. e.g WindowSize and TabsInTitlebar
return Promise.race([applyPromise, timeoutPromise]).then(() => {
@@ -278,16 +313,17 @@ this.TestRunner = {
});
});
};
try {
// First go through and actually apply all of the configs
for (let i = 0; i < combo.length; i++) {
let config = combo[i];
+
if (!this._lastCombo || config !== this._lastCombo[i]) {
this.mochitestScope.info(`promising ${config.name}`);
await changeConfig(config);
}
}
// Update the lastCombo since it's now been applied regardless of whether it's accepted below.
this.mochitestScope.info("fulfilled all applyConfig so setting lastCombo.");
@@ -299,17 +335,17 @@ this.TestRunner = {
for (let i = 0; i < combo.length; i++) {
let config = combo[i];
// A configuration can specify an optional verifyConfig method to indicate
// if the current config is valid for a screenshot. This gets called even
// if the this config was used in the lastCombo since another config may
// have invalidated it.
if (config.verifyConfig) {
this.mochitestScope.info(`checking if the combo is valid with ${config.name}`);
- await config.verifyConfig();
+ await config.verifyConfig({browserWindow: window});
}
}
} catch (ex) {
this.mochitestScope.info(`\tskipped configuration [ ${combo.map((e) => e.name).join(", ")} ]`);
this.mochitestScope.info(`\treason: ${ex.toString()}`);
// Don't set lastCombo here so that we properly know which configurations
// need to be applied since the last screenshot
@@ -332,22 +368,27 @@ this.TestRunner = {
}
}
const rect = this._findBoundingBox(finalSelectors, windowType);
this.mochitestScope.ok(rect, "A valid bounding box was found");
if (!rect) {
return;
}
- await this._onConfigurationReady(combo, rect);
+ await this._onConfigurationReady(combo, rect, window);
},
- async _onConfigurationReady(combo, rect) {
+ async _onConfigurationReady(combo, rect, window) {
let filename = padLeft(this.currentComboIndex + 1,
String(this.combos.length).length) + this._comboName(combo);
+
+ // If the window is private, add private tag to filename
+ if (PrivateBrowsingUtils.isWindowPrivate(window)) {
+ filename += "_PrivateBrowsing";
+ }
const imagePath = await Screenshot.captureExternal(filename);
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
await this._cropImage(browserWindow, OS.Path.toFileURI(imagePath), rect, imagePath).catch((msg) => {
throw `Cropping combo [${combo.map((e) => e.name).join(", ")}] failed: ${msg}`;
});
this.completedCombos++;
this.mochitestScope.info("_onConfigurationReady");
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/AppMenu.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/AppMenu.jsm
@@ -9,79 +9,79 @@ this.EXPORTED_SYMBOLS = ["AppMenu"];
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");
this.AppMenu = {
init(libDir) {},
+ // TODO: test skips all configs except first
+ // I believe this is unrelated to my changes
configurations: {
appMenuClosed: {
selectors: ["#appMenu-popup"],
- async applyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
browserWindow.PanelUI.hide();
},
},
appMenuMainView: {
selectors: ["#appMenu-popup"],
- applyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ applyConfig({browserWindow}) {
let promise = browserWindow.PanelUI.show();
browserWindow.PanelUI.showMainView();
return promise;
},
},
appMenuHistorySubview: {
selectors: ["#appMenu-popup"],
- applyConfig() {
+ applyConfig({browserWindow}) {
// History has a footer
- if (isCustomizing()) {
+ if (isCustomizing(browserWindow)) {
return Promise.reject("Can't show subviews while customizing");
}
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
let promise = browserWindow.PanelUI.show();
return promise.then(() => {
browserWindow.PanelUI.showMainView();
browserWindow.document.getElementById("history-panelmenu").click();
});
},
- verifyConfig: verifyConfigHelper,
+ async verifyConfig({browserWindow}) {
+ return verifyConfigHelper(browserWindow);
+ },
},
appMenuHelpSubview: {
selectors: ["#appMenu-popup"],
- applyConfig() {
- if (isCustomizing()) {
+ applyConfig({browserWindow}) {
+ if (isCustomizing(browserWindow)) {
return Promise.reject("Can't show subviews while customizing");
}
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
let promise = browserWindow.PanelUI.show();
return promise.then(() => {
browserWindow.PanelUI.showMainView();
browserWindow.document.getElementById("PanelUI-help").click();
});
},
- verifyConfig: verifyConfigHelper,
+ async verifyConfig({browserWindow}) {
+ return verifyConfigHelper(browserWindow);
+ },
},
-
},
};
-function verifyConfigHelper() {
- if (isCustomizing()) {
+function verifyConfigHelper(browserWindow) {
+ if (isCustomizing(browserWindow)) {
return Promise.reject("AppMenu verifyConfigHelper");
}
return Promise.resolve("AppMenu verifyConfigHelper");
}
-function isCustomizing() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+function isCustomizing(browserWindow) {
if (browserWindow.document.documentElement.hasAttribute("customizing")) {
return true;
}
return false;
}
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Buttons.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Buttons.jsm
@@ -6,16 +6,17 @@
this.EXPORTED_SYMBOLS = ["Buttons"];
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource:///modules/CustomizableUI.jsm");
Cu.import("resource://gre/modules/Services.jsm");
+// TODO: Handle init
this.Buttons = {
init(libDir) {
createWidget();
},
configurations: {
navBarButtons: {
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/ControlCenter.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/ControlCenter.jsm
@@ -22,245 +22,239 @@ const HTTPS_PAGE = "https://example.com/
const PERMISSIONS_PAGE = "https://test1.example.com/";
const HTTP_PASSWORD_PAGE = `http://test2.example.org/${RESOURCE_PATH}/password.html`;
const MIXED_CONTENT_URL = `https://example.com/${RESOURCE_PATH}/mixed.html`;
const MIXED_ACTIVE_CONTENT_URL = `https://example.com/${RESOURCE_PATH}/mixed_active.html`;
const MIXED_PASSIVE_CONTENT_URL = `https://example.com/${RESOURCE_PATH}/mixed_passive.html`;
const TRACKING_PAGE = `http://tracking.example.org/${RESOURCE_PATH}/tracking.html`;
this.ControlCenter = {
- init(libDir) { },
+ init(libDir) {},
configurations: {
about: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage("about:rights");
- await openIdentityPopup();
+ async applyConfig({browserWindow}) {
+ await loadPage("about:rights", browserWindow);
+ await openIdentityPopup(false, browserWindow);
},
},
localFile: {
selectors: ["#identity-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
let channel = NetUtil.newChannel({
uri: "chrome://mozscreenshots/content/lib/mozscreenshots.html",
loadUsingSystemPrincipal: true
});
channel = channel.QueryInterface(Ci.nsIFileChannel);
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
let gBrowser = browserWindow.gBrowser;
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, channel.file.path);
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
- await openIdentityPopup();
+ await openIdentityPopup(false, browserWindow);
},
- async verifyConfig() {
+ async verifyConfig({browserWindow}) {
return Promise.reject("Bug 1373563: intermittent controlCenter_localFile on Taskcluster");
},
},
http: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage(HTTP_PAGE);
- await openIdentityPopup();
+ async applyConfig({browserWindow}) {
+ await loadPage(HTTP_PAGE, browserWindow);
+ await openIdentityPopup(false, browserWindow);
},
},
httpSubView: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage(HTTP_PAGE);
- await openIdentityPopup(true);
+ async applyConfig({browserWindow}) {
+ await loadPage(HTTP_PAGE, browserWindow);
+ await openIdentityPopup(true, browserWindow);
},
},
https: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage(HTTPS_PAGE);
- await openIdentityPopup();
+ async applyConfig({browserWindow}) {
+ await loadPage(HTTPS_PAGE, browserWindow);
+ await openIdentityPopup(false, browserWindow);
},
},
httpsSubView: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage(HTTPS_PAGE);
- await openIdentityPopup(true);
+ async applyConfig({browserWindow}) {
+ await loadPage(HTTPS_PAGE, browserWindow);
+ await openIdentityPopup(true, browserWindow);
},
},
singlePermission: {
selectors: ["#identity-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
let uri = Services.io.newURI(PERMISSIONS_PAGE);
SitePermissions.set(uri, "camera", SitePermissions.ALLOW);
- await loadPage(PERMISSIONS_PAGE);
- await openIdentityPopup();
+ await loadPage(PERMISSIONS_PAGE, browserWindow);
+ await openIdentityPopup(false, browserWindow);
},
},
allPermissions: {
selectors: ["#identity-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
// TODO: (Bug 1330601) Rewrite this to consider temporary (TAB) permission states.
// There are 2 possible non-default permission states, so we alternate between them.
let states = [SitePermissions.ALLOW, SitePermissions.BLOCK];
let uri = Services.io.newURI(PERMISSIONS_PAGE);
SitePermissions.listPermissions().forEach(function(permission, index) {
SitePermissions.set(uri, permission, states[index % 2]);
});
- await loadPage(PERMISSIONS_PAGE);
- await openIdentityPopup();
+ await loadPage(PERMISSIONS_PAGE, browserWindow);
+ await openIdentityPopup(false, browserWindow);
},
},
mixed: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage(MIXED_CONTENT_URL);
- await openIdentityPopup();
+ async applyConfig({browserWindow}) {
+ await loadPage(MIXED_CONTENT_URL, browserWindow);
+ await openIdentityPopup(false, browserWindow);
},
},
mixedSubView: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage(MIXED_CONTENT_URL);
- await openIdentityPopup(true);
+ async applyConfig({browserWindow}) {
+ await loadPage(MIXED_CONTENT_URL, browserWindow);
+ await openIdentityPopup(true, browserWindow);
},
},
mixedPassive: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage(MIXED_PASSIVE_CONTENT_URL);
- await openIdentityPopup();
+ async applyConfig({browserWindow}) {
+ await loadPage(MIXED_PASSIVE_CONTENT_URL, browserWindow);
+ await openIdentityPopup(false, browserWindow);
},
},
mixedPassiveSubView: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage(MIXED_PASSIVE_CONTENT_URL);
- await openIdentityPopup(true);
+ async applyConfig({browserWindow}) {
+ await loadPage(MIXED_PASSIVE_CONTENT_URL, browserWindow);
+ await openIdentityPopup(true, browserWindow);
},
},
mixedActive: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage(MIXED_ACTIVE_CONTENT_URL);
- await openIdentityPopup();
+ async applyConfig({browserWindow}) {
+ await loadPage(MIXED_ACTIVE_CONTENT_URL, browserWindow);
+ await openIdentityPopup(false, browserWindow);
},
},
mixedActiveSubView: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage(MIXED_ACTIVE_CONTENT_URL);
- await openIdentityPopup(true);
+ async applyConfig({browserWindow}) {
+ await loadPage(MIXED_ACTIVE_CONTENT_URL, browserWindow);
+ await openIdentityPopup(true, browserWindow);
},
},
mixedActiveUnblocked: {
selectors: ["#identity-popup"],
- async applyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
let gBrowser = browserWindow.gBrowser;
- await loadPage(MIXED_ACTIVE_CONTENT_URL);
+ await loadPage(MIXED_ACTIVE_CONTENT_URL, browserWindow);
gBrowser.ownerGlobal.gIdentityHandler.disableMixedContentProtection();
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, MIXED_ACTIVE_CONTENT_URL);
- await openIdentityPopup();
+ await openIdentityPopup(false, browserWindow);
},
},
mixedActiveUnblockedSubView: {
selectors: ["#identity-popup"],
- async applyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
let gBrowser = browserWindow.gBrowser;
- await loadPage(MIXED_ACTIVE_CONTENT_URL);
+ await loadPage(MIXED_ACTIVE_CONTENT_URL, browserWindow);
gBrowser.ownerGlobal.gIdentityHandler.disableMixedContentProtection();
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, MIXED_ACTIVE_CONTENT_URL);
- await openIdentityPopup(true);
+ await openIdentityPopup(true, browserWindow);
},
},
httpPassword: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage(HTTP_PASSWORD_PAGE);
- await openIdentityPopup();
+ async applyConfig({browserWindow}) {
+ await loadPage(HTTP_PASSWORD_PAGE, browserWindow);
+ await openIdentityPopup(false, browserWindow);
},
},
httpPasswordSubView: {
selectors: ["#identity-popup"],
- async applyConfig() {
- await loadPage(HTTP_PASSWORD_PAGE);
- await openIdentityPopup(true);
+ async applyConfig({browserWindow}) {
+ await loadPage(HTTP_PASSWORD_PAGE, browserWindow);
+ await openIdentityPopup(true, browserWindow);
},
},
trackingProtectionNoElements: {
selectors: ["#identity-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
Services.prefs.setBoolPref("privacy.trackingprotection.enabled", true);
- await loadPage(HTTP_PAGE);
- await openIdentityPopup();
+ await loadPage(HTTP_PAGE, browserWindow);
+ await openIdentityPopup(false, browserWindow);
},
},
trackingProtectionEnabled: {
selectors: ["#identity-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
Services.prefs.setBoolPref("privacy.trackingprotection.enabled", true);
Services.prefs.setIntPref("privacy.trackingprotection.introCount", 20);
await UrlClassifierTestUtils.addTestTrackers();
- await loadPage(TRACKING_PAGE);
- await openIdentityPopup();
+ await loadPage(TRACKING_PAGE, browserWindow);
+ await openIdentityPopup(false, browserWindow);
},
},
trackingProtectionDisabled: {
selectors: ["#identity-popup"],
- async applyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
let gBrowser = browserWindow.gBrowser;
Services.prefs.setBoolPref("privacy.trackingprotection.enabled", true);
Services.prefs.setIntPref("privacy.trackingprotection.introCount", 20);
await UrlClassifierTestUtils.addTestTrackers();
- await loadPage(TRACKING_PAGE);
- await openIdentityPopup();
+ await loadPage(TRACKING_PAGE, browserWindow);
+ await openIdentityPopup(false, browserWindow);
// unblock the page
gBrowser.ownerGlobal.document.querySelector("#tracking-action-unblock").click();
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, TRACKING_PAGE);
- await openIdentityPopup();
+ await openIdentityPopup(false, browserWindow);
},
},
},
};
-async function loadPage(url) {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+async function loadPage(url, browserWindow) {
let gBrowser = browserWindow.gBrowser;
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, url);
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, url);
}
-async function openIdentityPopup(expand) {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+async function openIdentityPopup(expand, browserWindow) {
let gBrowser = browserWindow.gBrowser;
let { gIdentityHandler } = gBrowser.ownerGlobal;
gIdentityHandler._identityPopup.hidePopup();
gIdentityHandler._identityBox.querySelector("#identity-icon").click();
if (expand) {
// give some time for opening to avoid weird style issues
await new Promise((c) => setTimeout(c, 500));
gIdentityHandler._identityPopup.querySelector("#identity-popup-security-expander").click();
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/CustomizeMode.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/CustomizeMode.jsm
@@ -13,19 +13,18 @@ Cu.import("resource://gre/modules/Timer.
this.CustomizeMode = {
init(libDir) {},
configurations: {
notCustomizing: {
selectors: ["#navigator-toolbox"],
- applyConfig() {
+ applyConfig({browserWindow}) {
return new Promise((resolve) => {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
if (!browserWindow.document.documentElement.hasAttribute("customizing")) {
resolve("notCustomizing: already not customizing");
return;
}
function onCustomizationEnds() {
browserWindow.gNavToolbox.removeEventListener("aftercustomization",
onCustomizationEnds);
// Wait for final changes
@@ -33,21 +32,22 @@ this.CustomizeMode = {
}
browserWindow.gNavToolbox.addEventListener("aftercustomization",
onCustomizationEnds);
browserWindow.gCustomizeMode.exit();
});
},
},
+ // TODO: Private window gets stuck here on customizing...
+ // Pops browser window back to the front then stalls
customizing: {
selectors: ["#navigator-toolbox", "#customization-container"],
- applyConfig() {
+ applyConfig({browserWindow}) {
return new Promise((resolve) => {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
if (browserWindow.document.documentElement.hasAttribute("customizing")) {
resolve("customizing: already customizing");
return;
}
function onCustomizing() {
browserWindow.gNavToolbox.removeEventListener("customizationready",
onCustomizing);
// Wait for final changes
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/DevTools.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/DevTools.jsm
@@ -16,21 +16,25 @@ let { devtools } = Cu.import("resource:/
let TargetFactory = devtools.TargetFactory;
function getTargetForSelectedTab() {
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
let target = TargetFactory.forTab(browserWindow.gBrowser.selectedTab);
return target;
}
+// When this function is called in TestRunner (line 253), does it
+// return for the most recent window or what?
function selectToolbox() {
return gDevTools.getToolbox(getTargetForSelectedTab()).win.document.querySelector("#toolbox-container");
}
+// comment so you can see function in mozreview
this.DevTools = {
+ // TODO: init...
init(libDir) {
let panels = ["options", "webconsole", "jsdebugger", "styleeditor",
"performance", "netmonitor"];
panels.forEach(panel => {
this.configurations[panel] = {};
this.configurations[panel].selectors = [selectToolbox];
this.configurations[panel].applyConfig = async function() {
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/LightweightThemes.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/LightweightThemes.jsm
@@ -23,24 +23,26 @@ this.LightweightThemes = {
let whiteImage = libDir.clone();
whiteImage.append("white_theme.png");
this._whiteImageURL = Services.io.newFileURI(whiteImage).spec;
},
configurations: {
noLWT: {
selectors: ["#navigator-toolbox"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
+ // How does LightweightThemeManager manager work?
+ // it worked right out of the box without needing browserWindow
LightweightThemeManager.currentTheme = null;
},
},
darkLWT: {
selectors: ["#navigator-toolbox"],
- applyConfig() {
+ applyConfig({browserWindow}) {
LightweightThemeManager.setLocalTheme({
id: "black",
name: "black",
headerURL: LightweightThemes._blackImageURL,
textcolor: "#eeeeee",
accentcolor: "#111111",
});
@@ -50,17 +52,17 @@ this.LightweightThemes = {
resolve("darkLWT");
}, 500);
});
},
},
lightLWT: {
selectors: ["#navigator-toolbox"],
- applyConfig() {
+ applyConfig({browserWindow}) {
LightweightThemeManager.setLocalTheme({
id: "white",
name: "white",
headerURL: LightweightThemes._whiteImageURL,
textcolor: "#111111",
accentcolor: "#eeeeee",
});
// Wait for LWT listener
@@ -69,21 +71,21 @@ this.LightweightThemes = {
resolve("lightLWT");
}, 500);
});
},
},
compactLight: {
selectors: ["#navigator-toolbox"],
- applyConfig() {
+ applyConfig({browserWindow}) {
LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme("firefox-compact-light@mozilla.org");
},
},
compactDark: {
selectors: ["#navigator-toolbox"],
- applyConfig() {
+ applyConfig({browserWindow}) {
LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme("firefox-compact-dark@mozilla.org");
},
},
},
};
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm
@@ -7,109 +7,122 @@
this.EXPORTED_SYMBOLS = ["PermissionPrompts"];
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/E10SUtils.jsm");
Cu.import("resource://testing-common/ContentTask.jsm");
Cu.import("resource://testing-common/BrowserTestUtils.jsm");
+Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
const URL = "https://test1.example.com/browser/browser/tools/mozscreenshots/mozscreenshots/extension/mozscreenshots/browser/chrome/mozscreenshots/lib/permissionPrompts.html";
let lastTab = null;
this.PermissionPrompts = {
init(libDir) {
Services.prefs.setBoolPref("browser.storageManager.enabled", true);
Services.prefs.setBoolPref("media.navigator.permission.fake", true);
Services.prefs.setBoolPref("extensions.install.requireBuiltInCerts", false);
Services.prefs.setBoolPref("signon.rememberSignons", true);
},
configurations: {
shareDevices: {
selectors: ["#notification-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
await closeLastTab();
- await clickOn("#webRTC-shareDevices");
+ await clickOn("#webRTC-shareDevices", browserWindow);
},
},
shareMicrophone: {
selectors: ["#notification-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
await closeLastTab();
- await clickOn("#webRTC-shareMicrophone");
+ await clickOn("#webRTC-shareMicrophone", browserWindow);
},
},
shareVideoAndMicrophone: {
selectors: ["#notification-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
await closeLastTab();
- await clickOn("#webRTC-shareDevices2");
+ await clickOn("#webRTC-shareDevices2", browserWindow);
},
},
shareScreen: {
selectors: ["#notification-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
await closeLastTab();
- await clickOn("#webRTC-shareScreen");
+ await clickOn("#webRTC-shareScreen", browserWindow);
},
},
geo: {
selectors: ["#notification-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
await closeLastTab();
- await clickOn("#geo");
+ await clickOn("#geo", browserWindow);
},
},
+ // For this config and the one below, the private test would stall
+ // I'm assuming this is because private window doesn't allow this?
+ // I set up a quick skip for now
persistentStorage: {
selectors: ["#notification-popup"],
- async applyConfig() {
- await closeLastTab();
- await clickOn("#persistent-storage");
+ async applyConfig({browserWindow}) {
+ if (!PrivateBrowsingUtils.isWindowPrivate(browserWindow)) {
+ await closeLastTab();
+ await clickOn("#persistent-storage", browserWindow);
+ return Promise.resolve();
+ }
+
+ return Promise.reject("skip for private browsing");
},
},
loginCapture: {
selectors: ["#notification-popup"],
- async applyConfig() {
- await closeLastTab();
- await clickOn("#login-capture");
+ async applyConfig({browserWindow}) {
+ if (!PrivateBrowsingUtils.isWindowPrivate(browserWindow)) {
+ await closeLastTab();
+ await clickOn("#login-capture", browserWindow);
+ return Promise.resolve();
+ }
+
+ return Promise.reject("skip for private browsing");
},
},
notifications: {
selectors: ["#notification-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
await closeLastTab();
- await clickOn("#web-notifications");
+ await clickOn("#web-notifications", browserWindow);
},
},
addons: {
selectors: ["#notification-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
Services.prefs.setBoolPref("xpinstall.whitelist.required", true);
await closeLastTab();
- await clickOn("#addons");
+ await clickOn("#addons", browserWindow);
},
},
addonsNoWhitelist: {
selectors: ["#notification-popup"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
Services.prefs.setBoolPref("xpinstall.whitelist.required", false);
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
let notification = browserWindow.document.getElementById("addon-install-confirmation-notification");
await closeLastTab();
await clickOn("#addons");
// We want to skip the progress-notification, so we wait for
// the install-confirmation screen to be "not hidden" = shown.
await BrowserTestUtils.waitForCondition(() => !notification.hasAttribute("hidden"),
@@ -122,19 +135,17 @@ this.PermissionPrompts = {
async function closeLastTab() {
if (!lastTab) {
return;
}
await BrowserTestUtils.removeTab(lastTab);
lastTab = null;
}
-async function clickOn(selector) {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
-
+async function clickOn(selector, browserWindow) {
// Save the tab so we can close it later.
lastTab = await BrowserTestUtils.openNewForegroundTab(browserWindow.gBrowser, URL);
await ContentTask.spawn(lastTab.linkedBrowser, selector, async function(arg) {
E10SUtils.wrapHandlingUserInput(content, true, function() {
let element = content.document.querySelector(arg);
element.click();
});
--- 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://testing-common/TestUtils.jsm");
Cu.import("resource://testing-common/ContentTask.jsm");
+// TODO: init...
this.Preferences = {
init(libDir) {
let panes = [
["paneGeneral"],
["paneGeneral", browsingGroup],
["paneGeneral", connectionDialog],
["paneSearch"],
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Tabs.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Tabs.jsm
@@ -17,31 +17,29 @@ Cu.import("resource://gre/modules/Servic
Cu.import("resource://gre/modules/Timer.jsm");
this.Tabs = {
init(libDir) {},
configurations: {
fiveTabs: {
selectors: ["#tabbrowser-tabs"],
- async applyConfig() {
- fiveTabsHelper();
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
+ fiveTabsHelper(browserWindow);
hoverTab(browserWindow.gBrowser.tabs[3]);
await new Promise((resolve, reject) => {
setTimeout(resolve, 3000);
});
},
},
fourPinned: {
selectors: ["#tabbrowser-tabs"],
- async applyConfig() {
- fiveTabsHelper();
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
+ fiveTabsHelper(browserWindow);
let tab = browserWindow.gBrowser.addTab(PREFS_TAB);
browserWindow.gBrowser.pinTab(tab);
tab = browserWindow.gBrowser.addTab(CUST_TAB);
browserWindow.gBrowser.pinTab(tab);
tab = browserWindow.gBrowser.addTab("about:privatebrowsing");
browserWindow.gBrowser.pinTab(tab);
tab = browserWindow.gBrowser.addTab("about:home");
browserWindow.gBrowser.pinTab(tab);
@@ -56,20 +54,19 @@ this.Tabs = {
await new Promise((resolve, reject) => {
setTimeout(resolve, 3000);
});
},
},
twoPinnedWithOverflow: {
selectors: ["#tabbrowser-tabs"],
- async applyConfig() {
- fiveTabsHelper();
+ async applyConfig({browserWindow}) {
+ fiveTabsHelper(browserWindow);
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
browserWindow.gBrowser.loadTabs([
PREFS_TAB,
CUST_TAB,
"about:home",
DEFAULT_FAVICON_TAB,
"about:newtab",
"about:addons",
"about:home",
@@ -111,49 +108,49 @@ this.Tabs = {
},
},
},
};
/* helpers */
-function fiveTabsHelper() {
+function fiveTabsHelper(browserWindow) {
// some with no favicon and some with. Selected tab in middle.
- closeAllButOneTab("about:addons");
+ closeAllButOneTab("about:addons", browserWindow);
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
browserWindow.gBrowser.loadTabs([
"about:addons",
"about:home",
DEFAULT_FAVICON_TAB,
"about:newtab",
CUST_TAB,
],
{
inBackground: true,
replace: true,
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal()
});
browserWindow.gBrowser.selectTabAtIndex(1);
}
-function closeAllButOneTab(url = "about:blank") {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+function closeAllButOneTab(url = "about:blank", browserWindow) {
let gBrowser = browserWindow.gBrowser;
// Close all tabs except the last so we don't quit the browser.
while (gBrowser.tabs.length > 1)
gBrowser.removeTab(gBrowser.selectedTab, {animate: false});
gBrowser.selectedBrowser.loadURI(url);
if (gBrowser.selectedTab.pinned)
gBrowser.unpinTab(gBrowser.selectedTab);
let newTabButton = browserWindow.document.getAnonymousElementByAttribute(browserWindow.gBrowser.tabContainer, "class", "tabs-newtab-button toolbarbutton-1");
hoverTab(newTabButton, false);
}
+// TODO: test skips fourPinned config, saying error on line 152
+// I believe this is unrelated to my changes
function hoverTab(tab, hover = true) {
const inIDOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
if (hover) {
inIDOMUtils.addPseudoClassLock(tab, ":hover");
} else {
inIDOMUtils.clearPseudoClassLocks(tab);
}
// XXX TODO: this isn't necessarily testing what we ship
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/TabsInTitlebar.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/TabsInTitlebar.jsm
@@ -14,26 +14,26 @@ Cu.import("resource://gre/modules/Servic
this.TabsInTitlebar = {
init(libDir) {},
configurations: {
tabsInTitlebar: {
selectors: ["#navigator-toolbox"],
- async applyConfig() {
+ async applyConfig({browserWindow}) {
if (Services.appinfo.OS == "Linux") {
return Promise.reject("TabsInTitlebar isn't supported on Linux");
}
Services.prefs.setBoolPref(PREF_TABS_IN_TITLEBAR, true);
return undefined;
},
},
tabsOutsideTitlebar: {
selectors: ["#navigator-toolbox"].concat(Services.appinfo.OS == "Linux" ? [] : ["#titlebar"]),
- async applyConfig() {
+ async applyConfig({browserWindow}) {
Services.prefs.setBoolPref(PREF_TABS_IN_TITLEBAR, false);
},
},
},
};
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Toolbars.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Toolbars.jsm
@@ -11,48 +11,44 @@ const {classes: Cc, interfaces: Ci, util
Cu.import("resource://gre/modules/Services.jsm");
this.Toolbars = {
init(libDir) {},
configurations: {
onlyNavBar: {
selectors: ["#navigator-toolbox"],
- async applyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
let personalToolbar = browserWindow.document.getElementById("PersonalToolbar");
browserWindow.setToolbarVisibility(personalToolbar, false);
- toggleMenubarIfNecessary(false);
+ toggleMenubarIfNecessary(false, browserWindow);
},
},
allToolbars: {
selectors: ["#navigator-toolbox"],
- async applyConfig() { // Boookmarks and menubar
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) { // Boookmarks and menubar
let personalToolbar = browserWindow.document.getElementById("PersonalToolbar");
browserWindow.setToolbarVisibility(personalToolbar, true);
- toggleMenubarIfNecessary(true);
+ toggleMenubarIfNecessary(true, browserWindow);
},
- async verifyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async verifyConfig({browserWindow}) {
if (browserWindow.fullScreen) {
return Promise.reject("The bookmark toolbar and menubar are not shown in fullscreen.");
}
return undefined;
},
},
},
};
// helpers
-function toggleMenubarIfNecessary(visible) {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+function toggleMenubarIfNecessary(visible, browserWindow) {
// The menubar is not shown on OS X or while in fullScreen
if (Services.appinfo.OS != "Darwin" /* && !browserWindow.fullScreen*/) {
let menubar = browserWindow.document.getElementById("toolbar-menubar");
browserWindow.setToolbarVisibility(menubar, visible);
}
}
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/UIDensities.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/UIDensities.jsm
@@ -12,31 +12,28 @@ Cu.import("resource://gre/modules/Servic
this.UIDensities = {
init(libDir) {},
configurations: {
compactDensity: {
selectors: ["#navigator-toolbox, #appMenu-popup, #widget-overflow"],
- async applyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
browserWindow.gCustomizeMode.setUIDensity(browserWindow.gUIDensity.MODE_COMPACT);
},
},
normalDensity: {
selectors: ["#navigator-toolbox, #appMenu-popup, #widget-overflow"],
- async applyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
browserWindow.gCustomizeMode.setUIDensity(browserWindow.gUIDensity.MODE_NORMAL);
},
},
touchDensity: {
selectors: ["#navigator-toolbox, #appMenu-popup, #widget-overflow"],
- async applyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
browserWindow.gCustomizeMode.setUIDensity(browserWindow.gUIDensity.MODE_TOUCH);
},
},
},
};
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/WindowSize.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/WindowSize.jsm
@@ -16,47 +16,44 @@ this.WindowSize = {
init(libDir) {
Services.prefs.setBoolPref("browser.fullscreen.autohide", false);
},
configurations: {
maximized: {
selectors: [":root"],
- async applyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
await toggleFullScreen(browserWindow, false);
// Wait for the Lion fullscreen transition to end as there doesn't seem to be an event
// and trying to maximize while still leaving fullscreen doesn't work.
await new Promise((resolve, reject) => {
setTimeout(function waitToLeaveFS() {
browserWindow.maximize();
resolve();
}, 5000);
});
},
},
normal: {
selectors: [":root"],
- async applyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
await toggleFullScreen(browserWindow, false);
browserWindow.restore();
await new Promise((resolve, reject) => {
setTimeout(resolve, 5000);
});
},
},
fullScreen: {
selectors: [":root"],
- async applyConfig() {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
+ async applyConfig({browserWindow}) {
await toggleFullScreen(browserWindow, true);
// OS X Lion fullscreen transition takes a while
await new Promise((resolve, reject) => {
setTimeout(resolve, 5000);
});
},
},
},