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