Bug 1458235 - Make Assert.* fail if the message argument is defined but not a string. r=Gijs
authorMark Banner <standard8@mozilla.com>
Tue, 01 May 2018 15:36:51 +0100
changeset 417475 83fb6c53e740cd7d3f8125a684cb5851c5ef4dd8
parent 417474 03ee745ee8e2aa9c1ad602c2881be128b956f1e7
child 417476 3b84be9ee9e6a19d8e49aa86b71c9d60b5eaec8b
push id33968
push userebalazs@mozilla.com
push dateWed, 09 May 2018 09:32:53 +0000
treeherdermozilla-central@a2eccfbeb0ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1458235
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1458235 - Make Assert.* fail if the message argument is defined but not a string. r=Gijs MozReview-Commit-ID: 9Kfcz0WORXS
testing/modules/Assert.jsm
--- a/testing/modules/Assert.jsm
+++ b/testing/modules/Assert.jsm
@@ -189,16 +189,21 @@ proto.setReporter = function(reporterFun
  * @param message (optional)
  *        (string) Short explanation of the expected result
  * @param operator (optional)
  *        (string) Operation qualifier used by the assertion method (ex: '==')
  * @param truncate (optional) [true]
  *        (boolean) Whether or not `actual` and `expected` should be truncated when printing
  */
 proto.report = function(failed, actual, expected, message, operator, truncate = true) {
+  // Although not ideal, we allow a "null" message due to the way some of the extension tests
+  // work.
+  if (message !== undefined && message !== null && typeof message != "string") {
+    this.ok(false, `Expected a string or undefined for the error message to Assert.*, got ${typeof message}`);
+  }
   let err = new Assert.AssertionError({
     message,
     actual,
     expected,
     operator,
     truncate
   });
   if (!this._reporter) {