2016-01-20 06:40:34 +00:00
|
|
|
/* 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/. */
|
|
|
|
|
2016-10-23 17:00:20 +00:00
|
|
|
/* exported TestRunner, shouldCapture */
|
|
|
|
|
2016-01-20 06:40:34 +00:00
|
|
|
"use strict";
|
|
|
|
|
2016-04-18 21:21:53 +00:00
|
|
|
const chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
|
2016-02-03 03:05:21 +00:00
|
|
|
const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
|
2017-06-15 05:18:50 +00:00
|
|
|
const EXTENSION_DIR = "chrome://mochitests/content/browser/browser/tools/mozscreenshots/mozscreenshots/extension/mozscreenshots/browser/";
|
2016-04-18 21:21:53 +00:00
|
|
|
|
2016-02-14 01:44:05 +00:00
|
|
|
let TestRunner;
|
2016-01-20 06:40:34 +00:00
|
|
|
|
2017-05-12 12:45:01 +00:00
|
|
|
async function setup() {
|
2017-01-19 22:10:04 +00:00
|
|
|
// 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);
|
2016-01-20 06:40:34 +00:00
|
|
|
|
2018-01-23 02:13:27 +00:00
|
|
|
// Generate output so mozprocess knows we're still alive for the long session.
|
2018-01-23 04:30:17 +00:00
|
|
|
SimpleTest.requestCompleteLog();
|
|
|
|
|
2016-04-18 21:21:53 +00:00
|
|
|
info("installing extension temporarily");
|
2017-01-09 19:27:25 +00:00
|
|
|
let chromeURL = Services.io.newURI(EXTENSION_DIR);
|
2016-04-18 21:21:53 +00:00
|
|
|
let dir = chromeRegistry.convertChromeURL(chromeURL).QueryInterface(Ci.nsIFileURL).file;
|
2017-05-12 12:45:01 +00:00
|
|
|
await AddonManager.installTemporaryAddon(dir);
|
2016-04-18 21:21:53 +00:00
|
|
|
|
2016-01-20 06:40:34 +00:00
|
|
|
info("Checking for mozscreenshots extension");
|
2018-04-15 02:38:18 +00:00
|
|
|
return new Promise(async (resolve) => {
|
|
|
|
let aAddon = await AddonManager.getAddonByID("mozscreenshots@mozilla.org");
|
|
|
|
isnot(aAddon, null, "The mozscreenshots extension should be installed");
|
2018-10-04 21:41:06 +00:00
|
|
|
TestRunner = ChromeUtils.import("resource://mozscreenshots/TestRunner.jsm", {}).TestRunner;
|
2018-04-15 02:38:18 +00:00
|
|
|
TestRunner.initTest(this);
|
|
|
|
resolve();
|
2016-01-20 06:40:34 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-01-20 23:45:34 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-01-25 21:57:37 +00:00
|
|
|
function shouldCapture() {
|
2016-02-14 01:44:05 +00:00
|
|
|
if (env.get("MOZSCREENSHOTS_SETS")) {
|
|
|
|
ok(true, "MOZSCREENSHOTS_SETS was specified so only capture what was " +
|
|
|
|
"requested (in browser_screenshots.js)");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-20 23:45:34 +00:00
|
|
|
if (AppConstants.MOZ_UPDATE_CHANNEL == "nightly") {
|
|
|
|
ok(true, "Screenshots aren't captured on Nightlies");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-26 02:55:45 +00:00
|
|
|
return true;
|
2016-01-25 21:57:37 +00:00
|
|
|
}
|
|
|
|
|
2016-01-20 06:40:34 +00:00
|
|
|
add_task(setup);
|