Bug 1429082 - Drop AsyncChromeSender from proxy module. r?whimboo draft
authorAndreas Tolfsen <ato@sny.no>
Tue, 09 Jan 2018 15:42:01 +0000
changeset 717790 943f5ef6be567d57d7c03c49513f6afecb07731b
parent 717738 6f5fac320fcb6625603fa8a744ffa8523f8b3d71
child 717791 5ef7053d0e946b073e99e11a7931011ab858ccc1
push id94773
push userbmo:ato@sny.no
push dateTue, 09 Jan 2018 15:45:17 +0000
reviewerswhimboo
bugs1429082
milestone59.0a1
Bug 1429082 - Drop AsyncChromeSender from proxy module. r?whimboo The AsyncChromeSender and its factory construction function proxy.toChromeAsync are no longer in use. MozReview-Commit-ID: 8tFr1IUTd5g
testing/marionette/proxy.js
--- a/testing/marionette/proxy.js
+++ b/testing/marionette/proxy.js
@@ -317,88 +317,16 @@ proxy.AsyncMessageChannel = class {
 };
 proxy.AsyncMessageChannel.ReplyType = {
   Ok: 0,
   Value: 1,
   Error: 2,
 };
 
 /**
- * A transparent content-to-chrome RPC interface where responses are
- * presented as promises.
- *
- * @param {nsIFrameMessageManager} frameMessageManager
- *     The content frame's message manager, which itself is usually an
- *     implementor of.
- */
-proxy.toChromeAsync = function(frameMessageManager) {
-  let sender = new AsyncChromeSender(frameMessageManager);
-  return new Proxy(sender, ownPriorityGetterTrap);
-};
-
-/**
- * Sends asynchronous RPC messages to chrome space using a frame's
- * sendAsyncMessage (nsIAsyncMessageSender) function.
- *
- * Example on how to use from a frame content script:
- *
- *     let sender = new AsyncChromeSender(messageManager);
- *     let promise = sender.send("runEmulatorCmd", "my command");
- *     let rv = await promise;
- */
-class AsyncChromeSender {
-  constructor(frameMessageManager) {
-    this.mm = frameMessageManager;
-  }
-
-  /**
-   * Call registered function in chrome context.
-   *
-   * @param {string} name
-   *     Function to call in the chrome, e.g. for <tt>Marionette:foo</tt>,
-   *     use <tt>foo</tt>.
-   * @param {*} args
-   *     Argument list to pass the function.  Must be JSON serialisable.
-   *
-   * @return {Promise}
-   *     A promise that resolves to the value sent back.
-   */
-  send(name, args) {
-    let uuid = uuidgen.generateUUID().toString();
-
-    let proxy = new Promise((resolve, reject) => {
-      let responseListener = msg => {
-        if (msg.json.id != uuid) {
-          return;
-        }
-
-        this.mm.removeMessageListener(
-            "Marionette:listenerResponse", responseListener);
-
-        if ("value" in msg.json) {
-          resolve(msg.json.value);
-        } else if ("error" in msg.json) {
-          reject(msg.json.error);
-        } else {
-          throw new TypeError(
-              `Unexpected response: ${msg.name} ${JSON.stringify(msg.json)}`);
-        }
-      };
-
-      let msg = {arguments: marshal(args), id: uuid};
-      this.mm.addMessageListener(
-          "Marionette:listenerResponse", responseListener);
-      this.mm.sendAsyncMessage("Marionette:" + name, msg);
-    });
-
-    return proxy;
-  }
-}
-
-/**
  * Creates a transparent interface from the content- to the chrome context.
  *
  * Calls to this object will be proxied via the frame's sendSyncMessage
  * ({@link nsISyncMessageSender}) function.  Since the message is
  * synchronous, the return value is presented as a return value.
  *
  * Example on how to use from a frame content script:
  *