Bug 1494657 - Wait for SpecialPowers before proceeding with mochitest setup; r=aswan
authorGeoff Brown <gbrown@mozilla.com>
Thu, 18 Oct 2018 10:22:26 -0600
changeset 490234 edaa4f0b9da959b7a0158e35fbb972eb24cbe708
parent 490233 6d6b5c10bba56bc286ae66cf9d72948a6a03d200
child 490251 8b06ecb59a60ef9f7920fa6e9d307c6592f6a477
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersaswan
bugs1494657
milestone64.0a1
Bug 1494657 - Wait for SpecialPowers before proceeding with mochitest setup; r=aswan
testing/mochitest/tests/SimpleTest/setup.js
--- a/testing/mochitest/tests/SimpleTest/setup.js
+++ b/testing/mochitest/tests/SimpleTest/setup.js
@@ -4,16 +4,23 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 TestRunner.logEnabled = true;
 TestRunner.logger = LogController;
 
+if (!("SpecialPowers" in window)) {
+  dump("SimpleTest setup.js found SpecialPowers unavailable: reloading...\n");
+  setTimeout(() => {
+    window.location.reload();
+  }, 1000);
+}
+
 /* Helper function */
 function parseQueryString(encodedString, useArrays) {
   // strip a leading '?' from the encoded string
   var qstr = (encodedString.length > 0 && encodedString[0] == "?")
              ? encodedString.substring(1)
              : encodedString;
   var pairs = qstr.replace(/\+/g, "%20").split(/(\&amp\;|\&\#38\;|\&#x26;|\&)/);
   var o = {};