Bug 1241284: mozscreenshots: Move TestRunner.init to `start` to avoid unnecessary work in other suites. r=bgrins
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 20 Jan 2016 13:26:24 -0800
changeset 303134 9300568c634b2f76eb5893b3630e1efe76c7f49d
parent 303133 31202b9037c8aac5e5b172c9a00337a0605880cf
child 303135 afb7e27d06f569b5dbc6d477ce09135101fd5097
push id8978
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 14:05:32 +0000
treeherdermozilla-aurora@b9a803752a2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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,58 @@ XPCOMUtils.defineLazyGetter(this, "log",
 this.TestRunner = {
   combos: null,
   completedCombos: 0,
   currentComboIndex: 0,
   _lastCombo: null,
   _libDir: null,
 
   init(extensionPath) {
+    this._extensionPath = extensionPath;
+  },
+
+  /**
+   * Load specified sets, execute all combinations of them, and capture screenshots.
+   */
+  start(setNames = null) {
+    setNames = setNames || defaultSetNames;
+
     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();
+    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);
-  },
-
-  /**
-   * 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;
 
+    // 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 " +