Bug 1814405 - The Download Mobile URL does not contain the experiment UTM parameters when it is accessed from window modal r=pdahiya

Differential Revision: https://phabricator.services.mozilla.com/D168740
This commit is contained in:
negin
2023-02-03 02:15:58 +00:00
parent d1603492ef
commit 48c1fd82ea
2 changed files with 74 additions and 0 deletions

View File

@@ -4396,6 +4396,7 @@ BrowserGlue.prototype = {
id: data?.id || "ABOUT_WELCOME_MODAL",
backdrop: data?.backdrop,
screens: data?.screens,
UTMTerm: data?.UTMTerm,
},
},
};

View File

@@ -522,3 +522,76 @@ add_task(async function test_multistage_aboutwelcome_backdrop() {
await doExperimentCleanup();
});
add_task(async function test_multistage_aboutwelcome_utm_term() {
const sandbox = sinon.createSandbox();
const TEST_CONTENT = [
{
id: "TEST_SCREEN",
content: {
position: "split",
logo: {},
title: "test",
secondary_button_top: {
label: "test",
style: "link",
action: {
type: "OPEN_URL",
data: {
args: "https://www.mozilla.org/",
},
},
},
},
},
];
await setAboutWelcomePref(true);
await ExperimentAPI.ready();
const doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({
featureId: "aboutwelcome",
value: {
id: "my-mochitest-experiment",
screens: TEST_CONTENT,
UTMTerm: "test",
},
});
const tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:welcome",
true
);
const browser = tab.linkedBrowser;
const aboutWelcomeActor = await getAboutWelcomeParent(browser);
sandbox.stub(aboutWelcomeActor, "onContentMessage");
await onButtonClick(browser, "button[value='secondary_button_top']");
let actionCall;
const { callCount } = aboutWelcomeActor.onContentMessage;
for (let i = 0; i < callCount; i++) {
const call = aboutWelcomeActor.onContentMessage.getCall(i);
info(`Call #${i}: ${call.args[0]} ${JSON.stringify(call.args[1])}`);
if (call.calledWithMatch("SPECIAL")) {
actionCall = call;
}
}
Assert.equal(
actionCall.args[1].data.args,
"https://www.mozilla.org/?utm_source=activity-stream&utm_campaign=firstrun&utm_medium=referral&utm_term=aboutwelcome-test-screen",
"UTMTerm set in mobile"
);
registerCleanupFunction(() => {
sandbox.restore();
BrowserTestUtils.removeTab(tab);
});
await doExperimentCleanup();
});