tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit b90602b62f414e50586b65aca218afa81b2d43d6
parent ffb579cd685179ed293f1fb02432727b3a63f8d9
Author: Thomas Wisniewski <twisniewski@mozilla.com>
Date:   Thu, 16 Oct 2025 16:12:18 +0000

Bug 1994456 - fix webcompat interventions automated tests; r=ksenia

Differential Revision: https://phabricator.services.mozilla.com/D268797

Diffstat:
Mtesting/webcompat/interventions/tests/test_1819450_cmbchina_com.py | 2+-
Mtesting/webcompat/interventions/tests/test_1846742_microsoft_com.py | 2+-
Mtesting/webcompat/interventions/tests/test_1848713_cleanrider_com.py | 7+++++--
Mtesting/webcompat/interventions/tests/test_1850998_chaturbate_com.py | 2+-
Mtesting/webcompat/interventions/tests/test_1856915_login_yahoo_com.py | 26+++++++++++++++++---------
Mtesting/webcompat/interventions/tests/test_1873166_108408_secure_nsandi_com.py | 2+-
Mtesting/webcompat/interventions/tests/test_1902407_www_sigadoc_mt_gov_br.py | 2+-
Mtesting/webcompat/interventions/tests/test_1905607_10play_com_au.py | 19++++++++++++++-----
Mtesting/webcompat/interventions/tests/test_1914327_media_qdnd_vn.py | 1-
Mtesting/webcompat/interventions/tests/test_1942292_beterbed_nl.py | 2+-
10 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/testing/webcompat/interventions/tests/test_1819450_cmbchina_com.py b/testing/webcompat/interventions/tests/test_1819450_cmbchina_com.py @@ -1,7 +1,7 @@ import pytest URL = "https://www.cmbchina.com/" -DESKTOP_CSS = "#aspnetForm" +DESKTOP_CSS = "#videodiv" MOBILE_CSS = "#ice-container" diff --git a/testing/webcompat/interventions/tests/test_1846742_microsoft_com.py b/testing/webcompat/interventions/tests/test_1846742_microsoft_com.py @@ -21,7 +21,7 @@ async def does_enter_work(client): # We now wait for the search suggestions to appear, press Down twice, # and Enter once. This should begin a navigation if things are working. - nav = await client.promise_navigation_begins(url="microsoft", timeout=2) + nav = await client.promise_navigation_begins(url="www.microsoft", timeout=2) client.await_css(SUGGESTION_CSS, is_displayed=True) client.keyboard.key_down("\ue05b").perform() # Down arrow client.keyboard.key_down("\ue05b").perform() # Down arrow diff --git a/testing/webcompat/interventions/tests/test_1848713_cleanrider_com.py b/testing/webcompat/interventions/tests/test_1848713_cleanrider_com.py @@ -1,6 +1,6 @@ import pytest from webdriver import NoSuchElementException -from webdriver.error import ElementClickInterceptedException +from webdriver.error import ElementClickInterceptedException, WebDriverException URL = "https://www.cleanrider.com/catalogue/velo-electrique/velos-pliants-electriques/" @@ -58,7 +58,10 @@ async def can_interact_with_slider(client): for _ in range(5): min_thumb.click() await client.stall(0.5) - except ElementClickInterceptedException: + except ( + ElementClickInterceptedException, + WebDriverException, + ) as _: # element not interactable return True assert await client.find_alert("bad") diff --git a/testing/webcompat/interventions/tests/test_1850998_chaturbate_com.py b/testing/webcompat/interventions/tests/test_1850998_chaturbate_com.py @@ -9,7 +9,7 @@ VID_CSS = ".videoPlayerDiv" async def is_requestFullscreen_called(client): await client.navigate(URL) - client.await_css(AGREE_CSS, is_displayed=True).click() + client.await_css(AGREE_CSS, is_displayed=True, timeout=30).click() client.await_css(FIRST_ROOM_CSS, is_displayed=True).click() vid = client.await_css(VID_CSS, is_displayed=True) fs = client.await_css(FS_CSS, is_displayed=True) diff --git a/testing/webcompat/interventions/tests/test_1856915_login_yahoo_com.py b/testing/webcompat/interventions/tests/test_1856915_login_yahoo_com.py @@ -15,15 +15,23 @@ async def is_password_reveal_toggle_fully_visible(client, in_headless_mode): await client.navigate(URL) client.await_css(USERNAME_CSS).send_keys("webcompat") client.await_css(SIGNIN_CSS).click() - client.await_css(RECAPTCHA_CSS, is_displayed=True) - print("\a") # beep to let the user know to do the reCAPTCHA - try: - toggle = client.await_css(TOGGLE_CSS, timeout=60) - except NoSuchElementException: - pytest.xfail( - "Timed out waiting for reCAPTCHA to be completed. Please try again." - ) - return False + recaptcha, toggle = client.await_first_element_of( + [ + client.css(RECAPTCHA_CSS), + client.css(TOGGLE_CSS), + ], + is_displayed=True, + ) + if recaptcha: + client.await_css(RECAPTCHA_CSS, is_displayed=True) + print("\a") # beep to let the user know to do the reCAPTCHA + try: + toggle = client.await_css(TOGGLE_CSS, timeout=60) + except NoSuchElementException: + pytest.xfail( + "Timed out waiting for reCAPTCHA to be completed. Please try again." + ) + return False return client.execute_script( """ const toggle = arguments[0].getBoundingClientRect(); diff --git a/testing/webcompat/interventions/tests/test_1873166_108408_secure_nsandi_com.py b/testing/webcompat/interventions/tests/test_1873166_108408_secure_nsandi_com.py @@ -21,7 +21,7 @@ async def is_warning_shown(client): @pytest.mark.asyncio @pytest.mark.with_interventions async def test_enabled(client): - assert await is_warning_shown(client) + assert not await is_warning_shown(client) @pytest.mark.only_platforms("android") diff --git a/testing/webcompat/interventions/tests/test_1902407_www_sigadoc_mt_gov_br.py b/testing/webcompat/interventions/tests/test_1902407_www_sigadoc_mt_gov_br.py @@ -13,7 +13,7 @@ UNSUPPORTED_CSS = "#isChrome" @pytest.mark.with_interventions async def test_enabled(client): await client.navigate(URL, wait="none") - client.await_css(HERO_CSS, is_displayed=True) + client.await_css(HERO_CSS, is_displayed=True, timeout=30) await asyncio.sleep(3) assert not client.find_css(UNSUPPORTED_CSS, is_displayed=True) assert not client.find_text(UNSUPPORTED_TEXT, is_displayed=True) diff --git a/testing/webcompat/interventions/tests/test_1905607_10play_com_au.py b/testing/webcompat/interventions/tests/test_1905607_10play_com_au.py @@ -3,21 +3,30 @@ import pytest URL = "https://10play.com.au/masterchef/episodes/season-16" SUPPORTED_TEXT = "Sign in to watch this video" UNSUPPORTED_TEXT = "Your mobile browser is not supported" +NEED_VPN_TEXT = "not available in your region" + + +async def visit_site(client, expected): + await client.navigate(URL) + expected, vpn = client.await_first_element_of( + [client.text(expected), client.text(NEED_VPN_TEXT)], is_displayed=True + ) + if vpn: + pytest.skip("Region-locked, cannot test. Try using a VPN set to Australia.") + return expected @pytest.mark.only_platforms("android") @pytest.mark.asyncio @pytest.mark.with_interventions async def test_enabled(client): - await client.navigate(URL) - assert client.await_text(SUPPORTED_TEXT) - assert not client.find_text(UNSUPPORTED_TEXT) + assert await visit_site(client, SUPPORTED_TEXT) + assert not client.find_text(UNSUPPORTED_TEXT, is_displayed=True) @pytest.mark.only_platforms("android") @pytest.mark.asyncio @pytest.mark.without_interventions async def test_disabled(client): - await client.navigate(URL) - assert client.await_text(UNSUPPORTED_TEXT) + assert await visit_site(client, UNSUPPORTED_TEXT) assert not client.find_text(SUPPORTED_TEXT) diff --git a/testing/webcompat/interventions/tests/test_1914327_media_qdnd_vn.py b/testing/webcompat/interventions/tests/test_1914327_media_qdnd_vn.py @@ -30,7 +30,6 @@ async def calls_canPlayType(client, type): ) if play: play.click() - client.await_css(ERROR_MSG_CSS, is_displayed=True) return client.execute_script( """ return window.__cpts.includes(arguments[0]); diff --git a/testing/webcompat/interventions/tests/test_1942292_beterbed_nl.py b/testing/webcompat/interventions/tests/test_1942292_beterbed_nl.py @@ -1,7 +1,7 @@ import pytest URL = "https://www.beterbed.nl/matrassen/m-line?SelectedFacetIds[1dfabd26b0e444e68fc92fd50281f0be]=M%20line&SortBy=DiscountPercentage" -CONTAINER_CSS = ".top-navigation__items.slider-content" +CONTAINER_CSS = ".slider-content" async def is_scrollbar_visible(client):