Bug 1470646 - Silence missing nodeType property warning. r?whimboo draft
authorAndreas Tolfsen <ato@sny.no>
Sat, 23 Jun 2018 14:00:50 +0100
changeset 809887 62f27fb8b7d8d3f716770af89cf4987abd1cb301
parent 809886 62035cdfe372b6969894f819a5e0a4d0885726fe
child 809888 dfa30f7dc945a4f15b544f49b316dc7d2ab8b1d9
push id113835
push userbmo:ato@sny.no
push dateSat, 23 Jun 2018 13:33:25 +0000
reviewerswhimboo
bugs1470646
milestone62.0a1
Bug 1470646 - Silence missing nodeType property warning. r?whimboo If val does not have a property nodeType, a warning is emitted to the browser console. This is observable when running the xpcshell unit tests because we mock out val without a nodeType property. MozReview-Commit-ID: GzqMoJQQdF8
testing/marionette/format.js
--- a/testing/marionette/format.js
+++ b/testing/marionette/format.js
@@ -32,17 +32,18 @@ const MAX_STRING_LENGTH = 250;
  *     pprint`Current window: ${window}`;
  *     => '[object Window https://www.mozilla.org/]'
  * </code></pre>
  */
 function pprint(ss, ...values) {
   function pretty(val) {
     let proto = Object.prototype.toString.call(val);
 
-    if (val && val.nodeType === 1) {
+    if (typeof val == "object" && val !== null &&
+        "nodeType" in val && val.nodeType === 1) {
       return prettyElement(val);
     } else if (["[object Window]", "[object ChromeWindow]"].includes(proto)) {
       return prettyWindowGlobal(val);
     } else if (proto == "[object Attr]") {
       return prettyAttr(val);
     }
     return prettyObject(val);
   }