Bug 1468634 - Allow running a single APZ mochitest subtest at a time. r=kats
This is done by passing "--setpref apz.subtest=<subtest-name>" on the
mochitest command line, where <subtest-name> is the name of the subtest file
(including the extension).
MozReview-Commit-ID: EscFekIeOxr
--- a/gfx/layers/apz/test/mochitest/apz_test_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_utils.js
@@ -189,16 +189,20 @@ function waitForApzFlushedRepaints(aCall
// functions provided by SimpleTest are also mapped into the subtest's window.
// For other things from the parent, the subtest can use window.opener.<whatever>
// to access objects.
function runSubtestsSeriallyInFreshWindows(aSubtests) {
return new Promise(function(resolve, reject) {
var testIndex = -1;
var w = null;
+ // If the "apz.subtest" pref has been set, only a single subtest whose name matches
+ // the pref's value (if any) will be run.
+ var onlyOneSubtest = SpecialPowers.getCharPref("apz.subtest", /* default = */ "");
+
function advanceSubtestExecution() {
var test = aSubtests[testIndex];
if (w) {
// Run any cleanup functions registered in the subtest
if (w.ApzCleanup) { // guard against the subtest not loading apz_test_utils.js
w.ApzCleanup.execute();
}
if (typeof test.dp_suppression != 'undefined') {
@@ -221,16 +225,23 @@ function runSubtestsSeriallyInFreshWindo
testIndex++;
if (testIndex >= aSubtests.length) {
resolve();
return;
}
test = aSubtests[testIndex];
+
+ if (onlyOneSubtest && onlyOneSubtest != test.file) {
+ SimpleTest.ok(true, "Skipping " + test.file + " because only " + onlyOneSubtest + " is being run");
+ setTimeout(function() { advanceSubtestExecution(); }, 0);
+ return;
+ }
+
if (typeof test.dp_suppression != 'undefined') {
// Normally during a test, the displayport will get suppressed during page
// load, and unsuppressed at a non-deterministic time during the test. The
// unsuppression can trigger a repaint which interferes with the test, so
// to avoid that we can force the displayport to be unsuppressed for the
// entire test which is more deterministic.
SpecialPowers.getDOMWindowUtils(window).respectDisplayPortSuppression(test.dp_suppression);
}