Commit 916bb368 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)

Bug 40773: Update the about:torconnect frontend page to match additional UI flows
parent 0f9475b6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ 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.",
@@ -341,6 +343,10 @@ class NetErrorParent extends JSWindowActorParent {
            break;
          }
        }
        break;
      case "ShouldShowTorConnect":
        return TorConnect.shouldShowTorConnect;
    }
    return undefined;
  }
}
+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",
@@ -646,6 +647,7 @@ var gPageIcons = {

var gInitialPages = [
  "about:tor",
  "about:torconnect",
  "about:blank",
  "about:home",
  ...(AppConstants.NIGHTLY_BUILD ? ["about:firefoxview"] : []),
@@ -1874,6 +1876,8 @@ var gBrowserInit = {
    }

    this._loadHandled = true;

    TorBootstrapUrlbar.init();
  },

  _cancelDelayedStartup() {
@@ -2421,21 +2425,23 @@ var gBrowserInit = {

      let defaultArgs = BrowserHandler.defaultArgs;

      // figure out which URI to actually load (or a Promise to get the uri)
      uri = (aUri => {
        // If the given URI is different from the homepage, we want to load it.
      if (uri != defaultArgs) {
        if (aUri != defaultArgs) {
          AboutNewTab.noteNonDefaultStartup();

        if (uri instanceof Ci.nsIArray) {
          if (aUri instanceof Ci.nsIArray) {
            // Transform the nsIArray of nsISupportsString's into a JS Array of
            // JS strings.
            return Array.from(
            uri.enumerate(Ci.nsISupportsString),
              aUri.enumerate(Ci.nsISupportsString),
              supportStr => supportStr.data
            );
        } else if (uri instanceof Ci.nsISupportsString) {
          return uri.data;
          } else if (aUri instanceof Ci.nsISupportsString) {
            return aUri.data;
          }
        return uri;
          return aUri;
        }

        // The URI appears to be the the homepage. We want to load it only if
@@ -2447,6 +2453,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(aUri => {
          if (aUri == null) {
            aUri = [];
          }

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

@@ -2513,6 +2533,8 @@ var gBrowserInit = {

    NewIdentityButton.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
@@ -122,6 +123,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
@@ -230,7 +230,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
@@ -253,6 +253,16 @@ function initPage() {
    document.body.classList.add("blocked");
  }

  // 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}`);
  }

  // Only worry about captive portals if this is a cert error.
  let showCaptivePortalUI = isCaptive() && gIsCertError;
  if (showCaptivePortalUI) {
+1 −0
Original line number Diff line number Diff line
@@ -323,6 +323,7 @@
                   data-l10n-id="urlbar-go-button"/>
            <hbox id="page-action-buttons" context="pageActionContextMenu">
              <toolbartabstop/>
#include ../../components/torconnect/content/torconnect-urlbar.inc.xhtml
              <hbox id="contextual-feature-recommendation" role="button" hidden="true">
                <hbox id="cfr-label-container">
                  <label id="cfr-label"/>
Loading