# HG changeset patch # User Botond Ballo # Date 1519440924 18000 # Node ID bbceec48f282e25504ce27a6313329c69b61643e # Parent 5b3ba212e295f9ed57e4a001965228bc57e41dd0 Bug 1440164 - Detect a subtest URL not resolving and give an error message. r=kats MozReview-Commit-ID: 1LntbmmFwif diff --git a/gfx/layers/apz/test/mochitest/apz_test_utils.js b/gfx/layers/apz/test/mochitest/apz_test_utils.js --- 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); });