Bug 1241284: mozscreenshots: Move TestRunner.init to `start` to avoid unnecessary work in other suites. r=bgrins draft
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 20 Jan 2016 13:26:24 -0800
changeset 323667 8d5be3b1324270d6c8588e2e53282531aa9dd336
parent 323666 31202b9037c8aac5e5b172c9a00337a0605880cf
child 513252 50954eda24374e6baa7e5dc65d05d4f8d88aa9b2
push id9762
push usermozilla@noorenberghe.ca
push dateWed, 20 Jan 2016 21:31:00 +0000
reviewersbgrins
bugs1241284
milestone46.0a1
Bug 1241284: mozscreenshots: Move TestRunner.init to `start` to avoid unnecessary work in other suites. r=bgrins The extension is installed in all mochitest suites so we shouldn't do work that's not needed in those suites.
browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/TestRunner.jsm
@@ -33,56 +33,57 @@ XPCOMUtils.defineLazyGetter(this, "log",
 this.TestRunner = {
   combos: null,
   completedCombos: 0,
   currentComboIndex: 0,
   _lastCombo: null,
   _libDir: null,
 
   init(extensionPath) {
-    let subDirs = ["mozscreenshots",
-                   (new Date()).toISOString().replace(/:/g, "-") + "_" + Services.appinfo.OS];
-    let screenshotPath = FileUtils.getFile("TmpD", subDirs).path;
-
-    const MOZ_UPLOAD_DIR = env.get("MOZ_UPLOAD_DIR");
-    if (MOZ_UPLOAD_DIR) {
-      screenshotPath = MOZ_UPLOAD_DIR;
-    }
-
-    log.info("Saving screenshots to:", screenshotPath);
-    log.debug("TestRunner.init");
-
-    let screenshotPrefix = Services.appinfo.appBuildID + "_";
-    Screenshot.init(screenshotPath, extensionPath, screenshotPrefix);
-    this._libDir = extensionPath.QueryInterface(Ci.nsIFileURL).file.clone();
-    this._libDir.append("chrome");
-    this._libDir.append("mozscreenshots");
-    this._libDir.append("lib");
-
-    // Setup some prefs
-    Services.prefs.setCharPref("browser.aboutHomeSnippets.updateUrl", "data:");
-    Services.prefs.setCharPref("extensions.ui.lastCategory", "addons://list/extension");
-    // Don't let the caret blink since it causes false positives for image diffs
-    Services.prefs.setIntPref("ui.caretBlinkTime", -1);
+    this._extensionPath = extensionPath;
   },
 
   /**
    * Load specified sets, execute all combinations of them, and capture screenshots.
    */
   start(setNames = null) {
     setNames = setNames || defaultSetNames;
     let sets = this.loadSets(setNames);
 
     log.info(sets.length + " sets:", setNames);
     this.combos = new LazyProduct(sets);
     log.info(this.combos.length + " combinations");
 
     this.currentComboIndex = this.completedCombos = 0;
     this._lastCombo = null;
 
+    let subDirs = ["mozscreenshots",
+                   (new Date()).toISOString().replace(/:/g, "-") + "_" + Services.appinfo.OS];
+    let screenshotPath = FileUtils.getFile("TmpD", subDirs).path;
+
+    const MOZ_UPLOAD_DIR = env.get("MOZ_UPLOAD_DIR");
+    if (MOZ_UPLOAD_DIR) {
+      screenshotPath = MOZ_UPLOAD_DIR;
+    }
+
+    log.info("Saving screenshots to:", screenshotPath);
+
+    let screenshotPrefix = Services.appinfo.appBuildID + "_";
+    Screenshot.init(screenshotPath, this._extensionPath, screenshotPrefix);
+    this._libDir = this._extensionPath.QueryInterface(Ci.nsIFileURL).file.clone();
+    this._libDir.append("chrome");
+    this._libDir.append("mozscreenshots");
+    this._libDir.append("lib");
+
+    // Setup some prefs
+    Services.prefs.setCharPref("browser.aboutHomeSnippets.updateUrl", "data:");
+    Services.prefs.setCharPref("extensions.ui.lastCategory", "addons://list/extension");
+    // Don't let the caret blink since it causes false positives for image diffs
+    Services.prefs.setIntPref("ui.caretBlinkTime", -1);
+
     return Task.spawn(function* doStart() {
       for (let i = 0; i < this.combos.length;
            i++){
         this.currentComboIndex = i;
         yield* this._performCombo(this.combos.item(this.currentComboIndex));
       }
 
       log.info("Done: Completed " + this.completedCombos + " out of " +