Commit 10ecf6dd authored by Richard Pospesel's avatar Richard Pospesel
Browse files

Bug 40679: Missing features on first-time launch in esr91

- fixes myriad problems with our async control port communication
  logic
- fixes tor-browser#40679
parent 733224de
......@@ -29,7 +29,7 @@ let createTorCircuitDisplay = (function () {
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
// Import the controller code.
let { controller } = ChromeUtils.import("resource://torbutton/modules/tor-control-port.js", {});
let { wait_for_controller } = ChromeUtils.import("resource://torbutton/modules/tor-control-port.js", {});
// Utility functions
let { bindPrefAndInit, observe, getLocale, getDomainForBrowser, torbutton_get_property_string } = ChromeUtils.import("resource://torbutton/modules/utils.js", {});
......@@ -458,7 +458,7 @@ let setupDisplay = function (enablePrefName) {
syncDisplayWithSelectedTab(false);
if (myController) {
if (stopCollectingIsolationData) {
stopCollectingIsolationData();
stopCollectingIsolationData();
}
if (stopCollectingBrowserCredentials) {
stopCollectingBrowserCredentials();
......@@ -469,19 +469,20 @@ let setupDisplay = function (enablePrefName) {
myController = null;
}
},
start = function () {
start = async function () {
if (!myController) {
myController = controller(function (err) {
// An error has occurred.
try {
myController = await wait_for_controller();
syncDisplayWithSelectedTab(true);
stopCollectingIsolationData = collectIsolationData(myController, updateCircuitDisplay);
stopCollectingBrowserCredentials = collectBrowserCredentials();
stopEnsuringCorrectPopupDimensions = ensureCorrectPopupDimensions();
} catch (err) {
logger.eclog(5, err);
logger.eclog(5, "Disabling tor display circuit because of an error.");
myController.close();
stop();
});
syncDisplayWithSelectedTab(true);
stopCollectingIsolationData = collectIsolationData(myController, updateCircuitDisplay);
stopCollectingBrowserCredentials = collectBrowserCredentials();
stopEnsuringCorrectPopupDimensions = ensureCorrectPopupDimensions();
}
}
};
try {
......
......@@ -28,7 +28,7 @@ let {
torbutton_log,
torbutton_get_property_string,
} = ChromeUtils.import("resource://torbutton/modules/utils.js", {});
let { configureControlPortModule, controller } = Cu.import("resource://torbutton/modules/tor-control-port.js", {});
let { configureControlPortModule, wait_for_controller } = Cu.import("resource://torbutton/modules/tor-control-port.js", {});
const k_tb_tor_check_failed_topic = "Torbutton:TorCheckFailed";
......@@ -352,7 +352,7 @@ async function torbutton_send_ctrl_cmd(command) {
let response = null;
try {
const avoidCache = true;
let torController = controller(e => { throw e; }, avoidCache);
let torController = await wait_for_controller(avoidCache);
let bytes = await torController.sendCommand(command);
if (!bytes.startsWith("250")) {
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment