summaryrefslogtreecommitdiffstats
path: root/browser/tools/mozscreenshots/head.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /browser/tools/mozscreenshots/head.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/tools/mozscreenshots/head.js')
-rw-r--r--browser/tools/mozscreenshots/head.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/browser/tools/mozscreenshots/head.js b/browser/tools/mozscreenshots/head.js
new file mode 100644
index 0000000000..2c7fc4c3fd
--- /dev/null
+++ b/browser/tools/mozscreenshots/head.js
@@ -0,0 +1,64 @@
+/* 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 chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(
+ Ci.nsIChromeRegistry
+);
+const EXTENSION_DIR =
+ "chrome://mochitests/content/browser/browser/tools/mozscreenshots/mozscreenshots/extension/mozscreenshots/browser/";
+
+let TestRunner;
+
+async function setup() {
+ // This timeout doesn't actually end the job even if it is hit - the buildbot timeout will
+ // handle things for us if the test actually hangs.
+ requestLongerTimeout(100);
+
+ // Generate output so mozprocess knows we're still alive for the long session.
+ SimpleTest.requestCompleteLog();
+
+ info("installing extension temporarily");
+ let chromeURL = Services.io.newURI(EXTENSION_DIR);
+ let dir = chromeRegistry
+ .convertChromeURL(chromeURL)
+ .QueryInterface(Ci.nsIFileURL).file;
+ await AddonManager.installTemporaryAddon(dir);
+
+ info("Checking for mozscreenshots extension");
+
+ let aAddon = await AddonManager.getAddonByID("mozscreenshots@mozilla.org");
+ isnot(aAddon, null, "The mozscreenshots extension should be installed");
+ TestRunner = ChromeUtils.import("resource://mozscreenshots/TestRunner.jsm")
+ .TestRunner;
+ TestRunner.initTest(this);
+}
+
+/**
+ * Used by pre-defined sets of configurations to decide whether to run for a build.
+ * @note This is not used by browser_screenshots.js which handles when MOZSCREENSHOTS_SETS is set.
+ * @return {bool} whether to capture screenshots.
+ */
+function shouldCapture() {
+ if (Services.env.get("MOZSCREENSHOTS_SETS")) {
+ ok(
+ true,
+ "MOZSCREENSHOTS_SETS was specified so only capture what was " +
+ "requested (in browser_screenshots.js)"
+ );
+ return false;
+ }
+
+ if (AppConstants.MOZ_UPDATE_CHANNEL == "nightly") {
+ ok(true, "Screenshots aren't captured on Nightlies");
+ return false;
+ }
+
+ return true;
+}
+
+add_setup(setup);