Bug 1875203 - Move urlbar focus test case out of multistage_experimentAPI into its own browser test file r=omc-reviewers,pdahiya

Moving urlbar focus test case into it's own browser test file to narrow down cause of intermittent with multistage_experimentAPI.

Differential Revision: https://phabricator.services.mozilla.com/D203955
This commit is contained in:
negin 2024-03-08 17:13:33 +00:00
parent 7cdd2817cd
commit 9c9ae5b4a1
3 changed files with 62 additions and 49 deletions

View file

@ -55,3 +55,5 @@ skip-if = [
"win11_2009 && debug",
"os == 'linux' && debug", # Bug 1804804 - disabled on win && linux for extremely high failure rate
]
["browser_aboutwelcome_multistage_urlbar_focus.js"]

View file

@ -590,52 +590,3 @@ add_task(async function test_multistage_aboutwelcome_utm_term() {
await doExperimentCleanup();
});
add_task(async function test_multistage_aboutwelcome_newtab_urlbar_focus() {
const sandbox = sinon.createSandbox();
const TEST_CONTENT = [
{
id: "TEST_SCREEN",
content: {
position: "split",
logo: {},
title: "Test newtab url focus",
primary_button: {
label: "Next",
action: {
navigate: true,
},
},
},
},
];
await setAboutWelcomePref(true);
await ExperimentAPI.ready();
await pushPrefs(["browser.aboutwelcome.newtabUrlBarFocus", true]);
const doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({
featureId: "aboutwelcome",
value: {
id: "my-mochitest-experiment",
screens: TEST_CONTENT,
},
});
const tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:welcome",
true
);
const browser = tab.linkedBrowser;
let focused = BrowserTestUtils.waitForEvent(gURLBar.inputField, "focus");
await onButtonClick(browser, "button.primary");
await focused;
Assert.ok(gURLBar.focused, "focus should be on url bar");
registerCleanupFunction(() => {
BrowserTestUtils.removeTab(tab);
sandbox.restore();
});
await doExperimentCleanup();
});

View file

@ -0,0 +1,60 @@
"use strict";
const { ExperimentAPI } = ChromeUtils.importESModule(
"resource://nimbus/ExperimentAPI.sys.mjs"
);
const { ExperimentFakes } = ChromeUtils.importESModule(
"resource://testing-common/NimbusTestUtils.sys.mjs"
);
const { TelemetryTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TelemetryTestUtils.sys.mjs"
);
add_task(async function test_multistage_aboutwelcome_newtab_urlbar_focus() {
const sandbox = sinon.createSandbox();
const TEST_CONTENT = [
{
id: "TEST_SCREEN",
content: {
position: "split",
logo: {},
title: "Test newtab url focus",
primary_button: {
label: "Next",
action: {
navigate: true,
},
},
},
},
];
await setAboutWelcomePref(true);
await ExperimentAPI.ready();
await pushPrefs(["browser.aboutwelcome.newtabUrlBarFocus", true]);
const doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({
featureId: "aboutwelcome",
value: {
id: "my-mochitest-experiment",
screens: TEST_CONTENT,
},
});
const tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:welcome",
true
);
const browser = tab.linkedBrowser;
let focused = BrowserTestUtils.waitForEvent(gURLBar.inputField, "focus");
await onButtonClick(browser, "button.primary");
await focused;
Assert.ok(gURLBar.focused, "focus should be on url bar");
registerCleanupFunction(() => {
BrowserTestUtils.removeTab(tab);
sandbox.restore();
});
await doExperimentCleanup();
});