now checks to see if nonexistent configurations have been specified draft
authorRand Mustafa <rndmustafa@gmail.com>
Thu, 21 Sep 2017 19:15:32 -0400
changeset 669213 76f7126ca3e1baffb530d5419a17e8d6d7507de5
parent 669212 a47398c71bcd8afe72aff9026257652065118c23
child 669214 5dbc375879fdcf1b85be0a70f3d29896130832fa
push id81256
push userbmo:rndmustafa@gmail.com
push dateFri, 22 Sep 2017 18:13:11 +0000
milestone57.0a1
now checks to see if nonexistent configurations have been specified MozReview-Commit-ID: Ara8iRu2pPP
browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
--- 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]);