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
-
e8920121
by Pier Angelo Vendrame at 2025-10-08T14:13:18+02:00
3 changed files:
- toolkit/components/search/OpenSearchLoader.sys.mjs
- toolkit/components/search/SearchUtils.sys.mjs
- tools/@types/generated/lib.gecko.xpcom.d.ts
Changes:
... | ... | @@ -98,8 +98,9 @@ const MOZSEARCH_LOCALNAME = "SearchPlugin"; |
98 | 98 | * @param {string} [lastModified]
|
99 | 99 | * The UTC date when the engine was last updated, if any.
|
100 | 100 | * @param {object} [originAttributes]
|
101 | - * The first party domain of the site loading that manifest. The domain of the
|
|
102 | - * manifest will be used if not provided.
|
|
101 | + * The origin attributes of the site loading the manifest. If none are
|
|
102 | + * specified, the origin attributes will be formed of the first party domain
|
|
103 | + * based on the domain of the manifest.
|
|
103 | 104 | * @returns {Promise<OpenSearchProperties>}
|
104 | 105 | * The properties of the loaded OpenSearch engine.
|
105 | 106 | */
|
... | ... | @@ -165,7 +166,8 @@ function loadEngineXML(sourceURI, lastModified, originAttributes = null) { |
165 | 166 | sourceURI,
|
166 | 167 | // OpenSearchEngine is loading a definition file for a search engine,
|
167 | 168 | // TYPE_DOCUMENT captures that load best.
|
168 | - Ci.nsIContentPolicy.TYPE_DOCUMENT
|
|
169 | + Ci.nsIContentPolicy.TYPE_DOCUMENT,
|
|
170 | + originAttributes
|
|
169 | 171 | );
|
170 | 172 | |
171 | 173 | // we collect https telemetry for all top-level (document) loads.
|
... | ... | @@ -173,17 +175,6 @@ function loadEngineXML(sourceURI, lastModified, originAttributes = null) { |
173 | 175 | ? Ci.nsILoadInfo.ALREADY_HTTPS
|
174 | 176 | : Ci.nsILoadInfo.NO_UPGRADE;
|
175 | 177 | |
176 | - if (!originAttributes) {
|
|
177 | - originAttributes = {};
|
|
178 | - try {
|
|
179 | - originAttributes.firstPartyDomain =
|
|
180 | - Services.eTLD.getSchemelessSite(sourceURI);
|
|
181 | - } catch (ex) {
|
|
182 | - console.error("Failed to get first party domain for the manifest", ex);
|
|
183 | - }
|
|
184 | - }
|
|
185 | - chan.loadInfo.originAttributes = originAttributes;
|
|
186 | - |
|
187 | 178 | if (lastModified && chan instanceof Ci.nsIHttpChannel) {
|
188 | 179 | chan.setRequestHeader("If-Modified-Since", lastModified, false);
|
189 | 180 | }
|
... | ... | @@ -244,10 +244,12 @@ export var SearchUtils = { |
244 | 244 | * The URL string from which to create an nsIChannel.
|
245 | 245 | * @param {nsContentPolicyType} contentPolicyType
|
246 | 246 | * The type of document being loaded.
|
247 | + * @param {object} [originAttributes]
|
|
248 | + * The origin attributes to associate to this channel.
|
|
247 | 249 | * @returns {nsIChannel}
|
248 | 250 | * an nsIChannel object, or null if the url is invalid.
|
249 | 251 | */
|
250 | - makeChannel(url, contentPolicyType) {
|
|
252 | + makeChannel(url, contentPolicyType, originAttributes = null) {
|
|
251 | 253 | if (!contentPolicyType) {
|
252 | 254 | throw new Error("makeChannel called with invalid content policy type");
|
253 | 255 | }
|
... | ... | @@ -260,11 +262,13 @@ export var SearchUtils = { |
260 | 262 | {}
|
261 | 263 | );
|
262 | 264 | } else {
|
263 | - let originAttributes = {};
|
|
264 | - try {
|
|
265 | - originAttributes.firstPartyDomain =
|
|
266 | - Services.eTLD.getSchemelessSite(uri);
|
|
267 | - } catch {}
|
|
265 | + if (!originAttributes) {
|
|
266 | + originAttributes = {};
|
|
267 | + try {
|
|
268 | + originAttributes.firstPartyDomain =
|
|
269 | + Services.eTLD.getSchemelessSite(uri);
|
|
270 | + } catch {}
|
|
271 | + }
|
|
268 | 272 | principal =
|
269 | 273 | Services.scriptSecurityManager.createNullPrincipal(originAttributes);
|
270 | 274 | }
|
... | ... | @@ -11613,7 +11613,7 @@ interface nsISearchService extends nsISupports, Enums<typeof nsISearchService_Op |
11613 | 11613 | readonly hasSuccessfullyInitialized: boolean;
|
11614 | 11614 | runBackgroundChecks(): Promise<any>;
|
11615 | 11615 | resetToAppDefaultEngine(): void;
|
11616 | - addOpenSearchEngine(engineURL: string, iconURL: string): Promise<any>;
|
|
11616 | + addOpenSearchEngine(engineURL: string, iconURL: string, originAttributes?: any): Promise<any>;
|
|
11617 | 11617 | addUserEngine(formInfo: any): Promise<any>;
|
11618 | 11618 | addEnginesFromExtension(extension: any): Promise<any>;
|
11619 | 11619 | restoreDefaultEngines(): void;
|