Bug 1242101 - Only capture mozscreenshots for Nightlies, try pushes and local builds. r=felipe
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Mon, 25 Jan 2016 13:57:37 -0800
changeset 325604 afd78392739da09bf2d7edfa88527df7d99fd510
parent 325556 1bd84f34814d56257b6fed68cf987a0a9291ddcb
child 325605 7eb0141079d34b1b0c03101ba9dea8e41b6b0672
push id10011
push usercmanchester@mozilla.com
push dateTue, 26 Jan 2016 02:20:25 +0000
reviewersfelipe
bugs1242101
milestone46.0a1
Bug 1242101 - Only capture mozscreenshots for Nightlies, try pushes and local builds. r=felipe Don't generate images unless they're wanted and useful.
browser/tools/mozscreenshots/browser_screenshots.js
browser/tools/mozscreenshots/head.js
--- a/browser/tools/mozscreenshots/browser_screenshots.js
+++ b/browser/tools/mozscreenshots/browser_screenshots.js
@@ -1,17 +1,20 @@
 /* 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";
 
 const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
 
-add_task(function* test() {
+add_task(function* capture() {
+  if (!shouldCapture()) {
+    return;
+  }
   let { TestRunner } = Cu.import("chrome://mozscreenshots/content/TestRunner.jsm", {});
   let sets = ["TabsInTitlebar", "Tabs", "WindowSize", "Toolbars", "LightweightThemes"];
   let setsEnv = env.get("MOZSCREENSHOTS_SETS");
   if (setsEnv) {
     sets = setsEnv.trim().split(",");
   }
 
   yield TestRunner.start(sets);
--- a/browser/tools/mozscreenshots/head.js
+++ b/browser/tools/mozscreenshots/head.js
@@ -1,20 +1,34 @@
 /* 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";
 
 const {AddonWatcher} = Cu.import("resource://gre/modules/AddonWatcher.jsm", {});
-let TestRunner;
 
 function setup() {
   requestLongerTimeout(10);
 
   info("Checking for mozscreenshots extension");
-  AddonManager.getAddonByID("mozscreenshots@mozilla.org", function(aAddon) {
-    isnot(aAddon, null, "The mozscreenshots extension should be installed");
-    AddonWatcher.ignoreAddonPermanently(aAddon.id);
+  return new Promise((resolve) => {
+    AddonManager.getAddonByID("mozscreenshots@mozilla.org", function(aAddon) {
+      isnot(aAddon, null, "The mozscreenshots extension should be installed");
+      AddonWatcher.ignoreAddonPermanently(aAddon.id);
+      resolve();
+    });
   });
 }
 
+function shouldCapture() {
+  // Automation isn't able to schedule test jobs to only run on nightlies so we handle it here
+  // (see also: bug 1116275). Try pushes and local builds should also capture.
+  let capture = AppConstants.MOZ_UPDATE_CHANNEL == "nightly" ||
+                AppConstants.SOURCE_REVISION_URL.includes("/try/rev/") ||
+                AppConstants.SOURCE_REVISION_URL == "";
+  if (!capture) {
+    ok(true, "Capturing is disabled for this MOZ_UPDATE_CHANNEL or REPO");
+  }
+  return capture;
+}
+
 add_task(setup);