Bug 1247149 - mozscreenshots: Support restricting configurations in sets. r?MattN
MozReview-Commit-ID: LTT7auJfcHa
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
@@ -99,31 +99,47 @@ 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) {
+ let restrictions = null;
+ if (setName.contains("[")) {
+ let match = /\[([^\]]+)\]$/.exec(setName);
+ if (!match) {
+ throw new Error(`Invalid restrictions in ${setName}`);
+ }
+ // Trim the restrictions from the set name.
+ setName = setName.slice(0, match.index);
+ restrictions = match[1].split(",").reduce((set, name) =>
+ set.add(name.trim()), new Set());
+ }
try {
let imported = {};
Cu.import("chrome://mozscreenshots/content/configurations/" + setName + ".jsm",
imported);
imported[setName].init(this._libDir);
let configurationNames = Object.keys(imported[setName].configurations);
if (!configurationNames.length) {
throw new Error(setName + " has no configurations for this environment");
}
+ let configurations = [];
for (let config of configurationNames) {
// Automatically set the name property of the configuration object to
// its name from the configuration object.
imported[setName].configurations[config].name = config;
+ // Filter restricted configurations.
+ if (!restrictions || restrictions.has(config)) {
+ configurations.push(imported[setName].configurations[config]);
+ }
}
- sets.push(imported[setName].configurations);
+ sets.push(configurations);
} catch (ex) {
log.error("Error loading set: " + setName);
log.error(ex);
throw ex;
}
}
return sets;
},