From a217b583f91816fce8a8e1d03ec6b76baa23c15a Mon Sep 17 00:00:00 2001 From: Andreas Tolfsen Date: Wed, 4 Dec 2019 11:57:13 +0000 Subject: [PATCH] bug 1600111: remote: make nsIRemoteAgent.listen() sync r=remote-protocol-reviewers,maja_zf Interfaces exposed over XPIDL cannot be marked async, otherwise their return values get lost. This patch makes nsIRemoteAgent.listen() synchronous by removing the use of async/await. Unfortunately Rust does not yet support deserialising promises sent across XPIDL, documented in https://bugzilla.mozilla.org/show_bug.cgi?id=1512319. In an effort to retain the original API internally the function now returns a promise. This means the function can be awaited in JS only, which we make use of in remote/test/browser/head.js. Differential Revision: https://phabricator.services.mozilla.com/D55173 --HG-- extra : moz-landing-system : lando --- remote/RemoteAgent.jsm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/remote/RemoteAgent.jsm b/remote/RemoteAgent.jsm index 886b81635d3f..7e7324d0abf9 100644 --- a/remote/RemoteAgent.jsm +++ b/remote/RemoteAgent.jsm @@ -31,7 +31,7 @@ class RemoteAgentClass { return !!this.server && !this.server.isStopped(); } - async listen(url) { + listen(url) { if (!Preferences.get(ENABLED, false)) { throw new Error("Remote agent is disabled by preference"); } @@ -56,7 +56,7 @@ class RemoteAgentClass { } if (this.listening) { - return; + return Promise.resolve(); } Preferences.set(RecommendedPreferences); @@ -77,6 +77,10 @@ class RemoteAgentClass { delete this.server._handler._overridePaths[target.path]; }); + return this.asyncListen(host, port); + } + + async asyncListen(host, port) { try { await this.targets.watchForTargets();