Merge mozilla-central to autoland. a=merge CLOSED TREE
[gecko.git] / browser / tools / mozscreenshots / head.js
bloba1876b9c30ae0b2a871f8fddfa6ef4a656e2a39c
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /* exported TestRunner, shouldCapture */
7 "use strict";
9 const chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(
10   Ci.nsIChromeRegistry
12 const EXTENSION_DIR =
13   "chrome://mochitests/content/browser/browser/tools/mozscreenshots/mozscreenshots/extension/mozscreenshots/browser/";
15 let TestRunner;
17 async function setup() {
18   // This timeout doesn't actually end the job even if it is hit - the buildbot timeout will
19   // handle things for us if the test actually hangs.
20   requestLongerTimeout(100);
22   // Generate output so mozprocess knows we're still alive for the long session.
23   SimpleTest.requestCompleteLog();
25   info("installing extension temporarily");
26   let chromeURL = Services.io.newURI(EXTENSION_DIR);
27   let dir = chromeRegistry
28     .convertChromeURL(chromeURL)
29     .QueryInterface(Ci.nsIFileURL).file;
30   await AddonManager.installTemporaryAddon(dir);
32   info("Checking for mozscreenshots extension");
34   let aAddon = await AddonManager.getAddonByID("mozscreenshots@mozilla.org");
35   isnot(aAddon, null, "The mozscreenshots extension should be installed");
36   TestRunner = ChromeUtils.importESModule(
37     "resource://mozscreenshots/TestRunner.sys.mjs"
38   ).TestRunner;
39   TestRunner.initTest(this);
42 /**
43  * Used by pre-defined sets of configurations to decide whether to run for a build.
44  *
45  * This is not used by browser_screenshots.js which handles when MOZSCREENSHOTS_SETS is set.
46  *
47  * @returns {bool} whether to capture screenshots.
48  */
49 function shouldCapture() {
50   if (Services.env.get("MOZSCREENSHOTS_SETS")) {
51     ok(
52       true,
53       "MOZSCREENSHOTS_SETS was specified so only capture what was " +
54         "requested (in browser_screenshots.js)"
55     );
56     return false;
57   }
59   if (AppConstants.MOZ_UPDATE_CHANNEL == "nightly") {
60     ok(true, "Screenshots aren't captured on Nightlies");
61     return false;
62   }
64   return true;
67 add_setup(setup);