henry pushed to branch tor-browser-128.8.0esr-14.5-1 at The Tor Project / Applications / Tor Browser

Commits:

10 changed files:

Changes:

  • .eslintignore
    ... ... @@ -304,4 +304,5 @@ browser/app/profile/001-base-profile.js
    304 304
     browser/app/profile/000-tor-browser.js
    
    305 305
     mobile/android/app/000-tor-browser-android.js
    
    306 306
     toolkit/content/pt_config.json
    
    307
    +toolkit/content/moat_contries_dev_build.json
    
    307 308
     toolkit/components/lox/lox_wasm.jsm

  • .prettierignore
    ... ... @@ -1533,4 +1533,5 @@ browser/app/profile/001-base-profile.js
    1533 1533
     browser/app/profile/000-tor-browser.js
    
    1534 1534
     mobile/android/app/000-tor-browser-android.js
    
    1535 1535
     toolkit/content/pt_config.json
    
    1536
    +toolkit/content/moat_countries_dev_build.json
    
    1536 1537
     toolkit/components/lox/lox_wasm.jsm

  • browser/components/torpreferences/content/connectionPane.js
    ... ... @@ -2529,65 +2529,48 @@ const gConnectionPane = (function () {
    2529 2529
                 regionCode: location.value,
    
    2530 2530
               });
    
    2531 2531
             });
    
    2532
    -        this._populateLocations = () => {
    
    2533
    -          const currentValue = location.value;
    
    2534
    -          locationEntries.textContent = "";
    
    2535
    -          const createItem = (value, label, disabled) => {
    
    2536
    -            const item = document.createXULElement("menuitem");
    
    2537
    -            item.setAttribute("value", value);
    
    2538
    -            item.setAttribute("label", label);
    
    2539
    -            if (disabled) {
    
    2540
    -              item.setAttribute("disabled", "true");
    
    2541
    -            }
    
    2542
    -            return item;
    
    2543
    -          };
    
    2544
    -          const addLocations = codes => {
    
    2545
    -            const items = [];
    
    2546
    -            for (const code of codes) {
    
    2547
    -              items.push(
    
    2548
    -                createItem(
    
    2549
    -                  code,
    
    2550
    -                  TorConnect.countryNames[code]
    
    2551
    -                    ? TorConnect.countryNames[code]
    
    2552
    -                    : code
    
    2553
    -                )
    
    2554
    -              );
    
    2555
    -            }
    
    2556
    -            items.sort((left, right) => left.label.localeCompare(right.label));
    
    2557
    -            locationEntries.append(...items);
    
    2558
    -          };
    
    2559
    -          locationEntries.append(
    
    2560
    -            createItem("automatic", TorStrings.settings.bridgeLocationAutomatic)
    
    2561
    -          );
    
    2562
    -          if (TorConnect.countryCodes.length) {
    
    2563
    -            locationEntries.append(
    
    2564
    -              createItem("", TorStrings.settings.bridgeLocationFrequent, true)
    
    2565
    -            );
    
    2566
    -            addLocations(TorConnect.countryCodes);
    
    2567
    -            locationEntries.append(
    
    2568
    -              createItem("", TorStrings.settings.bridgeLocationOther, true)
    
    2532
    +        const createItem = (value, label, disabled) => {
    
    2533
    +          const item = document.createXULElement("menuitem");
    
    2534
    +          item.setAttribute("value", value);
    
    2535
    +          item.setAttribute("label", label);
    
    2536
    +          if (disabled) {
    
    2537
    +            item.setAttribute("disabled", "true");
    
    2538
    +          }
    
    2539
    +          return item;
    
    2540
    +        };
    
    2541
    +        const addLocations = codes => {
    
    2542
    +          const items = [];
    
    2543
    +          for (const code of codes) {
    
    2544
    +            items.push(
    
    2545
    +              createItem(
    
    2546
    +                code,
    
    2547
    +                TorConnect.countryNames[code]
    
    2548
    +                  ? TorConnect.countryNames[code]
    
    2549
    +                  : code
    
    2550
    +              )
    
    2569 2551
                 );
    
    2570 2552
               }
    
    2571
    -          addLocations(Object.keys(TorConnect.countryNames));
    
    2572
    -          location.value = currentValue;
    
    2553
    +          items.sort((left, right) => left.label.localeCompare(right.label));
    
    2554
    +          locationEntries.append(...items);
    
    2573 2555
             };
    
    2556
    +        // Add automatic before waiting for getFrequentRegions.
    
    2557
    +        locationEntries.append(
    
    2558
    +          createItem("automatic", TorStrings.settings.bridgeLocationAutomatic)
    
    2559
    +        );
    
    2560
    +        location.value = "automatic";
    
    2561
    +        TorConnect.getFrequentRegions().then(frequentCodes => {
    
    2562
    +          locationEntries.append(
    
    2563
    +            createItem("", TorStrings.settings.bridgeLocationFrequent, true)
    
    2564
    +          );
    
    2565
    +          addLocations(frequentCodes);
    
    2566
    +          locationEntries.append(
    
    2567
    +            createItem("", TorStrings.settings.bridgeLocationOther, true)
    
    2568
    +          );
    
    2569
    +          addLocations(Object.keys(TorConnect.countryNames));
    
    2570
    +        });
    
    2574 2571
             this._showAutoconfiguration = () => {
    
    2575
    -          if (
    
    2576
    -            !TorConnect.canBeginAutoBootstrap ||
    
    2577
    -            !TorConnect.potentiallyBlocked
    
    2578
    -          ) {
    
    2579
    -            locationGroup.setAttribute("hidden", "true");
    
    2580
    -            return;
    
    2581
    -          }
    
    2582
    -          // Populate locations, even though we will show only the automatic
    
    2583
    -          // item for a moment. In my opinion showing the button immediately is
    
    2584
    -          // better then waiting for the Moat query to finish (after a while)
    
    2585
    -          // and showing the controls only after that.
    
    2586
    -          this._populateLocations();
    
    2587
    -          locationGroup.removeAttribute("hidden");
    
    2588
    -          if (!TorConnect.countryCodes.length) {
    
    2589
    -            TorConnect.getCountryCodes().then(() => this._populateLocations());
    
    2590
    -          }
    
    2572
    +          locationGroup.hidden =
    
    2573
    +            !TorConnect.canBeginAutoBootstrap || !TorConnect.potentiallyBlocked;
    
    2591 2574
             };
    
    2592 2575
             this._showAutoconfiguration();
    
    2593 2576
           }
    

  • toolkit/components/torconnect/TorConnectParent.sys.mjs
    ... ... @@ -132,8 +132,8 @@ export class TorConnectParent extends JSWindowActorParent {
    132 132
               stage: TorConnect.stage,
    
    133 133
               quickstartEnabled: TorConnect.quickstart,
    
    134 134
             };
    
    135
    -      case "torconnect:get-country-codes":
    
    136
    -        return TorConnect.getCountryCodes();
    
    135
    +      case "torconnect:get-frequent-regions":
    
    136
    +        return TorConnect.getFrequentRegions();
    
    137 137
         }
    
    138 138
         return undefined;
    
    139 139
       }
    

  • toolkit/components/torconnect/content/aboutTorConnect.js
    ... ... @@ -610,7 +610,7 @@ class AboutTorConnect {
    610 610
     
    
    611 611
       showLocationForm(isChoose, buttonLabel) {
    
    612 612
         this.hideButtons();
    
    613
    -    RPMSendQuery("torconnect:get-country-codes").then(codes => {
    
    613
    +    RPMSendQuery("torconnect:get-frequent-regions").then(codes => {
    
    614 614
           if (codes && codes.length) {
    
    615 615
             this.populateFrequentLocations(codes);
    
    616 616
             this.setLocation();
    

  • toolkit/content/jar.mn
    ... ... @@ -158,4 +158,9 @@ toolkit.jar:
    158 158
        content/global/third_party/d3/d3.js                (/third_party/js/d3/d3.js)
    
    159 159
        content/global/third_party/cfworker/json-schema.js (/third_party/js/cfworker/json-schema.js)
    
    160 160
     
    
    161
    +   # The pt_config.json content should be replaced in the omni.ja in
    
    162
    +   # tor-browser-build. See tor-browser#42343.
    
    161 163
        content/global/pt_config.json               (pt_config.json)
    
    164
    +   # The moat_countries.json content should be replaced in the omni.ja in
    
    165
    +   # tor-browser-build. See tor-browser#43463.
    
    166
    +   content/global/moat_countries.json          (moat_countries_dev_build.json)

  • toolkit/content/moat_countries_dev_build.json
    1
    +[
    
    2
    +    {
    
    3
    +        "_comment1": "Used for dev build, replaced for release builds in tor-browser-build.",
    
    4
    +        "_comment2": "List is taken from tpo/anti-censorship/rdsys-admin 810fb24b:conf/circumvention.json and filtered with `jq -c keys`."
    
    5
    +    },
    
    6
    +    "by","cn","eg","hk","ir","mm","ru","tm"
    
    7
    +]

  • toolkit/modules/Moat.sys.mjs
    ... ... @@ -335,20 +335,6 @@ export class MoatRPC {
    335 335
         return settings;
    
    336 336
       }
    
    337 337
     
    
    338
    -  // Request a list of country codes with available censorship circumvention
    
    339
    -  // settings.
    
    340
    -  //
    
    341
    -  // returns an array of ISO 3166-1 alpha-2 country codes which we can query
    
    342
    -  // settings for.
    
    343
    -  async circumvention_countries() {
    
    344
    -    const args = {};
    
    345
    -    const { response } = await this.#makeRequest(
    
    346
    -      "circumvention/countries",
    
    347
    -      args
    
    348
    -    );
    
    349
    -    return response;
    
    350
    -  }
    
    351
    -
    
    352 338
       // Request a copy of the builtin bridges, takes the following parameters:
    
    353 339
       // - transports: optional, an array of transports we would like the latest
    
    354 340
       //   bridge strings for; if empty (or not given) returns all of them
    

  • toolkit/modules/RemotePageAccessManager.sys.mjs
    ... ... @@ -255,7 +255,7 @@ export let RemotePageAccessManager = {
    255 255
           ],
    
    256 256
           RPMSendQuery: [
    
    257 257
             "torconnect:get-init-args",
    
    258
    -        "torconnect:get-country-codes",
    
    258
    +        "torconnect:get-frequent-regions",
    
    259 259
           ],
    
    260 260
         },
    
    261 261
         "about:welcome": {
    

  • toolkit/modules/TorConnect.sys.mjs
    ... ... @@ -817,8 +817,14 @@ export const TorConnect = {
    817 817
         };
    
    818 818
       },
    
    819 819
     
    
    820
    -  // list of country codes Moat has settings for
    
    821
    -  _countryCodes: [],
    
    820
    +  /**
    
    821
    +   * Promise that resolves to a list of region codes that Moat has special
    
    822
    +   * bridge settings for.
    
    823
    +   *
    
    824
    +   * @type {Promise<string[]>}
    
    825
    +   */
    
    826
    +  _moatRegionsPromise: null,
    
    827
    +
    
    822 828
       _countryNames: Object.freeze(
    
    823 829
         (() => {
    
    824 830
           const codes = Services.intl.getAvailableLocaleDisplayNames("region");
    
    ... ... @@ -892,6 +898,18 @@ export const TorConnect = {
    892 898
           return;
    
    893 899
         }
    
    894 900
     
    
    901
    +    this._moatRegionsPromise = fetch(
    
    902
    +      "chrome://global/content/moat_countries.json"
    
    903
    +    )
    
    904
    +      .then(req => req.json())
    
    905
    +      // Filter out the "_comment" object in the moat_countries_dev_build.json
    
    906
    +      // file.
    
    907
    +      .then(regionList => regionList.filter(r => typeof r === "string"))
    
    908
    +      .catch(e => {
    
    909
    +        lazy.logger.error("Failed to fetch Moat region codes", e);
    
    910
    +        return [];
    
    911
    +      });
    
    912
    +
    
    895 913
         let observeTopic = addTopic => {
    
    896 914
           Services.obs.addObserver(this, addTopic);
    
    897 915
           lazy.logger.debug(`Observing topic '${addTopic}'`);
    
    ... ... @@ -1113,10 +1131,6 @@ export const TorConnect = {
    1113 1131
         return null;
    
    1114 1132
       },
    
    1115 1133
     
    
    1116
    -  get countryCodes() {
    
    1117
    -    return this._countryCodes;
    
    1118
    -  },
    
    1119
    -
    
    1120 1134
       get countryNames() {
    
    1121 1135
         return this._countryNames;
    
    1122 1136
       },
    
    ... ... @@ -1526,25 +1540,12 @@ export const TorConnect = {
    1526 1540
         this._makeStageRequest(TorConnectStage.ChooseRegion);
    
    1527 1541
       },
    
    1528 1542
     
    
    1529
    -  /*
    
    1530
    -    Further external commands and helper methods
    
    1543
    +  /**
    
    1544
    +   * Get the list of regions that Moat has settings for.
    
    1545
    +   *
    
    1546
    +   * @returns {string[]} - The list of region codes.
    
    1531 1547
        */
    
    1532
    -
    
    1533
    -  async getCountryCodes() {
    
    1534
    -    // Difference with the getter: this is to be called by TorConnectParent, and
    
    1535
    -    // downloads the country codes if they are not already in cache.
    
    1536
    -    if (this._countryCodes.length) {
    
    1537
    -      return this._countryCodes;
    
    1538
    -    }
    
    1539
    -    const mrpc = new lazy.MoatRPC();
    
    1540
    -    try {
    
    1541
    -      await mrpc.init();
    
    1542
    -      this._countryCodes = await mrpc.circumvention_countries();
    
    1543
    -    } catch (err) {
    
    1544
    -      lazy.logger.error("An error occurred while fetching country codes", err);
    
    1545
    -    } finally {
    
    1546
    -      mrpc.uninit();
    
    1547
    -    }
    
    1548
    -    return this._countryCodes;
    
    1548
    +  async getFrequentRegions() {
    
    1549
    +    return this._moatRegionsPromise ?? [];
    
    1549 1550
       },
    
    1550 1551
     };