Bug 1462983 diagnostic: when test_bug607529.html fails JSON.parse operation, print the string that it choked on. r=bz a=testonly
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 12 Jul 2018 09:48:22 -0700
changeset 477929 273c096e439160f2a4bd9894b838da1ff40769ca
parent 477928 979badf8ce75f150415911255c6084ad6a11848c
child 477930 351f1398477ced5a6cfc152135c9fd89e9bf5f5a
push id9471
push userdholbert@mozilla.com
push dateThu, 12 Jul 2018 22:05:46 +0000
treeherdermozilla-beta@273c096e4391 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, testonly
bugs1462983, 607529
milestone62.0
Bug 1462983 diagnostic: when test_bug607529.html fails JSON.parse operation, print the string that it choked on. r=bz a=testonly MozReview-Commit-ID: G8O0GP7VpFQ
layout/base/tests/test_bug607529.html
--- a/layout/base/tests/test_bug607529.html
+++ b/layout/base/tests/test_bug607529.html
@@ -45,17 +45,24 @@ https://bugzilla.mozilla.org/show_bug.cg
       // Protect against calling SimpleTest.finish() more than once.
       if (!done) {
         w.close();
         window.onmessage = null;
         SimpleTest.finish();
         done = true;
       }
     } else {
-      var msg = JSON.parse(e.data);
+      try {
+        var msg = JSON.parse(e.data);
+      } catch (ex) {
+        // Diagnostic for Bug 1462983: if JSON.parse throws, pause to print
+        // the string that it choked on, and then resume throwing the exception.
+        ok(false, "JSON.parse threw, when passed string '" + e.data + "'");
+        throw ex;
+      }
       if (msg.error) {
         window.onerror(msg.msg, msg.url, msg.line);
       }
     }
   };
 
   var w = window.open("file_bug607529.html");
 </script>