Bug 1440164 - Detect a subtest URL not resolving and give an error message. r=kats
MozReview-Commit-ID: 1LntbmmFwif
--- a/gfx/layers/apz/test/mochitest/apz_test_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_utils.js
@@ -227,17 +227,30 @@ function runSubtestsSeriallyInFreshWindo
w = window.open('', "_blank");
w.subtestDone = advanceSubtestExecution;
w.SimpleTest = SimpleTest;
w.is = function(a, b, msg) { return is(a, b, aFile + " | " + msg); };
w.ok = function(cond, name, diag) { return ok(cond, aFile + " | " + name, diag); };
if (test.onload) {
w.addEventListener('load', function(e) { test.onload(w); }, { once: true });
}
- w.location = location.href.substring(0, location.href.lastIndexOf('/') + 1) + aFile;
+ var subtestUrl = location.href.substring(0, location.href.lastIndexOf('/') + 1) + aFile;
+ function urlResolves(url) {
+ var request = new XMLHttpRequest();
+ request.open('GET', url, false);
+ request.send();
+ return request.status !== 404;
+ }
+ if (!urlResolves(subtestUrl)) {
+ SimpleTest.ok(false, "Subtest URL " + subtestUrl + " does not resolve. " +
+ "Be sure it's present in the support-files section of mochitest.ini.");
+ reject();
+ return;
+ }
+ w.location = subtestUrl;
return w;
}
if (test.prefs) {
// Got some prefs for this subtest, push them
SpecialPowers.pushPrefEnv({"set": test.prefs}, function() {
w = spawnTest(test.file);
});