Bug 1125383 - Unbreak running single mochitests using the runtests.py script directly; r=ted
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 23 Jan 2015 17:25:06 -0500
changeset 239744 5a3d567fd8b56e998cb89df22742a4dd245cb29e
parent 239743 2c010ad45bd386f2e80e458c15a6f2d6e6d56255
child 239745 b6d3a8960d38adc7d16a69f011db20d4e43dc83b
push id506
push usermleibovic@mozilla.com
push dateThu, 29 Jan 2015 12:40:10 +0000
reviewersted
bugs1125383
milestone38.0a1
Bug 1125383 - Unbreak running single mochitests using the runtests.py script directly; r=ted Without this, the following exception is thrown: TEST-UNEXPECTED-FAIL | unknown test url | uncaught exception - TypeError: SimpleTest.harnessParameters is undefined at http://mochi.test:8888/tests/SimpleTest/SimpleTest.js:624
testing/mochitest/tests/SimpleTest/SimpleTest.js
--- a/testing/mochitest/tests/SimpleTest/SimpleTest.js
+++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js
@@ -614,30 +614,32 @@ SimpleTest.expectAssertions = function(m
     if (parentRunner) {
         parentRunner.expectAssertions(min, max);
     }
 }
 
 SimpleTest._flakyTimeoutIsOK = false;
 SimpleTest._originalSetTimeout = window.setTimeout;
 window.setTimeout = function SimpleTest_setTimeoutShim() {
-    var testSuiteSupported = false;
-    // Right now, we only enable these checks for mochitest-plain.
-    switch (SimpleTest.harnessParameters.testRoot) {
-    case "browser":
-    case "chrome":
-    case "a11y":
-    case "webapprtContent":
-        break;
-    default:
-        if (!SimpleTest._alreadyFinished && arguments.length > 1 && arguments[1] > 0) {
-            if (SimpleTest._flakyTimeoutIsOK) {
-                SimpleTest.todo(false, "The author of the test has indicated that flaky timeouts are expected.  Reason: " + SimpleTest._flakyTimeoutReason);
-            } else {
-                SimpleTest.ok(false, "Test attempted to use a flaky timeout value " + arguments[1]);
+    // Don't break tests that are loaded without a parent runner.
+    if (parentRunner) {
+        // Right now, we only enable these checks for mochitest-plain.
+        switch (SimpleTest.harnessParameters.testRoot) {
+        case "browser":
+        case "chrome":
+        case "a11y":
+        case "webapprtContent":
+            break;
+        default:
+            if (!SimpleTest._alreadyFinished && arguments.length > 1 && arguments[1] > 0) {
+                if (SimpleTest._flakyTimeoutIsOK) {
+                    SimpleTest.todo(false, "The author of the test has indicated that flaky timeouts are expected.  Reason: " + SimpleTest._flakyTimeoutReason);
+                } else {
+                    SimpleTest.ok(false, "Test attempted to use a flaky timeout value " + arguments[1]);
+                }
             }
         }
     }
     return SimpleTest._originalSetTimeout.apply(window, arguments);
 }
 
 /**
  * Request the framework to allow usage of setTimeout(func, timeout)