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


Commits:
c92ea31b by Pier Angelo Vendrame at 2025-10-08T14:13:16+02:00
fixup! BB 19741: Fix FPI with OpenSearch.

This reverts commit 55015024a190faf1b69c4b7962ae9c6d5a4fed9c.

This reverts commit 771d640c9a037885731802bf868addd68fd678a1.

- - - - -
e8920121 by Pier Angelo Vendrame at 2025-10-08T14:13:18+02:00
Bug 1987600 - Add origin attributes to OpenSearch. r=search-reviewers,Standard8

Differential Revision: https://phabricator.services.mozilla.com/D265878

- - - - -


3 changed files:

- toolkit/components/search/OpenSearchLoader.sys.mjs
- toolkit/components/search/SearchUtils.sys.mjs
- tools/@types/generated/lib.gecko.xpcom.d.ts


Changes:

=====================================
toolkit/components/search/OpenSearchLoader.sys.mjs
=====================================
@@ -98,8 +98,9 @@ const MOZSEARCH_LOCALNAME = "SearchPlugin";
  * @param {string} [lastModified]
  *   The UTC date when the engine was last updated, if any.
  * @param {object} [originAttributes]
- *   The first party domain of the site loading that manifest. The domain of 
the
- *   manifest will be used if not provided.
+ *   The origin attributes of the site loading the manifest. If none are
+ *   specified, the origin attributes will be formed of the first party domain
+ *   based on the domain of the manifest.
  * @returns {Promise<OpenSearchProperties>}
  *   The properties of the loaded OpenSearch engine.
  */
@@ -165,7 +166,8 @@ function loadEngineXML(sourceURI, lastModified, 
originAttributes = null) {
     sourceURI,
     // OpenSearchEngine is loading a definition file for a search engine,
     // TYPE_DOCUMENT captures that load best.
-    Ci.nsIContentPolicy.TYPE_DOCUMENT
+    Ci.nsIContentPolicy.TYPE_DOCUMENT,
+    originAttributes
   );
 
   // we collect https telemetry for all top-level (document) loads.
@@ -173,17 +175,6 @@ function loadEngineXML(sourceURI, lastModified, 
originAttributes = null) {
     ? Ci.nsILoadInfo.ALREADY_HTTPS
     : Ci.nsILoadInfo.NO_UPGRADE;
 
-  if (!originAttributes) {
-    originAttributes = {};
-    try {
-      originAttributes.firstPartyDomain =
-        Services.eTLD.getSchemelessSite(sourceURI);
-    } catch (ex) {
-      console.error("Failed to get first party domain for the manifest", ex);
-    }
-  }
-  chan.loadInfo.originAttributes = originAttributes;
-
   if (lastModified && chan instanceof Ci.nsIHttpChannel) {
     chan.setRequestHeader("If-Modified-Since", lastModified, false);
   }


=====================================
toolkit/components/search/SearchUtils.sys.mjs
=====================================
@@ -244,10 +244,12 @@ export var SearchUtils = {
    *   The URL string from which to create an nsIChannel.
    * @param {nsContentPolicyType} contentPolicyType
    *   The type of document being loaded.
+   * @param {object} [originAttributes]
+   *   The origin attributes to associate to this channel.
    * @returns {nsIChannel}
    *   an nsIChannel object, or null if the url is invalid.
    */
-  makeChannel(url, contentPolicyType) {
+  makeChannel(url, contentPolicyType, originAttributes = null) {
     if (!contentPolicyType) {
       throw new Error("makeChannel called with invalid content policy type");
     }
@@ -260,11 +262,13 @@ export var SearchUtils = {
           {}
         );
       } else {
-        let originAttributes = {};
-        try {
-          originAttributes.firstPartyDomain =
-            Services.eTLD.getSchemelessSite(uri);
-        } catch {}
+        if (!originAttributes) {
+          originAttributes = {};
+          try {
+            originAttributes.firstPartyDomain =
+              Services.eTLD.getSchemelessSite(uri);
+          } catch {}
+        }
         principal =
           Services.scriptSecurityManager.createNullPrincipal(originAttributes);
       }


=====================================
tools/@types/generated/lib.gecko.xpcom.d.ts
=====================================
@@ -11613,7 +11613,7 @@ interface nsISearchService extends nsISupports, 
Enums<typeof nsISearchService_Op
   readonly hasSuccessfullyInitialized: boolean;
   runBackgroundChecks(): Promise<any>;
   resetToAppDefaultEngine(): void;
-  addOpenSearchEngine(engineURL: string, iconURL: string): Promise<any>;
+  addOpenSearchEngine(engineURL: string, iconURL: string, originAttributes?: 
any): Promise<any>;
   addUserEngine(formInfo: any): Promise<any>;
   addEnginesFromExtension(extension: any): Promise<any>;
   restoreDefaultEngines(): void;



View it on GitLab: 
https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/3ffcb9d925b2195c62fc1d20dc8d7ffe7806e57c...e8920121bfcf99e0443b43d62cd35d33f9b8f80e

-- 
View it on GitLab: 
https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/3ffcb9d925b2195c62fc1d20dc8d7ffe7806e57c...e8920121bfcf99e0443b43d62cd35d33f9b8f80e
You're receiving this email because of your account on gitlab.torproject.org.


_______________________________________________
tbb-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to