commit d95ba3913f326e4074ef204b5ed4a29d0e24d318
parent 863814c850a906275fb605c01e096e74ed0653e7
Author: Mike Conley <mconley@mozilla.com>
Date: Fri, 14 Nov 2025 15:01:18 +0000
Bug 2000073 - Shim the browser_attribution_actor test for newtab train-hop compatibility. r=home-newtab-reviewers,nbarrett
Differential Revision: https://phabricator.services.mozilla.com/D272639
Diffstat:
1 file changed, 119 insertions(+), 4 deletions(-)
diff --git a/browser/extensions/newtab/test/browser/browser_attribution_actor.js b/browser/extensions/newtab/test/browser/browser_attribution_actor.js
@@ -2,6 +2,15 @@
"use strict";
+/**
+ * @backward-compat { version 146 }
+ *
+ * Bug 2000073 - Fix perma mochitest-browser failure on release 145, where
+ * DAPSender does not exist.
+ */
+const is146AndUp =
+ Services.vc.compare(AppConstants.MOZ_APP_VERSION, "146.0a1") >= 0;
+
ChromeUtils.defineESModuleGetters(this, {
sinon: "resource://testing-common/Sinon.sys.mjs",
NewTabActorRegistry: "resource://newtab/lib/NewTabActorRegistry.sys.mjs",
@@ -15,10 +24,6 @@ const { AttributionParent } = ChromeUtils.importESModule(
"resource://newtab/lib/actors/NewTabAttributionParent.sys.mjs"
);
-const { DAPSender } = ChromeUtils.importESModule(
- "resource://gre/modules/DAPSender.sys.mjs"
-);
-
const { RemoteSettings } = ChromeUtils.importESModule(
"resource://services-settings/remote-settings.sys.mjs"
);
@@ -69,6 +74,17 @@ async function dispatchAttributionEvent(browser, detail) {
}
add_setup(async function () {
+ /**
+ * @backward-compat { version 146 }
+ *
+ * Bug 2000073 - Fix perma mochitest-browser failure on release 145, where
+ * DAPSender does not exist.
+ */
+ if (!is146AndUp) {
+ Assert.ok(true, "Skipping test for train-hop compatibility.");
+ return;
+ }
+
// enable gating so registry will register the actor
await SpecialPowers.pushPrefEnv({
set: [
@@ -86,6 +102,17 @@ add_setup(async function () {
});
sandbox = sinon.createSandbox();
+
+ /**
+ * @backward-compat { version 146 }
+ *
+ * Bug 2000073 - Move this back up to the list of imports once 146 hits
+ * release.
+ */
+ const { DAPSender } = ChromeUtils.importESModule(
+ "resource://gre/modules/DAPSender.sys.mjs"
+ );
+
dapStub = sandbox.stub(DAPSender, "sendDAPMeasurement");
conversionStub = sandbox.stub(
NewTabAttributionServiceClass.prototype,
@@ -126,6 +153,17 @@ async function resetTestState() {
* from an allowlisted origin.
*/
add_task(async function test_parent_calls_onAttributionConversion() {
+ /**
+ * @backward-compat { version 146 }
+ *
+ * Bug 2000073 - Fix perma mochitest-browser failure on release 145, where
+ * DAPSender does not exist.
+ */
+ if (!is146AndUp) {
+ Assert.ok(true, "Skipping test for train-hop compatibility.");
+ return;
+ }
+
await resetTestState();
dapStub.resetHistory();
@@ -172,6 +210,17 @@ add_task(async function test_parent_calls_onAttributionConversion() {
* is not in allowlist.
*/
add_task(async function test_parent_blocks_non_allowlisted_origin() {
+ /**
+ * @backward-compat { version 146 }
+ *
+ * Bug 2000073 - Fix perma mochitest-browser failure on release 145, where
+ * DAPSender does not exist.
+ */
+ if (!is146AndUp) {
+ Assert.ok(true, "Skipping test for train-hop compatibility.");
+ return;
+ }
+
await resetTestState();
const partnerId = "expedia";
@@ -193,6 +242,17 @@ add_task(async function test_parent_blocks_non_allowlisted_origin() {
* conversion data (extra keys).
*/
add_task(async function test_parent_blocks_invalid_conversion_extra_keys() {
+ /**
+ * @backward-compat { version 146 }
+ *
+ * Bug 2000073 - Fix perma mochitest-browser failure on release 145, where
+ * DAPSender does not exist.
+ */
+ if (!is146AndUp) {
+ Assert.ok(true, "Skipping test for train-hop compatibility.");
+ return;
+ }
+
await resetTestState();
await BrowserTestUtils.withNewTab(TEST_URL, async browser => {
@@ -216,6 +276,17 @@ add_task(async function test_parent_blocks_invalid_conversion_extra_keys() {
* is not an object.
*/
add_task(async function test_parent_blocks_non_object_conversion() {
+ /**
+ * @backward-compat { version 146 }
+ *
+ * Bug 2000073 - Fix perma mochitest-browser failure on release 145, where
+ * DAPSender does not exist.
+ */
+ if (!is146AndUp) {
+ Assert.ok(true, "Skipping test for train-hop compatibility.");
+ return;
+ }
+
await resetTestState();
await BrowserTestUtils.withNewTab(TEST_URL, async browser => {
@@ -240,6 +311,17 @@ add_task(async function test_parent_blocks_non_object_conversion() {
* message.data.detail is missing.
*/
add_task(async function test_parent_blocks_missing_detail() {
+ /**
+ * @backward-compat { version 146 }
+ *
+ * Bug 2000073 - Fix perma mochitest-browser failure on release 145, where
+ * DAPSender does not exist.
+ */
+ if (!is146AndUp) {
+ Assert.ok(true, "Skipping test for train-hop compatibility.");
+ return;
+ }
+
await resetTestState();
await BrowserTestUtils.withNewTab(TEST_URL, async browser => {
@@ -263,6 +345,17 @@ add_task(async function test_parent_blocks_missing_detail() {
* Test that Remote Settings client uses get() and registers onSync handler.
*/
add_task(async function test_remote_settings_sync_and_handler() {
+ /**
+ * @backward-compat { version 146 }
+ *
+ * Bug 2000073 - Fix perma mochitest-browser failure on release 145, where
+ * DAPSender does not exist.
+ */
+ if (!is146AndUp) {
+ Assert.ok(true, "Skipping test for train-hop compatibility.");
+ return;
+ }
+
await resetTestState();
const mockClient = {
@@ -297,6 +390,17 @@ add_task(async function test_remote_settings_sync_and_handler() {
* Test that onSync updates the allowlist when Remote Settings syncs.
*/
add_task(async function test_onSync_updates_allowlist() {
+ /**
+ * @backward-compat { version 146 }
+ *
+ * Bug 2000073 - Fix perma mochitest-browser failure on release 145, where
+ * DAPSender does not exist.
+ */
+ if (!is146AndUp) {
+ Assert.ok(true, "Skipping test for train-hop compatibility.");
+ return;
+ }
+
await resetTestState();
await BrowserTestUtils.withNewTab(TEST_URL, async browser => {
@@ -332,6 +436,17 @@ add_task(async function test_onSync_updates_allowlist() {
* Test that didDestroy removes the onSync event listener.
*/
add_task(async function test_didDestroy_removes_listener() {
+ /**
+ * @backward-compat { version 146 }
+ *
+ * Bug 2000073 - Fix perma mochitest-browser failure on release 145, where
+ * DAPSender does not exist.
+ */
+ if (!is146AndUp) {
+ Assert.ok(true, "Skipping test for train-hop compatibility.");
+ return;
+ }
+
await resetTestState();
const mockClient = {