From e02175a9abe955c0c5907db6d962719046e225dd Mon Sep 17 00:00:00 2001 From: Andreas Tolfsen Date: Tue, 19 Nov 2019 12:32:46 +0000 Subject: [PATCH] bug 1543115: remote: make RemoteAgent.listen() accept strings; r=remote-protocol-reviewers,maja_zf Crafting nsIURIs in Rust is complicated. Allow RemoteAgent.listen() to accept both strings and nsIURIs when called in JavaScript. Differential Revision: https://phabricator.services.mozilla.com/D50286 --HG-- extra : moz-landing-system : lando --- remote/RemoteAgent.jsm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/remote/RemoteAgent.jsm b/remote/RemoteAgent.jsm index 60cf091eb0e2..7694984b34e5 100644 --- a/remote/RemoteAgent.jsm +++ b/remote/RemoteAgent.jsm @@ -36,7 +36,7 @@ class RemoteAgentClass { return !!this.server && !this.server.isStopped(); } - async listen(address) { + async listen(url) { if (!Preferences.get(ENABLED, false)) { throw new Error("Remote agent is disabled by preference"); } @@ -46,11 +46,11 @@ class RemoteAgentClass { ); } - if (!(address instanceof Ci.nsIURI)) { - throw new TypeError(`Expected nsIURI: ${address}`); + if (!(url instanceof Ci.nsIURI)) { + url = Services.io.newURI(url); } - let { host, port } = address; + let { host, port } = url; if (Preferences.get(FORCE_LOCAL) && !LOOPBACKS.includes(host)) { throw new Error("Restricted to loopback devices"); }