[tor-commits] [tor-browser/tor-browser-78.11.0esr-11.0-1] fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser
commit bd66f4a8a7e51d4966b548d10b188d9f2e6c5b17 Author: Richard Pospesel Date: Sun Jul 11 17:44:40 2021 +0200 fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser --- browser/components/torconnect/TorConnectParent.jsm | 4 1 file changed, 4 insertions(+) diff --git a/browser/components/torconnect/TorConnectParent.jsm b/browser/components/torconnect/TorConnectParent.jsm index 54548891fbab..c34fab76ddbb 100644 --- a/browser/components/torconnect/TorConnectParent.jsm +++ b/browser/components/torconnect/TorConnectParent.jsm @@ -11,6 +11,10 @@ const { TorLauncherUtil } = ChromeUtils.import( "resource://torlauncher/modules/tl-util.jsm" ); +const { TorConnect } = ChromeUtils.import( + "resource:///modules/TorConnect.jsm" +); + const kTorProcessReadyTopic = "TorProcessIsReady"; const kTorProcessExitedTopic = "TorProcessExited"; const kTorProcessDidNotStartTopic = "TorProcessDidNotStart"; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor-browser/tor-browser-78.11.0esr-11.0-1] fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser
commit f5dbe466cd7e3a37318fd4e68e93599b5bd35b23 Author: Richard Pospesel Date: Fri Jul 9 12:10:31 2021 +0200 fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser --- browser/components/BrowserGlue.jsm | 21 +++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm index 914b782afdb1..8735783cee2b 100644 --- a/browser/components/BrowserGlue.jsm +++ b/browser/components/BrowserGlue.jsm @@ -17,11 +17,28 @@ const { AppConstants } = ChromeUtils.import( "resource://gre/modules/AppConstants.jsm" ); -const { TorProtocolService } = ChromeUtils.import( +// TorProtocolService and TorConnect modules need to be lazily-loaded +// here because they will trigger generation of the random password used +// to talk to the tor daemon in tor-launcher. Generating the random +// password will initialize the cryptographic service ( nsNSSComponent ) +// +// If this service is init'd before the profile has been setup, it will +// use the fallback init path which behaves as if security.nocertdb=true +// +// We make these module getters so init happens when they are needed +// (when init'ing the OnionAliasStore). With theze getters, the password +// generation is triggered in torbutton after the 'profile-after-change' +// topic (so after the profile is initialized) + +ChromeUtils.defineModuleGetter( + this, + "TorProtocolService", "resource:///modules/TorProtocolService.jsm" ); -const { TorConnect } = ChromeUtils.import( +ChromeUtils.defineModuleGetter( + this, + "TorConnect", "resource:///modules/TorConnect.jsm" ); ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor-browser/tor-browser-78.11.0esr-11.0-1] fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser
commit 2d2ed519296f68d734480447b832d59a9c7fed68 Author: Richard Pospesel Date: Wed Jul 7 16:37:16 2021 +0200 fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser --- toolkit/mozapps/update/UpdateService.jsm | 29 - 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/toolkit/mozapps/update/UpdateService.jsm b/toolkit/mozapps/update/UpdateService.jsm index 6d0c79222577..79881cba42d6 100644 --- a/toolkit/mozapps/update/UpdateService.jsm +++ b/toolkit/mozapps/update/UpdateService.jsm @@ -17,6 +17,12 @@ const { TorProtocolService } = ChromeUtils.import( "resource:///modules/TorProtocolService.jsm" ); +function _shouldRegisterBootstrapObserver(errorCode) { + return errorCode == PROXY_SERVER_CONNECTION_REFUSED && + !TorProtocolService.isBootstrapDone() && + TorProtocolService.ownsTorDaemon; +}; + const { Bits, BitsRequest, @@ -2697,9 +2703,7 @@ UpdateService.prototype = { AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_OFFLINE); } return; -} else if (update.errorCode == PROXY_SERVER_CONNECTION_REFUSED && - !TorProtocolService.isBootstrapDone() && - TorProtocolService.ownsTorDaemon) { +} else if (_shouldRegisterBootstrapObserver(update.errorCode)) { // Register boostrap observer to try again, but only when we own the // tor process. this._registerBootstrapObserver(); @@ -5234,6 +5238,7 @@ Downloader.prototype = { var state = this._patch.state; var shouldShowPrompt = false; var shouldRegisterOnlineObserver = false; +var shouldRegisterBootstrapObserver = false; var shouldRetrySoon = false; var deleteActiveUpdate = false; var retryTimeout = Services.prefs.getIntPref( @@ -5311,7 +5316,18 @@ Downloader.prototype = { ); shouldRegisterOnlineObserver = true; deleteActiveUpdate = false; - +} else if(_shouldRegisterBootstrapObserver(status)) { + // Register a bootstrap observer to try again. + // The bootstrap observer will continue the incremental download by + // calling downloadUpdate on the active update which continues + // downloading the file from where it was. + LOG("Downloader:onStopRequest - not bootstrapped, register bootstrap observer: true"); + AUSTLMY.pingDownloadCode( +this.isCompleteUpdate, +AUSTLMY.DWNLD_RETRY_OFFLINE + ); + shouldRegisterBootstrapObserver = true; + deleteActiveUpdate = false; // Each of NS_ERROR_NET_TIMEOUT, ERROR_CONNECTION_REFUSED, // NS_ERROR_NET_RESET and NS_ERROR_DOCUMENT_NOT_CACHED can be returned // when disconnecting the internet while a download of a MAR is in @@ -5429,7 +5445,7 @@ Downloader.prototype = { // Only notify listeners about the stopped state if we // aren't handling an internal retry. -if (!shouldRetrySoon && !shouldRegisterOnlineObserver) { +if (!shouldRetrySoon && !shouldRegisterOnlineObserver && !shouldRegisterBootstrapObserver) { // Make shallow copy in case listeners remove themselves when called. var listeners = this._listeners.concat(); var listenerCount = listeners.length; @@ -5577,6 +5593,9 @@ Downloader.prototype = { if (shouldRegisterOnlineObserver) { LOG("Downloader:onStopRequest - Registering online observer"); this.updateService._registerOnlineObserver(); +} else if (shouldRegisterBootstrapObserver) { + LOG("Downloader:onStopRequest - Registering bootstrap observer"); + this.updateService._registerBootstrapObserver(); } else if (shouldRetrySoon) { LOG("Downloader:onStopRequest - Retrying soon"); this.updateService._consecutiveSocketErrors++; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor-browser/tor-browser-78.11.0esr-11.0-1] fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser
commit 21083586165d60491d7b4c590ca166415d1f104e Author: Matthew Finkel Date: Thu Jul 8 16:25:50 2021 + fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser --- browser/components/sessionstore/SessionStore.jsm | 16 1 file changed, 16 insertions(+) diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.jsm index 6ab86fd5913e..2d66422abf58 100644 --- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.jsm @@ -213,6 +213,10 @@ ChromeUtils.defineModuleGetter( "resource://gre/modules/sessionstore/SessionHistory.jsm" ); +const { TorProtocolService } = ChromeUtils.import( +"resource:///modules/TorProtocolService.jsm" +); + XPCOMUtils.defineLazyServiceGetters(this, { gScreenManager: ["@mozilla.org/gfx/screenmanager;1", "nsIScreenManager"], Telemetry: ["@mozilla.org/base/telemetry;1", "nsITelemetry"], @@ -1888,11 +1892,23 @@ var SessionStoreInternal = { }, "browser-delayed-startup-finished"); }); + let bootstrapPromise = new Promise(resolve => { +if (TorProtocolService.isBootstrapDone() || !TorProtocolService.ownsTorDaemon) { + resolve(); +} else { + Services.obs.addObserver(function obs(subject, topic) { +Services.obs.removeObserver(obs, topic); +resolve(); + }, "torconnect:bootstrap-complete"); +} + }); + // We are ready for initialization as soon as the session file has been // read from disk and the initial window's delayed startup has finished. this._promiseReadyForInitialization = Promise.all([ promise, SessionStartup.onceInitialized, +bootstrapPromise, ]); } ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor-browser/tor-browser-78.11.0esr-11.0-1] fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser
commit a2581284372175491fbd55b5f44e4c681b9009dd Author: Richard Pospesel Date: Mon Jul 5 17:07:23 2021 +0200 fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser --- browser/components/torconnect/TorConnectParent.jsm | 11 +-- .../torconnect/content/aboutTorConnect.js | 21 + browser/modules/TorConnect.jsm | 19 +-- dom/base/nsGlobalWindowOuter.cpp| 2 ++ toolkit/modules/RemotePageAccessManager.jsm | 4 5 files changed, 25 insertions(+), 32 deletions(-) diff --git a/browser/components/torconnect/TorConnectParent.jsm b/browser/components/torconnect/TorConnectParent.jsm index f775507a744f..54548891fbab 100644 --- a/browser/components/torconnect/TorConnectParent.jsm +++ b/browser/components/torconnect/TorConnectParent.jsm @@ -27,6 +27,7 @@ const gActiveTopics = [ kTorBootstrapStatusTopic, kTorBootstrapErrorTopic, kTorLogHasWarnOrErrTopic, + "torconnect:bootstrap-complete", ]; const gTorLauncherPrefs = { @@ -69,9 +70,6 @@ class TorConnectParent extends JSWindowActorParent { } } - get browser() { -return this.browsingContext.top.embedderElement; - } _OpenTorAdvancedPreferences() { const win = this.browsingContext.top.embedderElement.ownerGlobal; @@ -93,11 +91,6 @@ class TorConnectParent extends JSWindowActorParent { ); } - _GoToBrowserHome() { -const window = this.browser.ownerGlobal; -window.BrowserHome(); - } - receiveMessage(message) { switch (message.name) { case "TorBootstrapErrorOccurred": @@ -106,8 +99,6 @@ class TorConnectParent extends JSWindowActorParent { return TorProtocolService.retrieveBootstrapStatus(); case "OpenTorAdvancedPreferences": return this._OpenTorAdvancedPreferences(); - case "GoToBrowserHome": -return this._GoToBrowserHome(); case "GetLocalizedBootstrapStatus": const { status, keyword } = message.data; return TorLauncherUtil.getLocalizedBootstrapStatus(status, keyword); diff --git a/browser/components/torconnect/content/aboutTorConnect.js b/browser/components/torconnect/content/aboutTorConnect.js index 11301fa10cab..19fd335ccd13 100644 --- a/browser/components/torconnect/content/aboutTorConnect.js +++ b/browser/components/torconnect/content/aboutTorConnect.js @@ -15,10 +15,6 @@ const TorLauncherPrefs = { prompt_at_startup: "extensions.torlauncher.prompt_at_startup", } -const BrowserPrefs = { - homepage: "browser.startup.homepage", -} - class AboutTorConnect { log(...args) { console.log(...args); @@ -133,14 +129,6 @@ class AboutTorConnect { this.elemTitle.classList.add("error"); } - goToBrowserHome() { -this.hideElem(this.elemCancelButton); - -// redirect this about:torconnect to browser homepage -const homepage = RPMGetStringPref(BrowserPrefs.homepage); -window.location.replace(homepage); - } - set state(state) { const oldState = this.state; if (oldState === state) { @@ -158,7 +146,7 @@ class AboutTorConnect { this.setBootstrapErrorUI(); break; case AboutTorConnect.STATE_BOOTSTRAPPED: -this.goToBrowserHome(); +window.close(); break; } } @@ -219,8 +207,6 @@ class AboutTorConnect { // if bootstrap state is greater than 0. this.state = AboutTorConnect.STATE_INITIAL; return; -} else if (percentComplete >= 100) { - this.state = AboutTorConnect.STATE_BOOTSTRAPPED; } else if (percentComplete > 0) { this.state = AboutTorConnect.STATE_BOOTSTRAPPING; } @@ -306,7 +292,10 @@ class AboutTorConnect { RPMAddMessageListener(kTorQuickstartPrefChanged, ({ data }) => { // update checkbox with latest quickstart pref value this.elemQuickstartCheckbox.checked = data; -}) +}); +RPMAddMessageListener("torconnect:bootstrap-complete", () => { + this.state = AboutTorConnect.STATE_BOOTSTRAPPED; +}); } initKeyboardShortcuts() { diff --git a/browser/modules/TorConnect.jsm b/browser/modules/TorConnect.jsm index 2b8cd15e3b62..3125c84558db 100644 --- a/browser/modules/TorConnect.jsm +++ b/browser/modules/TorConnect.jsm @@ -3,11 +3,15 @@ var EXPORTED_SYMBOLS = ["TorConnect"]; const { Services } = ChromeUtils.import( - "resource://gre/modules/Services.jsm" +"resource://gre/modules/Services.jsm" +); + +const { BrowserWindowTracker } = ChromeUtils.import( +"resource:///modules/BrowserWindowTracker.jsm" ); const { TorProtocolService } = ChromeUtils.import( - "resource:///modules/TorProtocolService.jsm" +"resource:///modules/TorProtocolService.jsm" ); // TODO: move the bootstrap state management out of each of the individual @@ -29,6 +33,17 @@ var TorConnect = (() => { case "TorBootstrapStatus": const obj = subject?.wrappedJSObject; if (obj?.PROGRESS === 100) { +