tor-browser

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

commit f12aec981d3b1070d868de4d7a7b396b6139a2ec
parent 42ab0d4845e907a4b4fce78340e708c316bc6ab7
Author: Thomas Wisniewski <twisniewski@mozilla.com>
Date:   Wed, 26 Nov 2025 23:06:58 +0000

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

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

Diffstat:
Mtesting/webcompat/interventions/tests/test_1899930_africanews_com.py | 11+++++++++--
Mtesting/webcompat/interventions/tests/test_1902496_be_bim_mx.py | 22++++++++++++++++++----
Dtesting/webcompat/interventions/tests/test_1945019_order_mealkeyway_com.py | 23-----------------------
Mtesting/webcompat/interventions/tests/test_1981995_mygeha_com.py | 2+-
Mtesting/webcompat/interventions/tests/test_1989975_idp_infocert_it.py | 2+-
Mtesting/webcompat/interventions/tests/test_1998361_doctolib_de.py | 11+++++++++--
6 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/testing/webcompat/interventions/tests/test_1899930_africanews_com.py b/testing/webcompat/interventions/tests/test_1899930_africanews_com.py @@ -1,4 +1,5 @@ import pytest +from webdriver import NoSuchElementException URL = "https://africanews.com/" @@ -11,7 +12,10 @@ UNSUPPORTED_TEXT = "upgrade your browser" @pytest.mark.with_interventions async def test_enabled(client): await client.navigate(URL, wait="none") - client.await_css(POPUP_CSS, is_displayed=True).click() + try: + client.await_css(POPUP_CSS, is_displayed=True).click() + except NoSuchElementException: + pass assert not client.find_text(UNSUPPORTED_TEXT, is_displayed=True) @@ -20,5 +24,8 @@ async def test_enabled(client): @pytest.mark.without_interventions async def test_disabled(client): await client.navigate(URL, wait="none") - client.await_css(POPUP_CSS, is_displayed=True).click() + try: + client.await_css(POPUP_CSS, is_displayed=True).click() + except NoSuchElementException: + pass assert client.await_text(UNSUPPORTED_TEXT, is_displayed=True) diff --git a/testing/webcompat/interventions/tests/test_1902496_be_bim_mx.py b/testing/webcompat/interventions/tests/test_1902496_be_bim_mx.py @@ -4,19 +4,33 @@ URL = "https://be.bim.mx/nb/index.cfm" UNBLOCKED_CSS = "#myModal" BLOCKED_TEXT = "Google Chrome" +VPN_TEXT = "Error 403 - Forbidden" + + +async def visit_site(client, expected): + await client.navigate(URL, wait="none") + vpn, expected = client.await_first_element_of( + [ + client.text(VPN_TEXT), + expected, + ], + is_displayed=True, + ) + if vpn: + pytest.skip( + "Region-locked, cannot test. Try using a VPN set to Canada or the USA." + ) @pytest.mark.asyncio @pytest.mark.with_interventions async def test_enabled(client): - await client.navigate(URL, wait="none") - assert client.await_css(UNBLOCKED_CSS, is_displayed=True) + await visit_site(client, client.css(UNBLOCKED_CSS)) assert not client.find_text(BLOCKED_TEXT, is_displayed=True) @pytest.mark.asyncio @pytest.mark.without_interventions async def test_disabled(client): - await client.navigate(URL, wait="none") - assert client.await_text(BLOCKED_TEXT, is_displayed=True) + await visit_site(client, client.text(BLOCKED_TEXT)) assert not client.find_css(UNBLOCKED_CSS, is_displayed=True) diff --git a/testing/webcompat/interventions/tests/test_1945019_order_mealkeyway_com.py b/testing/webcompat/interventions/tests/test_1945019_order_mealkeyway_com.py @@ -1,23 +0,0 @@ -import asyncio - -import pytest - -URL = "https://order.mealkeyway.com/merchant/74755a54504e625163684d713635544d544c414b77413d3d/main" -LANDING_PAGE_CSS = ".landingPage" -WARNING_TEXT = "please open in Chrome" - - -@pytest.mark.asyncio -@pytest.mark.with_interventions -async def test_enabled(client): - await client.navigate(URL) - client.await_css(LANDING_PAGE_CSS, is_displayed=True) - await asyncio.sleep(1) - assert not client.find_text(WARNING_TEXT, is_displayed=True) - - -@pytest.mark.asyncio -@pytest.mark.without_interventions -async def test_disabled(client): - await client.navigate(URL) - client.await_text(WARNING_TEXT, is_displayed=True) diff --git a/testing/webcompat/interventions/tests/test_1981995_mygeha_com.py b/testing/webcompat/interventions/tests/test_1981995_mygeha_com.py @@ -12,7 +12,7 @@ async def is_state_beside_zip(client): return client.execute_script( """ const [city, state] = [...arguments].map(arg => arg.getBoundingClientRect()); - return city.right < state.left && parseInt(state.top) == parseInt(city.top); + return city.width > 100 && state.width > 100 && city.right < state.left && Math.abs(state.top - city.top) < 2; """, city, state, diff --git a/testing/webcompat/interventions/tests/test_1989975_idp_infocert_it.py b/testing/webcompat/interventions/tests/test_1989975_idp_infocert_it.py @@ -1,7 +1,7 @@ import pytest URL = "https://idp.infocert.it/login" -SUPPORTED_CSS = "#banner-accept-btn-1" +SUPPORTED_CSS = "#icIdName" UNSUPPORTED_CSS = ".unsupported-browser" diff --git a/testing/webcompat/interventions/tests/test_1998361_doctolib_de.py b/testing/webcompat/interventions/tests/test_1998361_doctolib_de.py @@ -1,4 +1,5 @@ import pytest +from webdriver import NoSuchElementException URL = "https://www.doctolib.de/appointments/eyJfcmFpbHMiOnsibWVzc2FnZSI6Ik56TXdNRFV3TlRFeU1RPT0iLCJleHAiOm51bGwsInB1ciI6ImFwcG9pbnRtZW50In19--8828380aa4726a4c5e5f887a55ae459629f24c25e979d14373b22c722b2de264/telehealth_diagnostic" COOKIES_CSS = "#didomi-notice-agree-button" @@ -13,7 +14,10 @@ UNSUPPORTED_TEXT = "Inkompatibler Browser" @pytest.mark.with_interventions async def test_enabled(client): await client.navigate(URL, wait="none") - client.await_css(COOKIES_CSS, is_displayed=True).click() + try: + client.await_css(COOKIES_CSS, is_displayed=True).click() + except NoSuchElementException: + pass client.await_css(ENTRY_BUTTON_CSS, is_displayed=True).click() assert client.await_text(SUPPORTED_TEXT, is_displayed=True) assert not client.find_text(UNSUPPORTED_TEXT, is_displayed=True) @@ -24,7 +28,10 @@ async def test_enabled(client): @pytest.mark.without_interventions async def test_disabled(client): await client.navigate(URL, wait="none") - client.await_css(COOKIES_CSS, is_displayed=True).click() + try: + client.await_css(COOKIES_CSS, is_displayed=True).click() + except NoSuchElementException: + pass client.await_css(APP_RECOMMENDATION_CSS, is_displayed=True).click() client.await_css(ENTRY_BUTTON_CSS, is_displayed=True).click() assert client.await_text(UNSUPPORTED_TEXT, is_displayed=True)