tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

head.js (2096B)


      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/. */
      4 
      5 /* exported TestRunner, shouldCapture */
      6 
      7 "use strict";
      8 
      9 const chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(
     10  Ci.nsIChromeRegistry
     11 );
     12 const EXTENSION_DIR =
     13  "chrome://mochitests/content/browser/browser/tools/mozscreenshots/mozscreenshots/extension/mozscreenshots/browser/";
     14 
     15 let TestRunner;
     16 
     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);
     21 
     22  // Generate output so mozprocess knows we're still alive for the long session.
     23  SimpleTest.requestCompleteLog();
     24 
     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);
     31 
     32  info("Checking for mozscreenshots extension");
     33 
     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);
     40 }
     41 
     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  }
     58 
     59  if (AppConstants.MOZ_UPDATE_CHANNEL == "nightly") {
     60    ok(true, "Screenshots aren't captured on Nightlies");
     61    return false;
     62  }
     63 
     64  return true;
     65 }
     66 
     67 add_setup(setup);