Bug 1299411 - s/on/once/ in NativeApp's sendMessage r=aswan
authorRob Wu <rob@robwu.nl>
Sat, 24 Sep 2016 13:22:31 +0200
changeset 320065 24d81c7b335e8cb1949efb2b27a978cf108de705
parent 320064 2829c46a636d7a2b77a88df0b9fbe36182fa836d
child 320066 ed1afd2aad61c64bb938cf1647975b4fda846d66
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1299411
milestone52.0a1
Bug 1299411 - s/on/once/ in NativeApp's sendMessage r=aswan This communicates more clearly that we expect only one message/event. MozReview-Commit-ID: 8jDYBVwqQtz
toolkit/components/extensions/NativeMessaging.jsm
--- a/toolkit/components/extensions/NativeMessaging.jsm
+++ b/toolkit/components/extensions/NativeMessaging.jsm
@@ -425,18 +425,18 @@ this.NativeApp = class extends EventEmit
 
     port = Cu.cloneInto(port, this.context.cloneScope, {cloneFunctions: true});
 
     return port;
   }
 
   sendMessage(msg) {
     let responsePromise = new Promise((resolve, reject) => {
-      this.on("message", (what, msg) => { resolve(msg); });
-      this.on("disconnect", (what, err) => { reject(err); });
+      this.once("message", (what, msg) => { resolve(msg); });
+      this.once("disconnect", (what, err) => { reject(err); });
     });
 
     let result = this.startupPromise.then(() => {
       this.send(msg);
       return responsePromise;
     });
 
     result.then(() => {