commit 43fa03cbf7bfafd52b19432ce43066ae8724eb43
parent 81399e64aeaee7a8dae90c9d44030162fc4d60c1
Author: Nathan Barrett <nbarrett@mozilla.com>
Date: Wed, 3 Dec 2025 18:38:15 +0000
Bug 2001400 - Add pref for dap.hpke and pass as options in attribution conversion r=home-newtab-reviewers,mconley
Differential Revision: https://phabricator.services.mozilla.com/D273483
Diffstat:
3 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
@@ -676,6 +676,12 @@ pref("browser.urlbar.merino.ohttpConfigURL", "");
// OHTTP relay URL for Merino requests
pref("browser.urlbar.merino.ohttpRelayURL", "");
+// OHTTP hpke for DAP
+pref("dap.ohttp.hpke", "https://dap-09-3.api.divviup.org/ohttp-configs");
+
+// OHTTP relay URL for DAP
+pref("dap.ohttp.relayURL", "https://mozilla-ohttp-dap.mozilla.fastly-edge.com/");
+
// Enable site specific search result.
pref("browser.urlbar.contextualSearch.enabled", true);
diff --git a/browser/extensions/newtab/lib/NewTabAttributionService.sys.mjs b/browser/extensions/newtab/lib/NewTabAttributionService.sys.mjs
@@ -15,6 +15,9 @@ const MAX_LOOKBACK_DAYS = 30;
const DAY_IN_MILLI = 1000 * 60 * 60 * 24;
const CONVERSION_RESET_MILLI = 7 * DAY_IN_MILLI;
+const DAP_HPKE_PREF = "dap.ohttp.hpke";
+const DAP_RELAY_PREF = "dap.ohttp.relayURL";
+
/**
*
*/
@@ -175,7 +178,14 @@ class NewTabAttributionService {
if (lookbackDays > MAX_LOOKBACK_DAYS) {
return;
}
-
+ const dapHpke = Services.prefs.getCharPref(
+ DAP_HPKE_PREF,
+ "https://dap-09-3.api.divviup.org/ohttp-configs"
+ );
+ const ohttpRelayURL = Services.prefs.getCharPref(
+ DAP_RELAY_PREF,
+ "https://mozilla-ohttp-dap.mozilla.fastly-edge.com/"
+ );
const now = this.#now();
const budget = await this.#getBudget(partnerId, now);
@@ -205,10 +215,20 @@ class NewTabAttributionService {
}
await this.#updateBudget(budget, budgetSpend, partnerId);
+
+ const options = {};
+ if (dapHpke) {
+ options.ohttp_hpke = dapHpke;
+ }
+
+ if (ohttpRelayURL) {
+ options.ohttp_relay = ohttpRelayURL;
+ }
+
await this.#dapSender.sendDAPMeasurement(
conversion.task,
measurement,
- {}
+ options
);
} catch (e) {
console.error(e);
diff --git a/browser/extensions/newtab/test/xpcshell/test_NewTabAttributionService.js b/browser/extensions/newtab/test/xpcshell/test_NewTabAttributionService.js
@@ -46,10 +46,11 @@ class MockDAPSender {
this.receivedMeasurements = [];
}
- async sendDAPMeasurement(task, measurement, _options) {
+ async sendDAPMeasurement(task, measurement, options) {
this.receivedMeasurements.push({
task,
measurement,
+ options,
});
}
}
@@ -145,6 +146,10 @@ add_task(async function testSuccessfulConversion() {
time_precision: conversionSettings.time_precision,
},
measurement: conversionSettings.index,
+ options: {
+ ohttp_hpke: Services.prefs.getStringPref("dap.ohttp.hpke"),
+ ohttp_relay: Services.prefs.getStringPref("dap.ohttp.relayURL"),
+ },
};
const receivedMeasurement = mockSender.receivedMeasurements.pop();
@@ -571,6 +576,8 @@ add_task(async function testHistogramSize() {
add_task(async function testWithRealDAPSender() {
// Omit mocking DAP telemetry sender in this test to defend against mock
// sender getting out of sync
+ Services.prefs.setStringPref("dap.ohttp.hpke", "");
+ Services.prefs.setStringPref("dap.ohttp.relayURL", "");
const mockServer = new MockServer();
mockServer.start();
@@ -609,4 +616,7 @@ add_task(async function testWithRealDAPSender() {
const receivedReport = mockServer.receivedReports.pop();
Assert.deepEqual(receivedReport, expectedReport);
+
+ Services.prefs.clearUserPref("dap.ohttp.hpke");
+ Services.prefs.clearUserPref("dap.ohttp.relayURL");
});