Verified Commit bcf2288b authored by Richard Pospesel's avatar Richard Pospesel
Browse files

Bug 27476: Implement about:torconnect captive portal within Tor Browser

- implements new about:torconnect page as tor-launcher replacement
- adds tor connection status to url bar and tweaks UX when not online
- adds new torconnect component to browser
- tor process management functionality remains implemented in tor-launcher through the TorProtocolService module
- adds warning/error box to about:preferences#tor when not connected to tor
- explicitly allows about:torconnect URIs to ignore Resist Fingerprinting (RFP)
- various tweaks to info-pages.inc.css for about:torconnect (also affects other firefox info pages)
parent a87990e9
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -21,6 +21,10 @@ const { TelemetryController } = ChromeUtils.import(
  "resource://gre/modules/TelemetryController.jsm"
);

const { TorConnect } = ChromeUtils.import(
  "resource:///modules/TorConnect.jsm"
);

const PREF_SSL_IMPACT_ROOTS = [
  "security.tls.version.",
  "security.ssl3.",
@@ -350,6 +354,10 @@ class NetErrorParent extends JSWindowActorParent {
            break;
          }
        }
        break;
      case "ShouldShowTorConnect":
        return TorConnect.shouldShowTorConnect;
    }
    return undefined;
  }
}
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ var gIdentityHandler = {
   * RegExp used to decide if an about url should be shown as being part of
   * the browser UI.
   */
  _secureInternalPages: /^(?:accounts|addons|cache|certificate|config|crashes|downloads|license|logins|preferences|protections|rights|sessionrestore|support|welcomeback)(?:[?#]|$)/i,
  _secureInternalPages: /^(?:accounts|addons|cache|certificate|config|crashes|downloads|license|logins|preferences|protections|rights|sessionrestore|support|welcomeback|tor|torconnect)(?:[?#]|$)/i,

  /**
   * Whether the established HTTPS connection is considered "broken".
+44 −22
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
  TabModalPrompt: "chrome://global/content/tabprompts.jsm",
  TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
  TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.jsm",
  TorConnect: "resource:///modules/TorConnect.jsm",
  Translation: "resource:///modules/translation/TranslationParent.jsm",
  UITour: "resource:///modules/UITour.jsm",
  UpdateUtils: "resource://gre/modules/UpdateUtils.jsm",
@@ -633,6 +634,7 @@ var gPageIcons = {

var gInitialPages = [
  "about:tor",
  "about:torconnect",
  "about:blank",
  "about:newtab",
  "about:home",
@@ -1837,6 +1839,8 @@ var gBrowserInit = {
    }

    this._loadHandled = true;

    TorBootstrapUrlbar.init();
  },

  _cancelDelayedStartup() {
@@ -2385,6 +2389,8 @@ var gBrowserInit = {

      let defaultArgs = BrowserHandler.defaultArgs;

      // figure out which URI to actually load (or a Promise to get the uri)
      uri = ((uri) => {
        // If the given URI is different from the homepage, we want to load it.
        if (uri != defaultArgs) {
          AboutNewTab.noteNonDefaultStartup();
@@ -2411,6 +2417,20 @@ var gBrowserInit = {
        return willOverride.then(willOverrideHomepage =>
          willOverrideHomepage ? null : uri
        );
      })(uri);

      // if using TorConnect, convert these uris to redirects
      if (TorConnect.shouldShowTorConnect) {
        return Promise.resolve(uri).then((uri) => {
          if (uri == null) {
            uri  = [];
          }

          uri = TorConnect.getURIsToLoad(uri);
          return uri;
        });
      }
      return uri;
    })());
  },

@@ -2473,6 +2493,8 @@ var gBrowserInit = {

    DownloadsButton.uninit();

    TorBootstrapUrlbar.uninit();

    gAccessibilityServiceIndicator.uninit();

    if (gToolbarKeyNavEnabled) {
+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
     override rules using selectors with the same specificity. This applies to
     both "content" and "skin" packages, which bug 1385444 will unify later. -->
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xml-stylesheet href="chrome://branding/content/tor-styles.css" type="text/css"?>

<!-- While these stylesheets are defined in Toolkit, they are only used in the
     main browser window, so we can load them here. Bug 1474241 is on file to
@@ -110,6 +111,7 @@
  Services.scriptloader.loadSubScript("chrome://browser/content/search/searchbar.js", this);
  Services.scriptloader.loadSubScript("chrome://torbutton/content/tor-circuit-display.js", this);
  Services.scriptloader.loadSubScript("chrome://torbutton/content/torbutton.js", this);
  Services.scriptloader.loadSubScript("chrome://browser/content/torconnect/torBootstrapUrlbar.js", this);

  window.onload = gBrowserInit.onLoad.bind(gBrowserInit);
  window.onunload = gBrowserInit.onUnload.bind(gBrowserInit);
+11 −1
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ function setErrorPageStrings(err) {
  document.l10n.setAttributes(titleElement, title);
}

function initPage() {
async function initPage() {
  // We show an offline support page in case of a system-wide error,
  // when a user cannot connect to the internet and access the SUMO website.
  // For example, clock error, which causes certerrors across the web or
@@ -258,6 +258,16 @@ function initPage() {
  }

  var err = getErrorCode();

  // proxyConnectFailure because no-tor running daemon would return this error
  if (
     (err === "proxyConnectFailure") &&
     (await RPMSendQuery("ShouldShowTorConnect"))
  ) {
     // pass orginal destination as redirect param
     const encodedRedirect = encodeURIComponent(document.location.href);
     document.location.replace(`about:torconnect?redirect=${encodedRedirect}`);
  }
  // List of error pages with an illustration.
  let illustratedErrors = [
    "malformedURI",
Loading