Bug 1387678 - Allow Marionette sendAsync command to handle null or undefinedr?ato draft
authorDavid Burns <dburns@mozilla.com>
Thu, 03 May 2018 11:00:26 +0100
changeset 801165 da48b40ae5f2294a7599eb7135e4c8ec7f909c7e
parent 801164 01157e7f5fa6d6fd8a96e1611d2794f2ada17cb3
child 801166 36e9c0b58611a64ab73ebfdea5445a48ed8746b7
push id111602
push userbmo:dburns@mozilla.com
push dateTue, 29 May 2018 22:11:56 +0000
bugs1387678
milestone62.0a1
Bug 1387678 - Allow Marionette sendAsync command to handle null or undefinedr?ato When evaluating if an object can be null, which would mean that we would not be able to pass through IPC as, the commandId could not be added to null. This patch makes sure that we can still send commands via IPC if the object is evaluated to null. MozReview-Commit-ID: Fl3Ionj08Sk
testing/marionette/driver.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -317,16 +317,20 @@ GeckoDriver.prototype.globalModalDialogH
  * @throws {JavaScriptError}
  *     If <var>data</var> could not be marshaled.
  * @throws {NoSuchWindowError}
  *     If there is no current target frame.
  */
 GeckoDriver.prototype.sendAsync = function(name, data, commandID) {
   let payload = evaluate.toJSON(data, this.seenEls);
 
+  if (payload === null) {
+    payload = {};
+  }
+
   // TODO(ato): When proxy.AsyncMessageChannel
   // is used for all chrome <-> content communication
   // this can be removed.
   if (commandID) {
     payload.commandID = commandID;
   }
 
   this.curBrowser.executeWhenReady(() => {