commit 405574551bf18d044365cd2c70c79d53d142a59f
parent 9b4e659207dba24b3f9d34be451d3892b04d36f7
Author: Mike Conley <mconley@mozilla.com>
Date: Thu, 4 Dec 2025 18:55:07 +0000
Bug 2003632 - Update OHTTP pre-flight request for MARS to updated specifications r=home-newtab-reviewers,nbarrett
Differential Revision: https://phabricator.services.mozilla.com/D274842
Diffstat:
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/browser/extensions/newtab/lib/DiscoveryStreamFeed.sys.mjs b/browser/extensions/newtab/lib/DiscoveryStreamFeed.sys.mjs
@@ -1204,7 +1204,7 @@ export class DiscoveryStreamFeed {
// mostly hit the HTTP cache rather than the network with these requests.
if (preFlightConfig.enabled) {
const preFlight = await this.fetchFromEndpoint(
- `${endpointBaseUrl}v1/o`,
+ `${endpointBaseUrl}v1/ads-preflight`,
{
method: "GET",
}
@@ -1217,6 +1217,7 @@ export class DiscoveryStreamFeed {
preFlight.normalized_ua || lazy.userAgent
);
headers.append("X-Geoname-ID", preFlight.geoname_id);
+ headers.append("X-Geo-Location", preFlight.geo_location);
}
}
diff --git a/browser/extensions/newtab/test/unit/lib/DiscoveryStreamFeed.test.js b/browser/extensions/newtab/test/unit/lib/DiscoveryStreamFeed.test.js
@@ -968,10 +968,11 @@ describe("DiscoveryStreamFeed", () => {
it("should fetch MARS pre flight info", async () => {
sandbox
.stub(feed, "fetchFromEndpoint")
- .withArgs("unifiedAdEndpoint/v1/o", { method: "GET" })
+ .withArgs("unifiedAdEndpoint/v1/ads-preflight", { method: "GET" })
.resolves({
normalized_ua: "normalized_ua",
geoname_id: "geoname_id",
+ geo_location: "geo_location",
});
feed.store = createStore(combineReducers(reducers), {
@@ -993,7 +994,7 @@ describe("DiscoveryStreamFeed", () => {
assert.equal(
feed.fetchFromEndpoint.firstCall.args[0],
- "unifiedAdEndpoint/v1/o"
+ "unifiedAdEndpoint/v1/ads-preflight"
);
assert.equal(feed.fetchFromEndpoint.firstCall.args[1].method, "GET");
assert.equal(
@@ -1008,6 +1009,10 @@ describe("DiscoveryStreamFeed", () => {
feed.fetchFromEndpoint.secondCall.args[1].headers.get("X-Geoname-ID"),
"geoname_id"
);
+ assert.equal(
+ feed.fetchFromEndpoint.secondCall.args[1].headers.get("X-Geo-Location"),
+ "geo_location"
+ );
});
});