Pier Angelo Vendrame pushed to branch tor-browser-140.2.0esr-15.0-1 at The Tor Project / Applications / Tor Browser

Commits:

3 changed files:

Changes:

  • toolkit/components/search/SearchEngineSelector.sys.mjs
    ... ... @@ -2,6 +2,8 @@
    2 2
      * License, v. 2.0. If a copy of the MPL was not distributed with this
    
    3 3
      * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    
    4 4
     
    
    5
    +import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
    
    6
    +
    
    5 7
     /**
    
    6 8
      * @typedef {import("../uniffi-bindgen-gecko-js/components/generated/RustSearch.sys.mjs").SearchEngineSelector} RustSearchEngineSelector
    
    7 9
      * We use "Rust" above to avoid conflict with the class name for the JavaScript wrapper.
    
    ... ... @@ -92,30 +94,13 @@ export class SearchEngineSelector {
    92 94
           return this._getConfigurationPromise;
    
    93 95
         }
    
    94 96
     
    
    95
    -    this._getConfigurationPromise = Promise.all([
    
    96
    -      this._getConfiguration(),
    
    97
    -      this._getConfigurationOverrides(),
    
    98
    -    ]);
    
    99
    -    let remoteSettingsData = await this._getConfigurationPromise;
    
    100
    -    this._configuration = remoteSettingsData[0];
    
    101
    -    this._configurationOverrides = remoteSettingsData[1];
    
    102
    -    delete this._getConfigurationPromise;
    
    103
    -
    
    104
    -    if (!this._configuration?.length) {
    
    105
    -      throw Components.Exception(
    
    106
    -        "Failed to get engine data from Remote Settings",
    
    107
    -        Cr.NS_ERROR_UNEXPECTED
    
    108
    -      );
    
    109
    -    }
    
    110
    -
    
    111
    -    if (!this._listenerAdded) {
    
    112
    -      this._remoteConfig.on("sync", this._onConfigurationUpdated);
    
    113
    -      this._remoteConfigOverrides.on(
    
    114
    -        "sync",
    
    115
    -        this._onConfigurationOverridesUpdated
    
    116
    -      );
    
    117
    -      this._listenerAdded = true;
    
    118
    -    }
    
    97
    +    let { promise, resolve } = Promise.withResolvers();
    
    98
    +    this._getConfigurationPromise = promise;
    
    99
    +    this._configuration = await (
    
    100
    +      await fetch("chrome://global/content/search/torBrowserSearchEngines.json")
    
    101
    +    ).json();
    
    102
    +    this._configurationOverrides = [];
    
    103
    +    resolve(this._configuration);
    
    119 104
     
    
    120 105
         if (lazy.SearchUtils.rustSelectorFeatureGate) {
    
    121 106
           this.#selector.setSearchConfig(
    
    ... ... @@ -242,6 +227,12 @@ export class SearchEngineSelector {
    242 227
        *   The new configuration object
    
    243 228
        */
    
    244 229
       _onConfigurationUpdated({ data: { current } }) {
    
    230
    +    // tor-browser#43525: Even though RemoteSettings are a no-op for us, we do
    
    231
    +    // not want them to interfere in any way.
    
    232
    +    if (AppConstants.BASE_BROWSER_VERSION) {
    
    233
    +      return;
    
    234
    +    }
    
    235
    +
    
    245 236
         this._configuration = current;
    
    246 237
     
    
    247 238
         if (lazy.SearchUtils.rustSelectorFeatureGate) {
    
    ... ... @@ -268,6 +259,12 @@ export class SearchEngineSelector {
    268 259
        *   The new configuration object
    
    269 260
        */
    
    270 261
       _onConfigurationOverridesUpdated({ data: { current } }) {
    
    262
    +    // tor-browser#43525: Even though RemoteSettings are a no-op for us, we do
    
    263
    +    // not want them to interfere in any way.
    
    264
    +    if (AppConstants.BASE_BROWSER_VERSION) {
    
    265
    +      return;
    
    266
    +    }
    
    267
    +
    
    271 268
         this._configurationOverrides = current;
    
    272 269
     
    
    273 270
         if (lazy.SearchUtils.rustSelectorFeatureGate) {
    

  • toolkit/components/search/SearchService.sys.mjs
    ... ... @@ -2628,11 +2628,21 @@ export class SearchService {
    2628 2628
       // This is prefixed with _ rather than # because it is
    
    2629 2629
       // called in test_remove_engine_notification_box.js
    
    2630 2630
       async _fetchEngineSelectorEngines() {
    
    2631
    -    // tor-browser#43525: Check this still works.
    
    2632
    -    const engines = await (
    
    2633
    -      await fetch("chrome://global/content/search/torBrowserSearchEngines.json")
    
    2634
    -    ).json();
    
    2635
    -    return { engines, privateDefault: undefined };
    
    2631
    +    let searchEngineSelectorProperties = {
    
    2632
    +      locale: "en-US",
    
    2633
    +      region: lazy.Region.home || "unknown",
    
    2634
    +      channel: lazy.SearchUtils.MODIFIED_APP_CHANNEL,
    
    2635
    +      experiment: this._experimentPrefValue,
    
    2636
    +      distroID: lazy.SearchUtils.distroID ?? "",
    
    2637
    +    };
    
    2638
    +
    
    2639
    +    for (let [key, value] of Object.entries(searchEngineSelectorProperties)) {
    
    2640
    +      this._settings.setMetaDataAttribute(key, value);
    
    2641
    +    }
    
    2642
    +
    
    2643
    +    return this.#engineSelector.fetchEngineConfiguration(
    
    2644
    +      searchEngineSelectorProperties
    
    2645
    +    );
    
    2636 2646
       }
    
    2637 2647
     
    
    2638 2648
       #setDefaultFromSelector(refinedConfig) {
    

  • toolkit/components/search/content/torBrowserSearchEngines.json
    1 1
     [
    
    2 2
       {
    
    3
    -    "aliases": ["duckduckgo", "ddg"],
    
    4
    -    "name": "DuckDuckGo",
    
    5
    -    "urls": {
    
    6
    -      "search": {
    
    7
    -        "base": "https://duckduckgo.com/",
    
    8
    -        "params": [],
    
    9
    -        "searchTermParamName": "q"
    
    3
    +    "base": {
    
    4
    +      "aliases": ["duckduckgo", "ddg"],
    
    5
    +      "classification": "general",
    
    6
    +      "name": "DuckDuckGo",
    
    7
    +      "urls": {
    
    8
    +        "search": {
    
    9
    +          "base": "https://duckduckgo.com/",
    
    10
    +          "params": [],
    
    11
    +          "searchTermParamName": "q"
    
    12
    +        }
    
    10 13
           }
    
    11 14
         },
    
    12 15
         "id": "04e99a38-13ee-47d8-8aa4-64482b3dea99",
    
    13 16
         "identifier": "ddg",
    
    14 17
         "recordType": "engine",
    
    15
    -    "variants": []
    
    18
    +    "variants": [
    
    19
    +      {
    
    20
    +        "environment": {
    
    21
    +          "allRegionsAndLocales": true
    
    22
    +        }
    
    23
    +      }
    
    24
    +    ]
    
    16 25
       },
    
    17 26
       {
    
    18
    -    "aliases": ["ddgonion"],
    
    19
    -    "name": "DuckDuckGo (.onion)",
    
    20
    -    "urls": {
    
    21
    -      "search": {
    
    22
    -        "base": "https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/",
    
    23
    -        "params": [],
    
    24
    -        "searchTermParamName": "q"
    
    27
    +    "base": {
    
    28
    +      "aliases": ["ddgonion"],
    
    29
    +      "classification": "general",
    
    30
    +      "name": "DuckDuckGo (.onion)",
    
    31
    +      "urls": {
    
    32
    +        "search": {
    
    33
    +          "base": "https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/",
    
    34
    +          "params": [],
    
    35
    +          "searchTermParamName": "q"
    
    36
    +        }
    
    25 37
           }
    
    26 38
         },
    
    27 39
         "id": "1e431da4-a60c-4411-9251-a95a841d451f",
    
    28 40
         "identifier": "ddg-onion",
    
    29 41
         "recordType": "engine",
    
    30
    -    "variants": []
    
    42
    +    "variants": [
    
    43
    +      {
    
    44
    +        "environment": {
    
    45
    +          "allRegionsAndLocales": true
    
    46
    +        }
    
    47
    +      }
    
    48
    +    ]
    
    31 49
       },
    
    32 50
       {
    
    33
    -    "aliases": ["startpage"],
    
    34
    -    "name": "Startpage",
    
    35
    -    "urls": {
    
    36
    -      "search": {
    
    37
    -        "base": "https://www.startpage.com/sp/search",
    
    38
    -        "params": [],
    
    39
    -        "searchTermParamName": "q"
    
    51
    +    "base": {
    
    52
    +      "aliases": ["startpage"],
    
    53
    +      "classification": "general",
    
    54
    +      "name": "Startpage",
    
    55
    +      "urls": {
    
    56
    +        "search": {
    
    57
    +          "base": "https://www.startpage.com/sp/search",
    
    58
    +          "params": [],
    
    59
    +          "searchTermParamName": "q"
    
    60
    +        }
    
    40 61
           }
    
    41 62
         },
    
    42 63
         "id": "927bbd9f-b2f3-48b4-8974-1c1148028f4d",
    
    43 64
         "identifier": "startpage",
    
    44 65
         "recordType": "engine",
    
    45
    -    "variants": []
    
    66
    +    "variants": [
    
    67
    +      {
    
    68
    +        "environment": {
    
    69
    +          "allRegionsAndLocales": true
    
    70
    +        }
    
    71
    +      }
    
    72
    +    ]
    
    46 73
       },
    
    47 74
       {
    
    48
    -    "aliases": ["startpage-onion"],
    
    49
    -    "name": "Startpage (.onion)",
    
    50
    -    "urls": {
    
    51
    -      "search": {
    
    52
    -        "base": "http://startpagel6srwcjlue4zgq3zevrujfaow726kjytqbbjyrswwmjzcqd.onion/sp/search",
    
    53
    -        "params": [],
    
    54
    -        "searchTermParamName": "q"
    
    75
    +    "base": {
    
    76
    +      "aliases": ["startpage-onion"],
    
    77
    +      "classification": "general",
    
    78
    +      "name": "Startpage (.onion)",
    
    79
    +      "urls": {
    
    80
    +        "search": {
    
    81
    +          "base": "http://startpagel6srwcjlue4zgq3zevrujfaow726kjytqbbjyrswwmjzcqd.onion/sp/search",
    
    82
    +          "params": [],
    
    83
    +          "searchTermParamName": "q"
    
    84
    +        }
    
    55 85
           }
    
    56 86
         },
    
    57 87
         "id": "e7eaba8d-6b9e-43fb-a799-b01b096c03ff",
    
    58 88
         "identifier": "startpage-onion",
    
    59 89
         "recordType": "engine",
    
    60
    -    "variants": []
    
    90
    +    "variants": [
    
    91
    +      {
    
    92
    +        "environment": {
    
    93
    +          "allRegionsAndLocales": true
    
    94
    +        }
    
    95
    +      }
    
    96
    +    ]
    
    61 97
       },
    
    62 98
       {
    
    63
    -    "aliases": ["wikipedia"],
    
    64
    -    "classification": "unknown",
    
    65
    -    "name": "Wikipedia (en)",
    
    66
    -    "urls": {
    
    67
    -      "search": {
    
    68
    -        "base": "https://en.wikipedia.org/wiki/Special:Search",
    
    69
    -        "params": [],
    
    70
    -        "searchTermParamName": "search"
    
    99
    +    "base": {
    
    100
    +      "aliases": ["wikipedia"],
    
    101
    +      "classification": "unknown",
    
    102
    +      "name": "Wikipedia (en)",
    
    103
    +      "urls": {
    
    104
    +        "search": {
    
    105
    +          "base": "https://en.wikipedia.org/wiki/Special:Search",
    
    106
    +          "params": [],
    
    107
    +          "searchTermParamName": "search"
    
    108
    +        }
    
    71 109
           }
    
    72 110
         },
    
    73 111
         "id": "7f6d23c2-191e-483e-af3a-ce6451e3a8dd",
    
    74 112
         "identifier": "wikipedia",
    
    75 113
         "recordType": "engine",
    
    76
    -    "variants": []
    
    114
    +    "variants": [
    
    115
    +      {
    
    116
    +        "environment": {
    
    117
    +          "allRegionsAndLocales": true
    
    118
    +        }
    
    119
    +      }
    
    120
    +    ]
    
    121
    +  },
    
    122
    +  {
    
    123
    +    "recordType": "defaultEngines",
    
    124
    +    "globalDefault": "ddg",
    
    125
    +    "globalDefaultPrivate": "ddg"
    
    77 126
       }
    
    78 127
     ]