Bug 1453385 - Make protocol.js throw if a spec implements a nested response object. r=jryans draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Thu, 12 Apr 2018 16:06:10 -0700
changeset 781938 6c0db50fca68d786637418f1088b418b583595a4
parent 781937 2df70ad4a7ca369bc3950a9fe9c0a0499eda0815
child 781939 997159e65ef2828d1259fa8003c332e0252e5114
push id106451
push userbmo:poirot.alex@gmail.com
push dateFri, 13 Apr 2018 20:48:33 +0000
reviewersjryans
bugs1453385
milestone61.0a1
Bug 1453385 - Make protocol.js throw if a spec implements a nested response object. r=jryans MozReview-Commit-ID: 7TXQMvYzGDG
devtools/shared/protocol.js
--- a/devtools/shared/protocol.js
+++ b/devtools/shared/protocol.js
@@ -724,17 +724,18 @@ Response.prototype = {
       return this.template.write(ret, ctx);
     }
     let result = {};
     for (let key in this.template) {
       let value = this.template[key];
       if (value instanceof RetVal) {
         result[key] = value.write(ret, ctx);
       } else {
-        result[key] = value;
+        throw new Error("Response can only be a `RetVal` instance or an object " +
+                        "with one property being a `RetVal` instance.");
       }
     }
     return result;
   },
 
   /**
    * Read a return value from the given response.
    *