Bug 1248087 - screenshots: Add preferences and devtools scheduled runs. r=kitcambridge

MozReview-Commit-ID: 708wpg9Reca

--HG--
extra : rebase_source : e239feab74ee96c836cc78af641155f4b0662fff
This commit is contained in:
Matthew Noorenberghe 2016-02-13 17:44:05 -08:00
Родитель f93270dc71
Коммит beca458e3e
12 изменённых файлов: 115 добавлений и 26 удалений

Просмотреть файл

@ -4,4 +4,3 @@ support-files =
head.js
[browser_screenshots.js]
tags = screenshots

Просмотреть файл

@ -5,15 +5,12 @@
"use strict";
add_task(function* capture() {
if (!shouldCapture()) {
let setsEnv = env.get("MOZSCREENSHOTS_SETS");
if (!setsEnv) {
ok(true, "MOZSCREENSHOTS_SETS wasn't specified so there's nothing to capture");
return;
}
let { TestRunner } = Cu.import("chrome://mozscreenshots/content/TestRunner.jsm", {});
let sets = ["TabsInTitlebar", "Tabs", "WindowSize", "Toolbars", "LightweightThemes"];
let setsEnv = env.get("MOZSCREENSHOTS_SETS");
if (setsEnv) {
sets = setsEnv.trim().split(",");
}
let sets = setsEnv.trim().split(",");
yield TestRunner.start(sets);
});

Просмотреть файл

@ -0,0 +1,6 @@
[DEFAULT]
subsuite = screenshots
support-files =
../head.js
[browser_devtools.js]

Просмотреть файл

@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
"use strict";
add_task(function* capture() {
if (!shouldCapture()) {
return;
}
let sets = ["DevTools"];
yield TestRunner.start(sets);
});

Просмотреть файл

@ -6,6 +6,7 @@
const {AddonWatcher} = Cu.import("resource://gre/modules/AddonWatcher.jsm", {});
const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
let TestRunner;
function setup() {
requestLongerTimeout(20);
@ -15,18 +16,25 @@ function setup() {
AddonManager.getAddonByID("mozscreenshots@mozilla.org", function(aAddon) {
isnot(aAddon, null, "The mozscreenshots extension should be installed");
AddonWatcher.ignoreAddonPermanently(aAddon.id);
TestRunner = Cu.import("chrome://mozscreenshots/content/TestRunner.jsm", {}).TestRunner;
resolve();
});
});
}
function shouldCapture() {
// Try pushes only capture in browser_screenshots.js with MOZSCREENSHOTS_SETS.
if (env.get("MOZSCREENSHOTS_SETS")) {
ok(true, "MOZSCREENSHOTS_SETS was specified so only capture what was " +
"requested (in browser_screenshots.js)");
return false;
}
// Automation isn't able to schedule test jobs to only run on nightlies so we handle it here
// (see also: bug 1116275). Try pushes and local builds should also capture.
// (see also: bug 1116275).
let capture = AppConstants.MOZ_UPDATE_CHANNEL == "nightly" ||
(AppConstants.SOURCE_REVISION_URL.includes("/try/rev/") &&
env.get("MOZSCREENSHOTS_SETS")) ||
AppConstants.SOURCE_REVISION_URL == "";
AppConstants.SOURCE_REVISION_URL == "" ||
AppConstants.SOURCE_REVISION_URL == "1"; // bug 1248027
if (!capture) {
ok(true, "Capturing is disabled for this MOZ_UPDATE_CHANNEL or REPO");
}

Просмотреть файл

@ -4,7 +4,14 @@
# 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/.
BROWSER_CHROME_MANIFESTS += ['browser.ini']
BROWSER_CHROME_MANIFESTS += [
# Each test is in it's own directory so it gets run in a clean profile with
# run-by-dir.
'browser.ini',
'devtools/browser.ini',
'preferences/browser.ini',
'primaryUI/browser.ini',
]
TEST_DIRS += [
'mozscreenshots/extension',

Просмотреть файл

@ -11,7 +11,6 @@ const defaultSetNames = ["TabsInTitlebar", "Tabs", "WindowSize", "Toolbars", "Li
const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
const HOME_PAGE = "chrome://mozscreenshots/content/lib/mozscreenshots.html";
Cu.import("resource://testing-common/BrowserTestUtils.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Task.jsm");
@ -19,6 +18,9 @@ Cu.import("resource://gre/modules/Timer.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "BrowserTestUtils",
"resource://testing-common/BrowserTestUtils.jsm");
Cu.import("chrome://mozscreenshots/content/Screenshot.jsm");
// Create a new instance of the ConsoleAPI so we can control the maxLogLevel with a pref.
@ -42,6 +44,7 @@ this.TestRunner = {
_libDir: null,
init(extensionPath) {
log.info("init");
this._extensionPath = extensionPath;
},

Просмотреть файл

@ -9,7 +9,9 @@ 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");
this.Preferences = {
@ -31,7 +33,7 @@ this.Preferences = {
["paneAdvanced", "encryptionTab"],
];
for (let [primary, advanced] of panes) {
let configName = primary + ("-" + advanced || "");
let configName = primary.replace(/^pane/, "prefs") + (advanced ? "-" + advanced : "");
this.configurations[configName] = {};
this.configurations[configName].applyConfig = prefHelper.bind(null, primary, advanced);
}
@ -40,14 +42,27 @@ this.Preferences = {
configurations: {},
};
function prefHelper(primary, advanced) {
return new Promise((resolve) => {
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) => {
browserWindow.addEventListener("MozAfterPaint", function paneSwitch() {
browserWindow.removeEventListener("MozAfterPaint", paneSwitch);
resolve();
});
});
} else {
readyPromise = TestUtils.topicObserved("advanced-pane-loaded");
}
if (primary == "paneAdvanced") {
browserWindow.openAdvancedPreferences(advanced);
} else {
browserWindow.openPreferences(primary);
}
setTimeout(resolve, 50);
yield readyPromise;
});
}

Просмотреть файл

@ -0,0 +1,6 @@
[DEFAULT]
subsuite = screenshots
support-files =
../head.js
[browser_preferences.js]

Просмотреть файл

@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
"use strict";
add_task(function* capture() {
if (!shouldCapture()) {
return;
}
let sets = ["Preferences"];
yield TestRunner.start(sets);
});

Просмотреть файл

@ -0,0 +1,6 @@
[DEFAULT]
subsuite = screenshots
support-files =
../head.js
[browser_primaryUI.js]

Просмотреть файл

@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
"use strict";
add_task(function* capture() {
if (!shouldCapture()) {
return;
}
let sets = ["TabsInTitlebar", "Tabs", "WindowSize", "Toolbars", "LightweightThemes"];
yield TestRunner.start(sets);
});