now checks to see if nonexistent configurations have been specified
MozReview-Commit-ID: Ara8iRu2pPP
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
@@ -117,35 +117,44 @@ 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("[")) {
+ if (setName.includes("[")) {
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");
}
+ //Checks to see if nonexistent configuration have been specified
+ if(restrictions != null) {
+ for(let restriction of restrictions){
+ if( !configurationNames.includes(restriction) ){
+ throw new Error(restriction + " is a nonexistent configuration");
+ }
+ }
+ }
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]);