Bug 1275042 - Turn undefined error message- and stacktrace fields into strings; r=automatedtester a=test-only
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 23 May 2016 17:46:04 +0100
changeset 333248 2f2941ed16da8f86e849c7e53b4f715d3e389917
parent 333247 fb6c47bc3e2d739b4b61d7a43e5f0f748c0e425a
child 333249 314e202438dedcf2a65cdbc9e7b3a91e57e28f25
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester, test-only
bugs1275042
milestone48.0a2
Bug 1275042 - Turn undefined error message- and stacktrace fields into strings; r=automatedtester a=test-only MozReview-Commit-ID: A2DYgTqp2rp
testing/marionette/error.js
testing/marionette/test_error.js
--- a/testing/marionette/error.js
+++ b/testing/marionette/error.js
@@ -135,18 +135,18 @@ error.stringify = function(err) {
  */
 error.toJson = function(err) {
   if (!error.isWebDriverError(err)) {
     throw new TypeError(`Unserialisable error type: ${err}`);
   }
 
   let json = {
     error: err.status,
-    message: err.message || null,
-    stacktrace: err.stack || null,
+    message: err.message || "",
+    stacktrace: err.stack || "",
   };
   return json;
 };
 
 /**
  * Unmarshal a JSON dictionary to a WebDriverError prototype.
  *
  * @param {Object.<string, string>} json
--- a/testing/marionette/test_error.js
+++ b/testing/marionette/test_error.js
@@ -88,18 +88,22 @@ add_test(function test_stringify() {
 
   run_next_test();
 });
 
 add_test(function test_toJson() {
   Assert.throws(() => error.toJson(new Error()),
       /Unserialisable error type: [object Error]/);
 
+  let e0 = new WebDriverError();
+  deepEqual({error: e0.status, message: "", stacktrace: ""},
+      error.toJson(e0));
+
   let e1 = new WebDriverError("a");
-  deepEqual({error: e1.status, message: "a", stacktrace: null},
+  deepEqual({error: e1.status, message: "a", stacktrace: ""},
       error.toJson(e1));
 
   let e2 = new JavaScriptError("first", "second", "third", "fourth");
   let e2s = error.toJson(e2);
   equal(e2.status, e2s.error);
   equal(e2.message, e2s.message);
   ok(e2s.stacktrace.match(/second/));
   ok(e2s.stacktrace.match(/third/));