summaryrefslogtreecommitdiffstats
path: root/application/basilisk/tools/mozscreenshots/head.js
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-06-04 13:17:38 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-06-04 13:17:38 +0200
commita1be17c1cea81ebb1e8b131a662c698d78f3f7f2 (patch)
treea92f7de513be600cc07bac458183e9af40e00c06 /application/basilisk/tools/mozscreenshots/head.js
parentbf11fdd304898ac675e39b01b280d39550e419d0 (diff)
downloadUXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.tar
UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.tar.gz
UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.tar.lz
UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.tar.xz
UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.zip
Issue #303 Part 1: Move basilisk files from /browser to /application/basilisk
Diffstat (limited to 'application/basilisk/tools/mozscreenshots/head.js')
-rw-r--r--application/basilisk/tools/mozscreenshots/head.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/application/basilisk/tools/mozscreenshots/head.js b/application/basilisk/tools/mozscreenshots/head.js
new file mode 100644
index 000000000..c1702ab08
--- /dev/null
+++ b/application/basilisk/tools/mozscreenshots/head.js
@@ -0,0 +1,53 @@
+/* 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/. */
+
+/* exported TestRunner, shouldCapture */
+
+"use strict";
+
+const {AddonWatcher} = Cu.import("resource://gre/modules/AddonWatcher.jsm", {});
+const chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
+const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
+const EXTENSION_DIR = "chrome://mochitests/content/extensions/mozscreenshots/browser/";
+
+let TestRunner;
+
+function* setup() {
+ requestLongerTimeout(10);
+
+ info("installing extension temporarily");
+ let chromeURL = Services.io.newURI(EXTENSION_DIR, null, null);
+ let dir = chromeRegistry.convertChromeURL(chromeURL).QueryInterface(Ci.nsIFileURL).file;
+ yield AddonManager.installTemporaryAddon(dir);
+
+ info("Checking for mozscreenshots extension");
+ return new Promise((resolve) => {
+ AddonManager.getAddonByID("mozscreenshots@mozilla.org", function(aAddon) {
+ isnot(aAddon, null, "The mozscreenshots extension should be installed");
+ AddonWatcher.ignoreAddonPermanently(aAddon.id);
+ TestRunner = Cu.import("chrome://mozscreenshots/content/TestRunner.jsm", {}).TestRunner;
+ resolve();
+ });
+ });
+}
+
+function shouldCapture() {
+ // Try pushes only capture in browser_screenshots.js with MOZSCREENSHOTS_SETS.
+ if (env.get("MOZSCREENSHOTS_SETS")) {
+ ok(true, "MOZSCREENSHOTS_SETS was specified so only capture what was " +
+ "requested (in browser_screenshots.js)");
+ return false;
+ }
+
+ // Automation isn't able to schedule test jobs to only run on nightlies so we handle it here
+ // (see also: bug 1116275).
+ let capture = AppConstants.MOZ_UPDATE_CHANNEL == "nightly" ||
+ AppConstants.SOURCE_REVISION_URL == "";
+ if (!capture) {
+ ok(true, "Capturing is disabled for this MOZ_UPDATE_CHANNEL or REPO");
+ }
+ return capture;
+}
+
+add_task(setup);