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
This commit is contained in:
Andreas Tolfsen 2019-11-22 08:03:10 +00:00
Родитель 7c06462151
Коммит 9c0f6722a6
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -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");
}