Can now choose multiple configurations within a set eg Toolbars[foo,bar]. r?jaws
draft
Can now choose multiple configurations within a set eg Toolbars[foo,bar]. r?jaws
MozReview-Commit-ID: GbNctrucFHw
--- a/browser/tools/mozscreenshots/browser_screenshots.js
+++ b/browser/tools/mozscreenshots/browser_screenshots.js
@@ -1,16 +1,56 @@
/* 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";
+/**
+ * Finds the index of the first comma that is not enclosed within square brackets.
+ * @param {String} env - the string that needs to be searched
+ * @return {Integer} index of valid comma or -1 if not found.
+ */
+function findComma(env){
+ let ignore = false;
+ for(let i = 0; i < env.length; i++){
+ if(env[i] === '[')
+ ignore = true;
+ else if(env[i] === ']')
+ ignore = false;
+ else if(env[i] === ',' && ignore === false){
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+/**
+ * Splits the environment variable around commas not enclosed in brackets.
+ * @param {String} env - The environment variable
+ * @return {String[]} Array of strings containing the configurations
+ * e.g. ["Toolbars[onlyNavBar,allToolbars]","DevTools[jsdebugger,webconsole]","Tabs"]
+ */
+function splitEnv(env){
+ let result = [];
+
+ let commaIndex = findComma(env);
+ while( commaIndex != -1 ){
+ result.push( env.slice(0, commaIndex).trim() );
+ env = env.slice(commaIndex+1);
+ commaIndex = findComma(env);
+ }
+ result.push( env.trim() );
+
+ return result;
+}
+
add_task(async function capture() {
let setsEnv = env.get("MOZSCREENSHOTS_SETS");
if (!setsEnv) {
ok(true, "MOZSCREENSHOTS_SETS wasn't specified so there's nothing to capture");
return;
}
- let sets = setsEnv.trim().split(",");
+ let sets = splitEnv(setsEnv);
await TestRunner.start(sets);
});