Skip to content

Commit 7faaf77

Browse files
committed
Bug 1863400 - Part 1: Move about:welcome mochitest-browser tests to browser/components/aboutwelcome folder. r=pdahiya,Gijs
This clones many of the ESLint rules from browser/components/newtab over as well. Differential Revision: https://phabricator.services.mozilla.com/D193116
1 parent f2026c1 commit 7faaf77

22 files changed

+228
-182
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2+
# vim: set filetype=python:
3+
# This Source Code Form is subject to the terms of the Mozilla Public
4+
# License, v. 2.0. If a copy of the MPL was not distributed with this
5+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
7+
with Files("**"):
8+
BUG_COMPONENT = ("Firefox", "Messaging System")
9+
10+
BROWSER_CHROME_MANIFESTS += [
11+
"tests/browser/browser.toml",
12+
]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[DEFAULT]
2+
support-files = [
3+
"head.js",
4+
]
5+
6+
prefs = [
7+
"intl.multilingual.aboutWelcome.languageMismatchEnabled=false",
8+
"browser.attribution.macos.enabled=true",
9+
]
10+
11+
["browser_aboutwelcome_attribution.js"]
12+
skip-if = [
13+
"os == 'linux'", # Test setup only implemented for OSX and Windows
14+
"os == 'win' && msix", # These tests rely on the ability to write postSigningData, which we can't do in MSIX builds. https://bugzilla.mozilla.org/show_bug.cgi?id=1805911
15+
]
16+
17+
["browser_aboutwelcome_configurable_ui.js"]
18+
skip-if = ["os == 'linux' && bits == 64 && debug"] # Bug 1784548
19+
20+
["browser_aboutwelcome_fxa_signin_flow.js"]
21+
22+
["browser_aboutwelcome_glean.js"]
23+
24+
["browser_aboutwelcome_import.js"]
25+
fail-if = ["a11y_checks"] # Bug 1854514 clicked primary button may not be focusable
26+
27+
["browser_aboutwelcome_mobile_downloads.js"]
28+
29+
["browser_aboutwelcome_multistage_addonspicker.js"]
30+
31+
["browser_aboutwelcome_multistage_default.js"]
32+
33+
["browser_aboutwelcome_multistage_experimentAPI.js"]
34+
35+
["browser_aboutwelcome_multistage_languageSwitcher.js"]
36+
skip-if = ["os == 'linux' && bits == 64"] # Bug 1757875
37+
38+
["browser_aboutwelcome_multistage_mr.js"]
39+
skip-if = ["os == 'linux' && bits == 64 && debug"] # Bug 1812050
40+
41+
["browser_aboutwelcome_multistage_video.js"]
42+
43+
["browser_aboutwelcome_observer.js"]
44+
https_first_disabled = true
45+
46+
["browser_aboutwelcome_rtamo.js"]
47+
skip-if = [
48+
"os == 'linux'", # Test setup only implemented for OSX and Windows
49+
"os == 'win' && msix", # These tests rely on the ability to write postSigningData, which we can't do in MSIX builds. https://bugzilla.mozilla.org/show_bug.cgi?id=1805911
50+
]
51+
52+
["browser_aboutwelcome_screen_targeting.js"]
53+
54+
["browser_aboutwelcome_upgrade_multistage_mr.js"]
55+
skip-if = [
56+
"win11_2009 && debug",
57+
"os == 'linux' && debug", # Bug 1804804 - disabled on win && linux for extremely high failure rate
58+
]

browser/components/newtab/test/browser/browser_aboutwelcome_multistage_default.js renamed to browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_multistage_default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ add_task(async function test_AWMultistage_can_restore_theme() {
541541
this.id = id;
542542
this.isActive = isActive;
543543
}
544+
544545
enable() {
545546
for (let addon of fakeAddons) {
546547
addon.isActive = false;

browser/components/newtab/test/browser/browser_aboutwelcome_multistage_languageSwitcher.js renamed to browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_multistage_languageSwitcher.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ add_task(function initSandbox() {
2121
*
2222
* The returned function flushes the spy of all of the matching button click events, and
2323
* returns the events.
24-
* @returns {() => TelemetryEvents[]}
24+
*
25+
* @returns {function(): TelemetryEvents[]}
2526
*/
2627
async function spyOnTelemetryButtonClicks(browser) {
2728
let aboutWelcomeActor = await getAboutWelcomeParent(browser);

browser/components/newtab/test/browser/browser_aboutwelcome_upgrade_multistage_mr.js renamed to browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_upgrade_multistage_mr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ add_setup(async () => {
5555
* @param {Array} screensToTest
5656
* A list of which screen ids to be displayed
5757
*
58-
* @returns Promise<Window>
58+
* @returns {Promise<Window>}
5959
* Resolves to the window global object for the dialog once it has been
6060
* opened
6161
*/
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/* Any copyright is dedicated to the Public Domain.
2+
http://creativecommons.org/publicdomain/zero/1.0/ */
3+
4+
"use strict";
5+
6+
ChromeUtils.defineESModuleGetters(this, {
7+
FxAccounts: "resource://gre/modules/FxAccounts.sys.mjs",
8+
sinon: "resource://testing-common/Sinon.sys.mjs",
9+
});
10+
11+
XPCOMUtils.defineLazyModuleGetters(this, {
12+
QueryCache: "resource://activity-stream/lib/ASRouterTargeting.jsm",
13+
});
14+
15+
// Set the content pref to make it available across tests
16+
const ABOUT_WELCOME_OVERRIDE_CONTENT_PREF = "browser.aboutwelcome.screens";
17+
18+
function popPrefs() {
19+
return SpecialPowers.popPrefEnv();
20+
}
21+
function pushPrefs(...prefs) {
22+
return SpecialPowers.pushPrefEnv({ set: prefs });
23+
}
24+
25+
async function getAboutWelcomeParent(browser) {
26+
let windowGlobalParent = browser.browsingContext.currentWindowGlobal;
27+
return windowGlobalParent.getActor("AboutWelcome");
28+
}
29+
30+
async function setAboutWelcomeMultiStage(value = "") {
31+
return pushPrefs([ABOUT_WELCOME_OVERRIDE_CONTENT_PREF, value]);
32+
}
33+
34+
async function setAboutWelcomePref(value) {
35+
return pushPrefs(["browser.aboutwelcome.enabled", value]);
36+
}
37+
38+
async function openMRAboutWelcome() {
39+
await setAboutWelcomePref(true); // NB: Calls pushPrefs
40+
let tab = await BrowserTestUtils.openNewForegroundTab(
41+
gBrowser,
42+
"about:welcome",
43+
true
44+
);
45+
46+
return {
47+
browser: tab.linkedBrowser,
48+
cleanup: async () => {
49+
BrowserTestUtils.removeTab(tab);
50+
await popPrefs(); // for setAboutWelcomePref()
51+
},
52+
};
53+
}
54+
55+
async function onButtonClick(browser, elementId) {
56+
await ContentTask.spawn(
57+
browser,
58+
{ elementId },
59+
async ({ elementId: buttonId }) => {
60+
let button = await ContentTaskUtils.waitForCondition(
61+
() => content.document.querySelector(buttonId),
62+
buttonId
63+
);
64+
button.click();
65+
}
66+
);
67+
}
68+
69+
async function clearHistoryAndBookmarks() {
70+
await PlacesUtils.bookmarks.eraseEverything();
71+
await PlacesUtils.history.clear();
72+
QueryCache.expireAll();
73+
}
74+
75+
/**
76+
* Setup functions to test welcome UI
77+
*/
78+
async function test_screen_content(
79+
browser,
80+
experiment,
81+
expectedSelectors = [],
82+
unexpectedSelectors = []
83+
) {
84+
await ContentTask.spawn(
85+
browser,
86+
{ expectedSelectors, experiment, unexpectedSelectors },
87+
async ({
88+
expectedSelectors: expected,
89+
experiment: experimentName,
90+
unexpectedSelectors: unexpected,
91+
}) => {
92+
for (let selector of expected) {
93+
await ContentTaskUtils.waitForCondition(
94+
() => content.document.querySelector(selector),
95+
`Should render ${selector} in ${experimentName}`
96+
);
97+
}
98+
for (let selector of unexpected) {
99+
ok(
100+
!content.document.querySelector(selector),
101+
`Should not render ${selector} in ${experimentName}`
102+
);
103+
}
104+
105+
if (experimentName === "home") {
106+
Assert.equal(
107+
content.document.location.href,
108+
"about:home",
109+
"Navigated to about:home"
110+
);
111+
} else {
112+
Assert.equal(
113+
content.document.location.href,
114+
"about:welcome",
115+
"Navigated to a welcome screen"
116+
);
117+
}
118+
}
119+
);
120+
}
121+
122+
async function test_element_styles(
123+
browser,
124+
elementSelector,
125+
expectedStyles = {},
126+
unexpectedStyles = {}
127+
) {
128+
await ContentTask.spawn(
129+
browser,
130+
[elementSelector, expectedStyles, unexpectedStyles],
131+
async ([selector, expected, unexpected]) => {
132+
const element = await ContentTaskUtils.waitForCondition(() =>
133+
content.document.querySelector(selector)
134+
);
135+
const computedStyles = content.window.getComputedStyle(element);
136+
Object.entries(expected).forEach(([attr, val]) =>
137+
is(
138+
computedStyles[attr],
139+
val,
140+
`${selector} should have computed ${attr} of ${val}`
141+
)
142+
);
143+
Object.entries(unexpected).forEach(([attr, val]) =>
144+
isnot(
145+
computedStyles[attr],
146+
val,
147+
`${selector} should not have computed ${attr} of ${val}`
148+
)
149+
);
150+
}
151+
);
152+
}

browser/components/moz.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ with Files("controlcenter/**"):
2929
DIRS += [
3030
"about",
3131
"aboutlogins",
32+
"aboutwelcome",
3233
"attribution",
3334
"contentanalysis",
3435
"contextualidentity",

browser/components/newtab/test/browser/browser.toml

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -21,63 +21,6 @@ prefs = [
2121
"browser.newtabpage.activity-stream.feeds.section.topstories=true",
2222
"browser.newtabpage.activity-stream.feeds.section.topstories.options={\"provider_name\":\"\"}",
2323
"messaging-system.log=all",
24-
"intl.multilingual.aboutWelcome.languageMismatchEnabled=false",
25-
"browser.attribution.macos.enabled=true",
26-
]
27-
28-
["browser_aboutwelcome_attribution.js"]
29-
skip-if = [
30-
"os == 'linux'", # Test setup only implemented for OSX and Windows
31-
"os == 'win' && msix", # These tests rely on the ability to write postSigningData, which we can't do in MSIX builds. https://bugzilla.mozilla.org/show_bug.cgi?id=1805911
32-
]
33-
34-
["browser_aboutwelcome_configurable_ui.js"]
35-
skip-if = ["os == 'linux' && bits == 64 && debug"] # Bug 1784548
36-
37-
["browser_aboutwelcome_fxa_signin_flow.js"]
38-
39-
["browser_aboutwelcome_glean.js"]
40-
41-
["browser_aboutwelcome_import.js"]
42-
fail-if = ["a11y_checks"] # Bug 1854514 clicked primary button may not be focusable
43-
44-
["browser_aboutwelcome_mobile_downloads.js"]
45-
46-
["browser_aboutwelcome_multistage_addonspicker.js"]
47-
48-
["browser_aboutwelcome_multistage_default.js"]
49-
50-
["browser_aboutwelcome_multistage_experimentAPI.js"]
51-
52-
["browser_aboutwelcome_multistage_languageSwitcher.js"]
53-
skip-if = [
54-
"os == 'linux' && bits == 64", # Bug 1757875
55-
"verify",
56-
]
57-
58-
["browser_aboutwelcome_multistage_mr.js"]
59-
skip-if = [
60-
"os == 'linux' && bits == 64 && debug", # Bug 1812050
61-
"os == 'linux' && tsan && verify",
62-
]
63-
64-
["browser_aboutwelcome_multistage_video.js"]
65-
66-
["browser_aboutwelcome_observer.js"]
67-
https_first_disabled = true
68-
69-
["browser_aboutwelcome_rtamo.js"]
70-
skip-if = [
71-
"os == 'linux'", # Test setup only implemented for OSX and Windows
72-
"os == 'win' && msix", # These tests rely on the ability to write postSigningData, which we can't do in MSIX builds. https://bugzilla.mozilla.org/show_bug.cgi?id=1805911
73-
]
74-
75-
["browser_aboutwelcome_screen_targeting.js"]
76-
77-
["browser_aboutwelcome_upgrade_multistage_mr.js"]
78-
skip-if = [
79-
"win11_2009 && debug",
80-
"os == 'linux' && debug", # Bug 1804804 - disabled on win && linux for extremely high failure rate
8124
]
8225

8326
["browser_as_load_location.js"]

0 commit comments

Comments
 (0)