Handle unavailability of NetworkLinkService API in Tor Connect
The rewritten TorConnect (currently only part of 14.5, the alpha release/branch) uses the NetworkLinkService API. As shown in netwerk/build/components.conf
, this API is not available on all operating systems. Therefore, on OpenBSD, I see the following when I run tor-browser --jsconsole
:
TypeError: Cc['@mozilla.org/network/network-link-service;1'] is undefined TorConnect.sys.mjs:19:3
<anonymous> resource://gre/modules/TorConnect.sys.mjs:19
_updateInternetStatus resource://gre/modules/TorConnect.sys.mjs:894
init resource://gre/modules/TorConnect.sys.mjs:941
#init resource://gre/modules/TorStartupService.sys.mjs:46
observe resource://gre/modules/TorStartupService.sys.mjs:30
and the TorConnect page does not function. This prevents me from connecting to the network.
In some other parts of the Mozilla code base, for instance in services/settings/Utils.sys.mjs
and toolkit/content/aboutNetworking.js
, the use of the NetworkLinkService API is surrounded by try {} catch (e) {}
, presumably to handle the case where the NetworkLinkService API is not available.
I propose to surround the use of this API with try catch
in TorConnect.sys.mjs
as well to make it work on (for example) OpenBSD. (I will submit the Merge Request that fixes this soon.)