tor-browser

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

commit 8d56ee3cbdc959df64899f83db562f191ad22a53
parent 2660e77da8e5c8fb91b5f9cb222518d80449cd41
Author: Thomas Wisniewski <twisniewski@mozilla.com>
Date:   Fri, 19 Dec 2025 23:16:53 +0000

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

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

Diffstat:
Mtesting/webcompat/client.py | 2+-
Mtesting/webcompat/fixtures.py | 18++++++++++++++++--
Mtesting/webcompat/interventions/tests/test_1844503_1849058_nicochannel_jp.py | 2+-
Mtesting/webcompat/interventions/tests/test_1846742_microsoft_com.py | 6+++++-
Mtesting/webcompat/interventions/tests/test_1897941_biodiscover_com.py | 8++++----
Dtesting/webcompat/interventions/tests/test_1907062_jianshu_io.py | 25-------------------------
Mtesting/webcompat/interventions/tests/test_1908636_ccccltd_cn.py | 2+-
Mtesting/webcompat/interventions/tests/test_1963270_app_kosmi_io.py | 1+
Dtesting/webcompat/interventions/tests/test_1964015_kickasstorrents_cr.py | 14--------------
Mtesting/webcompat/interventions/tests/test_1972511_cmyportal_tkc_co_jp.py | 4++--
Mtesting/webcompat/interventions/tests/test_1975927_trafficnews_jp.py | 2++
Mtesting/webcompat/interventions/tests/test_1999198_anime-bit_ru.py | 1+
12 files changed, 34 insertions(+), 51 deletions(-)

diff --git a/testing/webcompat/client.py b/testing/webcompat/client.py @@ -1560,7 +1560,7 @@ class Client: async def test_aceomni_pan_and_zoom_works(self, url): await self.navigate(url, wait="none") img = self.await_css("#imageZoom", is_displayed=True) - await self.stall(1) + await self.stall(2) def get_zoom_x(): return self.execute_script( diff --git a/testing/webcompat/fixtures.py b/testing/webcompat/fixtures.py @@ -450,6 +450,9 @@ def only_firefox_versions(bug_number, firefox_version, request): @pytest.fixture(autouse=True) def only_platforms(bug_number, platform, request, session): is_fenix = "org.mozilla.fenix" in session.capabilities.get("moz:profile", "") + is_gve = "org.mozilla.geckoview_example" in session.capabilities.get( + "moz:profile", "" + ) actualPlatform = session.capabilities["platformName"] actualPlatformRequired = request.node.get_closest_marker("actual_platform_required") if actualPlatformRequired and request.config.getoption("platform_override"): @@ -459,7 +462,11 @@ def only_platforms(bug_number, platform, request, session): if request.node.get_closest_marker("only_platforms"): plats = request.node.get_closest_marker("only_platforms").args for only in plats: - if only == platform or (only == "fenix" and is_fenix): + if ( + only == platform + or (only == "fenix" and is_fenix) + or (only == "gve" and is_gve) + ): if actualPlatform == platform or not actualPlatformRequired: return pytest.skip( @@ -470,10 +477,17 @@ def only_platforms(bug_number, platform, request, session): @pytest.fixture(autouse=True) def skip_platforms(bug_number, platform, request, session): is_fenix = "org.mozilla.fenix" in session.capabilities.get("moz:profile", "") + is_gve = "org.mozilla.geckoview_example" in session.capabilities.get( + "moz:profile", "" + ) if request.node.get_closest_marker("skip_platforms"): plats = request.node.get_closest_marker("skip_platforms").args for skipped in plats: - if skipped == platform or (skipped == "fenix" and is_fenix): + if ( + skipped == platform + or (skipped == "fenix" and is_fenix) + or (skipped == "gve" and is_gve) + ): pytest.skip( f"Bug #{bug_number} skipped on platform ({platform}, test skipped for {' and '.join(plats)})" ) diff --git a/testing/webcompat/interventions/tests/test_1844503_1849058_nicochannel_jp.py b/testing/webcompat/interventions/tests/test_1844503_1849058_nicochannel_jp.py @@ -9,7 +9,7 @@ async def check_for_regression(client, url, shouldPass=True): "視聴するには、会員プランまたはレンタルプランを購入してください" ) BLOCKED = client.text("このブラウザはサポートされていません。") - PLAY = client.css(".nfcp-overlay-play-lg") + PLAY = client.css("[data-testid=PlayArrowRoundedIcon]") await client.navigate(url) diff --git a/testing/webcompat/interventions/tests/test_1846742_microsoft_com.py b/testing/webcompat/interventions/tests/test_1846742_microsoft_com.py @@ -8,6 +8,7 @@ COOKIES_CSS = "#wcpConsentBannerCtrl" SEARCH_CSS = "#search" INPUT_CSS = "#cli_shellHeaderSearchInput" SUGGESTION_CSS = ".m-auto-suggest a.f-product" +SELECTED_PRODUCT_LINK_CSS = ".c-menu-item[data-selected=true] a.f-product" async def does_enter_work(client): @@ -21,10 +22,13 @@ 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="www.microsoft", timeout=2) client.await_css(SUGGESTION_CSS, is_displayed=True) + await client.stall(1) client.keyboard.key_down("\ue05b").perform() # Down arrow client.keyboard.key_down("\ue05b").perform() # Down arrow + selected_product = client.await_css(SELECTED_PRODUCT_LINK_CSS, is_displayed=True) + expected_url = client.get_element_attribute(selected_product, "href") + nav = await client.promise_navigation_begins(url=expected_url, timeout=2) client.keyboard.key_down("\ue007").perform() # Enter try: await nav diff --git a/testing/webcompat/interventions/tests/test_1897941_biodiscover_com.py b/testing/webcompat/interventions/tests/test_1897941_biodiscover_com.py @@ -1,8 +1,8 @@ import pytest URL = "https://biodiscover.com/" -DESKTOP_CSS = ".banner_warp" -MOBILE_CSS = ".banner-top" +DESKTOP_CSS = ".right-slider" +MOBILE_CSS = ".title > .more" @pytest.mark.only_platforms("android") @@ -10,7 +10,7 @@ MOBILE_CSS = ".banner-top" @pytest.mark.with_interventions async def test_enabled(client): await client.navigate(URL, wait="none") - assert client.await_css(MOBILE_CSS, is_displayed=True) + assert client.await_css(MOBILE_CSS, is_displayed=True, timeout=30) assert not client.find_css(DESKTOP_CSS, is_displayed=True) @@ -19,5 +19,5 @@ async def test_enabled(client): @pytest.mark.without_interventions async def test_disabled(client): await client.navigate(URL, wait="none") - assert client.await_css(DESKTOP_CSS, is_displayed=True) + assert client.await_css(DESKTOP_CSS, is_displayed=True, timeout=30) assert not client.find_css(MOBILE_CSS, is_displayed=True) diff --git a/testing/webcompat/interventions/tests/test_1907062_jianshu_io.py b/testing/webcompat/interventions/tests/test_1907062_jianshu_io.py @@ -1,25 +0,0 @@ -import pytest - -URL = "https://www.jianshu.com/p/68ea4f004c8a" - - -IMG_CSS = "img[data-original-src='//upload-images.jianshu.io/upload_images/27952728-939c10fd072ed9e3.png']" - - -@pytest.mark.asyncio -@pytest.mark.without_interventions -async def test_regression(client): - await client.make_preload_script( - f""" - window.__promise = new Promise(done => {{ - document.documentElement.addEventListener("load", ({{target}}) => {{ - if (target?.matches("{IMG_CSS}")) {{ - done(true); - }} - }}, true); - }}); - """ - ) - await client.navigate(URL, wait="none") - client.scroll_into_view(client.await_css(IMG_CSS)) - assert client.execute_async_script("window.__promise.then(arguments[0])") diff --git a/testing/webcompat/interventions/tests/test_1908636_ccccltd_cn.py b/testing/webcompat/interventions/tests/test_1908636_ccccltd_cn.py @@ -4,7 +4,7 @@ from webdriver.error import UnexpectedAlertOpenException URL = "https://xmgl.ccccltd.cn/a/login" UNSUPPORTED_TEXT = "请使用基于Chrome内核52版本以上的浏览器访问本系统" -LOGIN_CSS = "#main" +LOGIN_CSS = "#login_form2" @pytest.mark.asyncio diff --git a/testing/webcompat/interventions/tests/test_1963270_app_kosmi_io.py b/testing/webcompat/interventions/tests/test_1963270_app_kosmi_io.py @@ -18,6 +18,7 @@ async def is_local_file_option_shown(client, credentials, platform): condition="elem.innerText.replaceAll(' ', '').includes('Login')", is_displayed=True, ).click() + await client.stall(1) client.await_css( "button", condition="elem.innerText.includes('Login with Email')", diff --git a/testing/webcompat/interventions/tests/test_1964015_kickasstorrents_cr.py b/testing/webcompat/interventions/tests/test_1964015_kickasstorrents_cr.py @@ -1,14 +0,0 @@ -import pytest - -URL = "https://kickasstorrents.cr" - -SUPPORTED_CSS = "#wrapper" -UNSUPPORTED_CSS = "body:empty" - - -@pytest.mark.asyncio -@pytest.mark.without_interventions -async def test_regression(client): - await client.navigate(URL, wait="none") - assert client.await_css(SUPPORTED_CSS, is_displayed=True) - assert not client.find_css(UNSUPPORTED_CSS, is_displayed=True) diff --git a/testing/webcompat/interventions/tests/test_1972511_cmyportal_tkc_co_jp.py b/testing/webcompat/interventions/tests/test_1972511_cmyportal_tkc_co_jp.py @@ -9,7 +9,7 @@ UNSUPPORTED_CSS = "a[href*=chromesetup]" @pytest.mark.with_interventions async def test_enabled(client): await client.navigate(URL, wait="none") - assert client.await_css(SUPPORTED_CSS, is_displayed=True) + assert client.await_css(SUPPORTED_CSS, is_displayed=True, timeout=30) assert not client.find_css(UNSUPPORTED_CSS, is_displayed=True) @@ -17,5 +17,5 @@ async def test_enabled(client): @pytest.mark.without_interventions async def test_disabled(client): await client.navigate(URL, wait="none") - assert client.await_css(UNSUPPORTED_CSS, is_displayed=True) + assert client.await_css(UNSUPPORTED_CSS, is_displayed=True, timeout=30) assert not client.find_css(SUPPORTED_CSS, is_displayed=True) diff --git a/testing/webcompat/interventions/tests/test_1975927_trafficnews_jp.py b/testing/webcompat/interventions/tests/test_1975927_trafficnews_jp.py @@ -5,7 +5,9 @@ DESKTOP_CSS = "#pickup-slider" MOBILE_CSS = "#main-column" +# Somehow they serve GVE the desktop layout, but not true Fenix? @pytest.mark.only_platforms("android") +@pytest.mark.skip_platforms("gve") @pytest.mark.asyncio @pytest.mark.without_interventions async def test_regression(client): diff --git a/testing/webcompat/interventions/tests/test_1999198_anime-bit_ru.py b/testing/webcompat/interventions/tests/test_1999198_anime-bit_ru.py @@ -7,6 +7,7 @@ HIDDEN_IMAGES_CSS = ".anime_list.shadow.lazy" async def are_wrong_images_hidden(client): await client.navigate(URL, wait="none") client.execute_script("window.scrollTo(0, 200)") + await client.stall(1) # The site hides images with a class .lazy {display:none}, so we can check # if any of those images are onscreen and should be lacking that CSS class. return client.execute_script(