Skip to content

Commit 0fe729e

Browse files
committed
added sponsored item checking
1 parent b64a0ea commit 0fe729e

File tree

3 files changed

+210
-7
lines changed

3 files changed

+210
-7
lines changed
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
{
2+
"context": "chrome",
3+
"awesome-bar": {
4+
"selectorData": "urlbar-input",
5+
"strategy": "id",
6+
"groups": [
7+
"requiredForPage",
8+
"awesomeBar"
9+
]
10+
},
11+
12+
"results-dropdown": {
13+
"selectorData": "urlbar-results",
14+
"strategy": "id",
15+
"groups": [
16+
"doNotCache"
17+
]
18+
},
19+
20+
"tab-to-search-text-span": {
21+
"selectorData": "urlbarView-dynamic-onboardTabToSearch-text-container",
22+
"strategy": "class",
23+
"groups": []
24+
},
25+
26+
"search-mode-span": {
27+
"selectorData": "urlbar-search-mode-indicator-title",
28+
"strategy": "id",
29+
"groups": []
30+
},
31+
32+
"overflow-item": {
33+
"selectorData": "[class=\"urlbarView-title urlbarView-overflowable\"]",
34+
"strategy": "css",
35+
"groups": []
36+
},
37+
38+
"search-one-off-settings-button": {
39+
"selectorData": "urlbar-anon-search-settings",
40+
"strategy": "id",
41+
"groups": [
42+
"searchOneOffs"
43+
]
44+
},
45+
46+
"quick-actions-refresh-button": {
47+
"selectorData": "urlbarView-row-3-label-0",
48+
"strategy": "id",
49+
"groups": []
50+
},
51+
52+
"refresh-intervention-card": {
53+
"selectorData": "div[tip-type=\"intervention_refresh\"]",
54+
"strategy": "css",
55+
"groups": [
56+
"doNotCache"
57+
]
58+
},
59+
60+
"fx-refresh-text": {
61+
"selectorData": "span[data-l10n-id=\"intervention-refresh-profile\"]",
62+
"strategy": "css",
63+
"groups": []
64+
},
65+
66+
"fx-refresh-button": {
67+
"selectorData": "span[role=\"button\"][data-l10n-id=\"intervention-refresh-profile-confirm\"]",
68+
"strategy": "css",
69+
"groups": []
70+
},
71+
72+
"fx-refresh-menu": {
73+
"selectorData": "span[data-l10n-id=\"urlbar-result-menu-button\"][title=\"Open menu\"]",
74+
"strategy": "css",
75+
"groups": []
76+
},
77+
78+
"fx-refresh-menu-get-help-item": {
79+
"selectorData": "menuitem[data-l10n-id=\"urlbar-result-menu-tip-get-help\"]",
80+
"strategy": "css",
81+
"groups": []
82+
},
83+
84+
"fx-refresh-menu-get-help-item-get-help": {
85+
"selectorData": "urlbarView-result-menuitem",
86+
"strategy": "class",
87+
"groups": []
88+
},
89+
90+
"search-engine-suggestion-row": {
91+
"selectorData": "div[class=\"urlbarView-row\"][type=\"search_engine\"]",
92+
"strategy": "css",
93+
"groups": []
94+
},
95+
96+
"search-one-off-browser-button": {
97+
"selectorData": "urlbar-engine-one-off-item-{source}",
98+
"strategy": "id",
99+
"groups": []
100+
},
101+
102+
"panel-ui-button": {
103+
"selectorData": "PanelUI-button",
104+
"strategy": "id",
105+
"groups": []
106+
},
107+
108+
"navigation-background-component": {
109+
"selectorData": "nav-bar",
110+
"strategy": "id",
111+
"groups": []
112+
},
113+
114+
"context-menu-paste-and-go": {
115+
"selectorData": "paste-and-go",
116+
"strategy": "id",
117+
"groups": []
118+
},
119+
120+
"private-browsing-icon": {
121+
"selectorData": "private-browsing-indicator-icon",
122+
"strategy": "class",
123+
"groups": []
124+
},
125+
126+
127+
"add-extra-search-engine": {
128+
"selectorData": "[id*=urlbar-engine-one-off-item-engine--1][tooltiptext*='{0}']",
129+
"strategy": "css",
130+
"groups": []
131+
},
132+
133+
"search-one-off-engine-button": {
134+
"selectorData": "[id*=urlbar-engine-one-off-item-engine][tooltiptext^='{0}']",
135+
"strategy": "css",
136+
"groups": []
137+
},
138+
139+
"downloads-button": {
140+
"selectorData": "downloads-button",
141+
"strategy": "id",
142+
"groups": []
143+
},
144+
145+
"search-results-container": {
146+
"selectorData": "urlbar-results",
147+
"strategy": "id",
148+
"groups": []
149+
},
150+
151+
"addon-suggestion": {
152+
"selectorData": "div.urlbarView-row[type='rust_amo'] span.urlbarView-title.urlbarView-overflowable",
153+
"strategy": "css",
154+
"groups": []
155+
},
156+
157+
"search-suggestion-list": {
158+
"selectorData": "div.urlbarView-row[type='search_engine'] span.urlbarView-title",
159+
"strategy": "css",
160+
"groups": [
161+
"doNotCache"
162+
]
163+
},
164+
165+
"sponsored-site-card": {
166+
"selectorData": "top-site-outer",
167+
"strategy": "class",
168+
"groups": []
169+
},
170+
171+
"sponsored-site-card-menu-button": {
172+
"selectorData": "button[class=\"context-menu-button icon\"]",
173+
"strategy": "css",
174+
"groups": []
175+
},
176+
177+
"sponsored-site-context-menu": {
178+
"selectorData": "context-menu",
179+
"strategy": "class",
180+
"groups": []
181+
},
182+
183+
"sponsored-site-context-menu-list": {
184+
"selectorData": "ul[class=\"context-menu-list\"]",
185+
"strategy": "css",
186+
"groups": []
187+
}
188+
}

tests/address_bar_and_search/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def set_prefs(add_prefs: dict):
2424
("browser.newtabpage.activity-stream.system.showSponsored", True),
2525
("browser.newtabpage.activity-stream.showSponsoredTopSites", True),
2626
("browser.topsites.useRemoteSetting", True),
27+
("browser.topsites.contile.enabled", True)
2728
]
2829
prefs.extend(add_prefs)
2930
return prefs

tests/address_bar_and_search/test_tile_menu_options.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
["Pin", "Edit", "Open in a New Window", "Open in a New Private Window", "Dismiss"]
2929
)
3030

31+
REQUIRED_CONTEXT_MENU_ACTIONS_SPONSORED_TILE = set(
32+
["Open in a New Window", "Open in a New Private Window", "Dismiss", "Our sponsors & your privacy"]
33+
)
34+
35+
# first value in a tuple is the index of the card, second is the status of sponsorship
36+
card_indices = [(3, False), (0, True)]
3137

3238
@pytest.fixture()
3339
def add_prefs():
@@ -74,8 +80,8 @@ def test_default_tile_hover_states(driver: Firefox):
7480
in ALLOWED_RGB_AFTER_VALUES_THREE_DOTS
7581
)
7682

77-
78-
def test_tile_context_menu_options(driver: Firefox):
83+
@pytest.mark.parametrize("index, sponsored", card_indices)
84+
def test_tile_context_menu_options(driver: Firefox, index: int, sponsored: bool):
7985
"""
8086
C1533798.2: Ensure that a website has the appropriate context menu actions in the tile.
8187
"""
@@ -90,8 +96,8 @@ def test_tile_context_menu_options(driver: Firefox):
9096
driver.switch_to.window(driver.window_handles[-1])
9197
suggested_cards = nav.get_element("sponsored-site-card", multiple=True)
9298

93-
# pick the second card since its not pinned
94-
card = suggested_cards[1]
99+
# pick the fourth card since it is not a sponsored tile
100+
card = suggested_cards[index]
95101
nav.hover_over_element(card)
96102

97103
# press the three dots option
@@ -111,16 +117,24 @@ def test_tile_context_menu_options(driver: Firefox):
111117
for option in child_options
112118
if option.get_attribute("innerHTML") != ""
113119
]
120+
114121
matched_regex = util.match_regex(
115122
r"<button[^>]*><span[^>]*>([^<]*)</span></button>", option_html_logs
116123
)
117124

125+
# according to the status of sponsored, look at different context menu actions
126+
set_in_use = set()
127+
if sponsored:
128+
set_in_use = REQUIRED_CONTEXT_MENU_ACTIONS_SPONSORED_TILE
129+
else:
130+
set_in_use = REQUIRED_CONTEXT_MENU_ACTIONS_REGULAR_TILE
131+
118132
# ensure we match each option
119133
for match in matched_regex:
120-
if match in REQUIRED_CONTEXT_MENU_ACTIONS_REGULAR_TILE:
121-
REQUIRED_CONTEXT_MENU_ACTIONS_REGULAR_TILE.remove(match)
134+
if match in set_in_use:
135+
set_in_use.remove(match)
122136
logging.info(f"Detected the context item: {match}")
123137

124138
assert (
125-
len(REQUIRED_CONTEXT_MENU_ACTIONS_REGULAR_TILE) == 0
139+
len(set_in_use) == 0
126140
), "Did not find all of the required context menu actions."

0 commit comments

Comments
 (0)