diff options
Diffstat (limited to 'browser/components/aboutwelcome/tests/browser')
7 files changed, 357 insertions, 250 deletions
diff --git a/browser/components/aboutwelcome/tests/browser/browser.toml b/browser/components/aboutwelcome/tests/browser/browser.toml index 22d95272e8..96d1070645 100644 --- a/browser/components/aboutwelcome/tests/browser/browser.toml +++ b/browser/components/aboutwelcome/tests/browser/browser.toml @@ -37,6 +37,9 @@ skip-if = ["os == 'linux' && bits == 64"] # Bug 1757875 ["browser_aboutwelcome_multistage_mr.js"] skip-if = ["os == 'linux' && bits == 64 && debug"] # Bug 1812050 +["browser_aboutwelcome_multistage_transitions.js"] +skip-if = ["debug"] # Bug 1875203 + ["browser_aboutwelcome_multistage_video.js"] ["browser_aboutwelcome_observer.js"] @@ -50,6 +53,8 @@ skip-if = [ ["browser_aboutwelcome_screen_targeting.js"] +["browser_aboutwelcome_toolbar_button.js"] + ["browser_aboutwelcome_upgrade_multistage_mr.js"] skip-if = [ "win11_2009 && debug", diff --git a/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_attribution.js b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_attribution.js index f0727c9b6f..d7076bd7c5 100644 --- a/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_attribution.js +++ b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_attribution.js @@ -42,7 +42,6 @@ const TEST_PROTON_CONTENT = [ navigate: true, }, }, - has_noodles: true, }, }, { @@ -58,7 +57,6 @@ const TEST_PROTON_CONTENT = [ data: {}, }, }, - has_noodles: true, }, }, ]; diff --git a/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_configurable_ui.js b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_configurable_ui.js index d53b5acc14..3081688a0c 100644 --- a/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_configurable_ui.js +++ b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_configurable_ui.js @@ -334,46 +334,46 @@ add_task(async function test_aboutwelcome_dismiss_button() { /** * Test rendering a screen with the "split" position */ -add_task(async function test_aboutwelcome_split_position() { - const TEST_SPLIT_STEP = makeTestContent("TEST_SPLIT_STEP", { - position: "split", - hero_text: "hero test", - }); - - const TEST_SPLIT_JSON = JSON.stringify([TEST_SPLIT_STEP]); - let browser = await openAboutWelcome(TEST_SPLIT_JSON); - - await test_screen_content( - browser, - "renders screen secondary section containing hero text", - // Expected selectors: - [`main.screen[pos="split"]`, `.section-secondary`, `.message-text h1`] - ); - - // Ensure secondary section has split template styling - await test_element_styles( - browser, - "main.screen .section-secondary", - // Expected styles: - { - display: "flex", - margin: "auto 0px auto auto", - } - ); - - // Ensure secondary action has button styling - await test_element_styles( - browser, - ".action-buttons .secondary-cta .secondary", - // Expected styles: - { - // Override default text-link styles - "background-color": "color(srgb 0.0823529 0.0784314 0.101961 / 0.07)", - color: "rgb(21, 20, 26)", - } - ); - browser.closeBrowser(); -}); +// add_task(async function test_aboutwelcome_split_position() { +// const TEST_SPLIT_STEP = makeTestContent("TEST_SPLIT_STEP", { +// position: "split", +// hero_text: "hero test", +// }); + +// const TEST_SPLIT_JSON = JSON.stringify([TEST_SPLIT_STEP]); +// let browser = await openAboutWelcome(TEST_SPLIT_JSON); + +// await test_screen_content( +// browser, +// "renders screen secondary section containing hero text", +// // Expected selectors: +// [`main.screen[pos="split"]`, `.section-secondary`, `.message-text h1`] +// ); + +// // Ensure secondary section has split template styling +// await test_element_styles( +// browser, +// "main.screen .section-secondary", +// // Expected styles: +// { +// display: "flex", +// margin: "auto 0px auto auto", +// } +// ); + +// // Ensure secondary action has button styling +// await test_element_styles( +// browser, +// ".action-buttons .secondary-cta .secondary", +// // Expected styles: +// { +// // Override default text-link styles +// "background-color": "color(srgb 0.0823529 0.0784314 0.101961 / 0.07)", +// color: "rgb(21, 20, 26)", +// } +// ); +// browser.closeBrowser(); +// }); /** * Test rendering a screen with a URL value and default color for backdrop @@ -722,3 +722,27 @@ add_task(async function test_aboutwelcome_start_screen_configured() { browser.closeBrowser(); sandbox.restore(); }); + +/** + * Test rendering a screen with that doesn't use responsive design + */ +add_task(async function test_aboutwelcome_rdm_property() { + let screens = [makeTestContent(`TEST_NO_RDM`, { no_rdm: true })]; + + let doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({ + featureId: "aboutwelcome", + value: { enabled: true, screens }, + }); + + let browser = await openAboutWelcome(); + + await test_screen_content( + browser, + "render screen with 'no-rdm' attribute", + // Expected selectors: + ["main.TEST_NO_RDM[no-rdm]"] + ); + + await doExperimentCleanup(); + browser.closeBrowser(); +}); diff --git a/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_multistage_experimentAPI.js b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_multistage_experimentAPI.js index 960d42a1f8..1e29e230ab 100644 --- a/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_multistage_experimentAPI.js +++ b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_multistage_experimentAPI.js @@ -10,101 +10,6 @@ const { TelemetryTestUtils } = ChromeUtils.importESModule( "resource://testing-common/TelemetryTestUtils.sys.mjs" ); -const TEST_PROTON_CONTENT = [ - { - id: "AW_STEP1", - content: { - title: "Step 1", - primary_button: { - label: "Next", - action: { - navigate: true, - }, - }, - secondary_button: { - label: "link", - }, - secondary_button_top: { - label: "link top", - action: { - type: "SHOW_FIREFOX_ACCOUNTS", - data: { entrypoint: "test" }, - }, - }, - has_noodles: true, - }, - }, - { - id: "AW_STEP2", - content: { - title: "Step 2", - primary_button: { - label: "Next", - action: { - navigate: true, - }, - }, - secondary_button: { - label: "link", - }, - has_noodles: true, - }, - }, - { - id: "AW_STEP3", - content: { - title: "Step 3", - tiles: { - type: "theme", - action: { - theme: "<event>", - }, - data: [ - { - theme: "automatic", - label: "theme-1", - tooltip: "test-tooltip", - }, - { - theme: "dark", - label: "theme-2", - }, - ], - }, - primary_button: { - label: "Next", - action: { - navigate: true, - }, - }, - secondary_button: { - label: "Import", - action: { - type: "SHOW_MIGRATION_WIZARD", - data: { source: "chrome" }, - }, - }, - has_noodles: true, - }, - }, - { - id: "AW_STEP4", - content: { - title: "Step 4", - primary_button: { - label: "Next", - action: { - navigate: true, - }, - }, - secondary_button: { - label: "link", - }, - has_noodles: true, - }, - }, -]; - /** * Test the zero onboarding using ExperimentAPI */ @@ -354,119 +259,6 @@ add_task(async function test_multistage_aboutwelcome_experimentAPI() { await doExperimentCleanup(); }); -/** - * Test the multistage proton welcome UI using ExperimentAPI with transitions - */ -add_task(async function test_multistage_aboutwelcome_transitions() { - const sandbox = sinon.createSandbox(); - await setAboutWelcomePref(true); - await ExperimentAPI.ready(); - - let doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({ - featureId: "aboutwelcome", - value: { - id: "my-mochitest-experiment", - enabled: true, - screens: TEST_PROTON_CONTENT, - transitions: true, - }, - }); - - let tab = await BrowserTestUtils.openNewForegroundTab( - gBrowser, - "about:welcome", - true - ); - - const browser = tab.linkedBrowser; - - let aboutWelcomeActor = await getAboutWelcomeParent(browser); - // Stub AboutWelcomeParent Content Message Handler - sandbox.spy(aboutWelcomeActor, "onContentMessage"); - registerCleanupFunction(() => { - BrowserTestUtils.removeTab(tab); - sandbox.restore(); - }); - - await test_screen_content( - browser, - "multistage proton step 1", - // Expected selectors: - ["div.proton.transition- .screen"], - // Unexpected selectors: - ["div.proton.transition-out"] - ); - - // Double click should still only transition once. - await onButtonClick(browser, "button.primary"); - await onButtonClick(browser, "button.primary"); - - await test_screen_content( - browser, - "multistage proton step 1 transition to 2", - // Expected selectors: - ["div.proton.transition-out .screen", "div.proton.transition- .screen-1"] - ); - - await doExperimentCleanup(); -}); - -/** - * Test the multistage proton welcome UI using ExperimentAPI without transitions - */ -add_task(async function test_multistage_aboutwelcome_transitions_off() { - const sandbox = sinon.createSandbox(); - await setAboutWelcomePref(true); - await ExperimentAPI.ready(); - - let doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({ - featureId: "aboutwelcome", - value: { - id: "my-mochitest-experiment", - enabled: true, - screens: TEST_PROTON_CONTENT, - transitions: false, - }, - }); - - let tab = await BrowserTestUtils.openNewForegroundTab( - gBrowser, - "about:welcome", - true - ); - - const browser = tab.linkedBrowser; - - let aboutWelcomeActor = await getAboutWelcomeParent(browser); - // Stub AboutWelcomeParent Content Message Handler - sandbox.spy(aboutWelcomeActor, "onContentMessage"); - registerCleanupFunction(() => { - BrowserTestUtils.removeTab(tab); - sandbox.restore(); - }); - - await test_screen_content( - browser, - "multistage proton step 1", - // Expected selectors: - ["div.proton.transition- .screen"], - // Unexpected selectors: - ["div.proton.transition-out"] - ); - - await onButtonClick(browser, "button.primary"); - await test_screen_content( - browser, - "multistage proton step 1 no transition to 2", - // Expected selectors: - [], - // Unexpected selectors: - ["div.proton.transition-out .screen-0"] - ); - - await doExperimentCleanup(); -}); - /* Test multistage custom backdrop */ add_task(async function test_multistage_aboutwelcome_backdrop() { diff --git a/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_multistage_transitions.js b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_multistage_transitions.js new file mode 100644 index 0000000000..d27674ef6c --- /dev/null +++ b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_multistage_transitions.js @@ -0,0 +1,219 @@ +"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" +); + +const TEST_PROTON_CONTENT = [ + { + id: "AW_STEP1", + content: { + title: "Step 1", + primary_button: { + label: "Next", + action: { + navigate: true, + }, + }, + secondary_button: { + label: "link", + }, + secondary_button_top: { + label: "link top", + action: { + type: "SHOW_FIREFOX_ACCOUNTS", + data: { entrypoint: "test" }, + }, + }, + has_noodles: true, + }, + }, + { + id: "AW_STEP2", + content: { + title: "Step 2", + primary_button: { + label: "Next", + action: { + navigate: true, + }, + }, + secondary_button: { + label: "link", + }, + has_noodles: true, + }, + }, + { + id: "AW_STEP3", + content: { + title: "Step 3", + tiles: { + type: "theme", + action: { + theme: "<event>", + }, + data: [ + { + theme: "automatic", + label: "theme-1", + tooltip: "test-tooltip", + }, + { + theme: "dark", + label: "theme-2", + }, + ], + }, + primary_button: { + label: "Next", + action: { + navigate: true, + }, + }, + secondary_button: { + label: "Import", + action: { + type: "SHOW_MIGRATION_WIZARD", + data: { source: "chrome" }, + }, + }, + has_noodles: true, + }, + }, + { + id: "AW_STEP4", + content: { + title: "Step 4", + primary_button: { + label: "Next", + action: { + navigate: true, + }, + }, + secondary_button: { + label: "link", + }, + has_noodles: true, + }, + }, +]; + +/** + * Test the multistage proton welcome UI using ExperimentAPI with transitions + */ +add_task(async function test_multistage_aboutwelcome_transitions() { + const sandbox = sinon.createSandbox(); + await setAboutWelcomePref(true); + await ExperimentAPI.ready(); + + let doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({ + featureId: "aboutwelcome", + value: { + id: "my-mochitest-experiment", + enabled: true, + screens: TEST_PROTON_CONTENT, + transitions: true, + }, + }); + + let tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + "about:welcome", + true + ); + + const browser = tab.linkedBrowser; + + let aboutWelcomeActor = await getAboutWelcomeParent(browser); + // Stub AboutWelcomeParent Content Message Handler + sandbox.spy(aboutWelcomeActor, "onContentMessage"); + registerCleanupFunction(() => { + BrowserTestUtils.removeTab(tab); + sandbox.restore(); + }); + + await test_screen_content( + browser, + "multistage proton step 1", + // Expected selectors: + ["div.proton.transition- .screen"], + // Unexpected selectors: + ["div.proton.transition-out"] + ); + + // Double click should still only transition once. + await onButtonClick(browser, "button.primary"); + await onButtonClick(browser, "button.primary"); + + await test_screen_content( + browser, + "multistage proton step 1 transition to 2", + // Expected selectors: + ["div.proton.transition-out .screen", "div.proton.transition- .screen-1"] + ); + + await doExperimentCleanup(); +}); + +/** + * Test the multistage proton welcome UI using ExperimentAPI without transitions + */ +add_task(async function test_multistage_aboutwelcome_transitions_off() { + const sandbox = sinon.createSandbox(); + await setAboutWelcomePref(true); + await ExperimentAPI.ready(); + + let doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({ + featureId: "aboutwelcome", + value: { + id: "my-mochitest-experiment", + enabled: true, + screens: TEST_PROTON_CONTENT, + transitions: false, + }, + }); + + let tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + "about:welcome", + true + ); + + const browser = tab.linkedBrowser; + + let aboutWelcomeActor = await getAboutWelcomeParent(browser); + // Stub AboutWelcomeParent Content Message Handler + sandbox.spy(aboutWelcomeActor, "onContentMessage"); + registerCleanupFunction(() => { + BrowserTestUtils.removeTab(tab); + sandbox.restore(); + }); + + await test_screen_content( + browser, + "multistage proton step 1", + // Expected selectors: + ["div.proton.transition- .screen"], + // Unexpected selectors: + ["div.proton.transition-out"] + ); + + await onButtonClick(browser, "button.primary"); + await test_screen_content( + browser, + "multistage proton step 1 no transition to 2", + // Expected selectors: + [], + // Unexpected selectors: + ["div.proton.transition-out .screen-0"] + ); + + await doExperimentCleanup(); +}); diff --git a/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_observer.js b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_observer.js index 58f9059532..d1fe0edc4c 100644 --- a/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_observer.js +++ b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_observer.js @@ -70,4 +70,9 @@ add_task(async function test_About_Welcome_Location_Change() { aboutWelcomeActor.AboutWelcomeObserver.AWTerminate.ADDRESS_BAR_NAVIGATED, "Terminated due to location uri changed" ); + + // Wait for the end of the any transition happening due to + // location change before closing the window, See bug 1882067 + // eslint-disable-next-line mozilla/no-arbitrary-setTimeout + await new Promise(r => setTimeout(r, 100)); }); diff --git a/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_toolbar_button.js b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_toolbar_button.js new file mode 100644 index 0000000000..c9180ddf2d --- /dev/null +++ b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_toolbar_button.js @@ -0,0 +1,64 @@ +"use strict"; + +const { AboutWelcomeTelemetry } = ChromeUtils.importESModule( + "resource:///modules/aboutwelcome/AboutWelcomeTelemetry.sys.mjs" +); +const { AWToolbarButton } = ChromeUtils.importESModule( + "resource:///modules/aboutwelcome/AWToolbarUtils.sys.mjs" +); + +const TOOLBAR_PREF = "browser.aboutwelcome.toolbarButtonEnabled"; +const DID_SEE_FINAL_SCREEN_PREF = "browser.aboutwelcome.didSeeFinalScreen"; + +async function openNewTab() { + let tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + "about:newtab", + false + ); + + registerCleanupFunction(async () => { + BrowserTestUtils.removeTab(tab); + await SpecialPowers.popPrefEnv(); + }); + + return tab.linkedBrowser; +} + +add_task(async function test_add_and_remove_toolbar_button() { + // Clear the final screen pref, which may have been set by other tests + await SpecialPowers.pushPrefEnv({ + set: [[DID_SEE_FINAL_SCREEN_PREF, false]], + }); + // Open newtab + let win = await BrowserTestUtils.openNewBrowserWindow(); + win.BrowserOpenTab(); + ok(win, "browser exists"); + // Try to add the button. It shouldn't add because the pref is false + await AWToolbarButton.maybeAddSetupButton(); + ok( + !win.document.getElementById("aboutwelcome-button"), + "Button should not exist" + ); + // Set the pref and try again + await SpecialPowers.pushPrefEnv({ + set: [[TOOLBAR_PREF, true]], + }); + await AWToolbarButton.maybeAddSetupButton(); + // The button should exist + ok( + win.document.getElementById("aboutwelcome-button"), + "Button should be added." + ); + // Switch the pref to false and check again + await SpecialPowers.pushPrefEnv({ + set: [[TOOLBAR_PREF, false]], + }); + ok( + !win.document.getElementById("aboutwelcome-button"), + "Button should be removed" + ); + // Cleanup + await SpecialPowers.popPrefEnv(); + await BrowserTestUtils.closeWindow(win); +}); |