Bug 1440164 - Detect a subtest URL not resolving and give an error message. r=kats draft
authorBotond Ballo <botond@mozilla.com>
Fri, 23 Feb 2018 21:55:24 -0500
changeset 759345 5c088cf4094e1d2537bc33664d6983654508c28c
parent 759344 b528b83f431c89ff5b21fdd725b2c371edd9b29a
push id100342
push userbballo@mozilla.com
push dateSat, 24 Feb 2018 04:21:57 +0000
reviewerskats
bugs1440164
milestone60.0a1
Bug 1440164 - Detect a subtest URL not resolving and give an error message. r=kats MozReview-Commit-ID: 1LntbmmFwif
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);
         });