Bug 1828953 - add automated tests for a lot of webcompat interventions (mostly Android); r=ksenia

Differential Revision: https://phabricator.services.mozilla.com/D176205
This commit is contained in:
Thomas Wisniewski 2023-04-24 18:15:41 +00:00
parent f2f8898b45
commit 695f2198ee
47 changed files with 970 additions and 4 deletions

View File

@ -237,6 +237,15 @@ def platform(session):
return session.capabilities["platformName"]
@pytest.fixture(autouse=True)
def only_platforms(bug_number, platform, request, session):
if request.node.get_closest_marker("only_platforms"):
for only in request.node.get_closest_marker("only_platforms").args:
if only == platform:
return
pytest.skip(f"Bug #{bug_number} skipped on platform ({platform})")
@pytest.fixture(autouse=True)
def skip_platforms(bug_number, platform, request, session):
if request.node.get_closest_marker("skip_platforms"):

View File

@ -18,6 +18,11 @@ def pytest_generate_tests(metafunc):
argvalues = []
ids = []
if "only_platforms" in marks:
for mark in metafunc.function.pytestmark:
if mark.name == "only_platforms":
otherargs["only_platforms"] = mark.args
if "skip_platforms" in marks:
for mark in metafunc.function.pytestmark:
if mark.name == "skip_platforms":

View File

@ -1,6 +1,7 @@
[pytest]
console_output_style = classic
markers =
skip_platforms: skip tests on specific platforms (mac, linux, windows)
only_platforms: only run tests on specific platforms (mac, linux, windows, android)
skip_platforms: skip tests on specific platforms (mac, linux, windows, android)
with_interventions: enable web-compat interventions
without_interventions: disable web-compat interventions

View File

@ -0,0 +1,23 @@
import pytest
URL = "http://www.rakuten.co.jp/"
MOBILE_CSS = "#top-area"
DESKTOP_CSS = "#header-group"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(MOBILE_CSS)
assert not client.find_css(DESKTOP_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert client.await_css(DESKTOP_CSS)
assert not client.find_css(MOBILE_CSS)

View File

@ -0,0 +1,21 @@
import pytest
URL = "https://secure.viewer.zmags.com/services/htmlviewer/content/ddc3f3b9?pubVersion=46&locale=en&viewerID=85cfd72f#/ddc3f3b9/1"
BLOCKED_TEXT = "This browser is not supported"
UNBLOCKED_CSS = "#viewer .MainViewEnabled"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(UNBLOCKED_CSS)
@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(BLOCKED_TEXT)

View File

@ -0,0 +1,29 @@
import pytest
URL = "https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/AboutBundles/AboutBundles.html"
TOC_CSS = "#toc"
def toc_is_onscreen(client):
assert client.await_css(TOC_CSS, is_displayed=True)
return client.execute_script(
"""
return document.querySelector("#toc").getBoundingClientRect().left >= 0;
"""
)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert toc_is_onscreen(client)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert not toc_is_onscreen(client)

View File

@ -0,0 +1,23 @@
import pytest
# The site puts an exclamation mark in front of width="703"
# for Chrome UAs, but not for Firefox.
URL = "http://enuri.com/knowcom/detail.jsp?kbno=474985"
CHECK_CSS = "td[width='703']"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert not client.find_css(CHECK_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert client.find_css(CHECK_CSS)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.metfone.com.kh/en/4g-lte"
DESKTOP_CSS = "section.quickLinks"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert not client.find_css(DESKTOP_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert client.find_css(DESKTOP_CSS)

View File

@ -0,0 +1,21 @@
import pytest
URL = "https://store-kr.uniqlo.com/"
REDIRECT_CSS = "[onload='javascript:redirectPage();']"
APP_CSS = "uni-root"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(APP_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert client.await_css(REDIRECT_CSS)

View File

@ -0,0 +1,34 @@
import pytest
# Google puts [disabled="true"] on buttons, which causes them to not
# work in Firefox. Our intervention removes that [disabled] property.
URL = "https://www.google.com/maps/dir/Fettstra%C3%9Fe+20,+D-20357+Hamburg,+Deutschland/Hauptkirche+St.+Michaelis,+Englische+Planke,+Hamburg/@53.5586949,9.9852882,14z/data=!4m8!4m7!1m2!1m1!1s0x47b18f4493d02fe1:0x6280c2a6cea3ed83!1m2!1m1!1s0x47b18f11e1dd5b45:0x187d5dca009a4b19!3e3?gl=de"
BUTTON_CSS = "button[jsaction^='directionsSearchbox.time']"
def button_is_disabled(client):
button = client.await_css(BUTTON_CSS, is_displayed=True)
assert button
return client.execute_script(
"""
return arguments[0].getAttribute("disabled") === "true";
""",
button,
)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert not button_is_disabled(client)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert button_is_disabled(client)

View File

@ -5,6 +5,7 @@ IFRAME_CSS = "#main-iframe"
INCOMPATIBLE_CSS = ".browser-compatible.compatible.incompatible"
BLOCKED_TEXT = "blocked by the security rules"
DENIED_TEXT = "not available in your region"
FORBIDDEN_TEXT = "403 Forbidden"
async def check_unsupported_visibility(client, should_show):
@ -15,15 +16,16 @@ async def check_unsupported_visibility(client, should_show):
if frame:
client.switch_frame(frame)
denied, blocked, incompatible = client.await_first_element_of(
denied, blocked, forbidden, incompatible = client.await_first_element_of(
[
client.text(DENIED_TEXT),
client.text(BLOCKED_TEXT),
client.text(FORBIDDEN_TEXT),
client.css(INCOMPATIBLE_CSS),
]
)
if denied or blocked:
if denied or blocked or forbidden:
pytest.skip("Region-locked, cannot test. Try using a VPN set to USA.")
return

View File

@ -0,0 +1,21 @@
import pytest
URL = "https://wp1-ext.usps.gov/sap/bc/webdynpro/sap/hrrcf_a_unreg_job_search"
BLOCKED_TEXT = "This browser is not supported"
UNBLOCKED_CSS = "#sapwd_main_window_root_"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(UNBLOCKED_CSS)
@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(BLOCKED_TEXT)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.autotrader.ca/"
MOBILE_CSS = "#openInApp"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.find_css(MOBILE_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert not client.find_css(MOBILE_CSS)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.jp.square-enix.com/music/sem/page/FF7R/ost/"
ERROR_MSG = 'can\'t access property "slice", e.match(...) is null'
UNBLOCKED_CSS = "h1.logo.visible"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(UNBLOCKED_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL, await_console_message=ERROR_MSG)

View File

@ -0,0 +1,27 @@
import pytest
URL = "https://www.teletrader.com/"
def body_is_offscreen(client):
return client.execute_script(
"""
return document.body.getBoundingClientRect().left > 0;
"""
)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert not body_is_offscreen(client)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert body_is_offscreen(client)

View File

@ -0,0 +1,32 @@
import pytest
URL = "http://preev.com/"
INPUT_CSS = "#invField"
def no_number_arrows_appear(client):
inp = client.await_css(INPUT_CSS, is_displayed=True)
assert inp
inp.click()
return client.execute_script(
"""
return getComputedStyle(arguments[0]).appearance == "textfield";
""",
inp,
)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert no_number_arrows_appear(client)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert not no_number_arrows_appear(client)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.reactine.ca/products/"
BANNER_CSS = "#browser-alert"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(BANNER_CSS, is_displayed=False)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert client.await_css(BANNER_CSS, is_displayed=True)

View File

@ -0,0 +1,31 @@
import pytest
URL = "https://m.myvidster.com/"
CONTAINER_CSS = "#home_refresh_var"
def content_is_cropped(client):
container = client.await_css(CONTAINER_CSS, is_displayed=True)
assert container
return client.execute_script(
"""
return arguments[0].clientHeight < 100
""",
container,
)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert not content_is_cropped(client)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert content_is_cropped(client)

View File

@ -0,0 +1,21 @@
import pytest
URL = "https://mobile2.bmo.com/"
BLOCKED_TEXT = "This browser is out-of-date"
UNBLOCKED_CSS = "auth-field"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(UNBLOCKED_CSS)
@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(BLOCKED_TEXT)

View File

@ -0,0 +1,23 @@
import pytest
# This site fails with a redirect loop with a Firefox UA
URL = "http://app.xiaomi.com/"
REDIR_FAILURE_TEXT = "ERROR_REDIRECT_LOOP"
SUCCESS_CSS = "#J_mingleList"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(SUCCESS_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL, timeout=15)
assert client.find_text(REDIR_FAILURE_TEXT)

View File

@ -0,0 +1,31 @@
import pytest
URL = "https://www.dealnews.com/"
# The page sets the style.width of images too wide on
# Firefox, making the page wider than the viewport
def is_wider_than_window(client):
return client.execute_script(
"""
return document.body.scrollWidth > document.body.clientWidth;
"""
)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert not is_wider_than_window(client)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert is_wider_than_window(client)

View File

@ -0,0 +1,27 @@
import pytest
URL = "https://game.granbluefantasy.jp/"
def content_is_full_width(client):
return client.execute_script(
"""
return document.querySelector("#wrapper").offsetWidth == document.body.clientWidth;
"""
)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert content_is_full_width(client)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert not content_is_full_width(client)

View File

@ -0,0 +1,23 @@
import pytest
URL = "https://www.frontgate.com/resort-cotton-bath-towels/155771"
MOBILE_CSS = "#app"
DESKTOP_CSS = "#cbiBody"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.find_css(MOBILE_CSS)
assert not client.find_css(DESKTOP_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert client.find_css(DESKTOP_CSS)
assert not client.find_css(MOBILE_CSS)

View File

@ -0,0 +1,23 @@
import pytest
URL = "https://www.vmos.cn/"
MOBILE_CSS = ".bg_wave_blue"
DESKTOP_CSS = "#content"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(MOBILE_CSS)
assert not client.find_css(DESKTOP_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert client.await_css(DESKTOP_CSS)
assert not client.find_css(MOBILE_CSS)

View File

@ -0,0 +1,23 @@
import pytest
URL = "http://www.slrclub.com/"
MOBILE_CSS = "#logo-wrap"
DESKTOP_CSS = "#header"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(MOBILE_CSS)
assert not client.find_css(DESKTOP_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert client.await_css(DESKTOP_CSS)
assert not client.find_css(MOBILE_CSS)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://workflow.base.vn/todos"
ERROR_MSG = 'can\'t access property "split", a.ua.split(...)[1] is undefined'
SUCCESS_CSS = "#authform"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(SUCCESS_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL, await_console_message=ERROR_MSG)

View File

@ -0,0 +1,23 @@
import pytest
URL = "https://www.dolcegabbana.com/en/"
FAIL_CSS = "#p-homepage"
SUCCESS_CSS = "#app"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(SUCCESS_CSS)
assert not client.find_css(FAIL_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert client.await_css(FAIL_CSS)
assert not client.find_css(SUCCESS_CSS)

View File

@ -0,0 +1,22 @@
import pytest
URL = "https://www.acuvue.com/"
UNSUPPORTED_CSS = "#browser-alert"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,22 @@
import pytest
URL = "https://www.aveeno.com/products/calm-restore-oat-gel-moisturizer-for-sensitive-skin"
UNSUPPORTED_CSS = "#browser-alert"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.aptsovation.com/"
UNSUPPORTED_CSS = "[aria-label='Your browser is not supported']"
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.avanabayview.com/"
UNSUPPORTED_CSS = "[aria-label='Your browser is not supported']"
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.breakpointeandcoronado.com/"
UNSUPPORTED_CSS = "[aria-label='Your browser is not supported']"
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.liveatlasathens.com/"
UNSUPPORTED_CSS = "[aria-label='Your browser is not supported']"
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.liveobserverpark.com/"
UNSUPPORTED_CSS = "[aria-label='Your browser is not supported']"
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.midwayurban.com/"
UNSUPPORTED_CSS = "[aria-label='Your browser is not supported']"
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.nhcalaska.com/"
UNSUPPORTED_CSS = "[aria-label='Your browser is not supported']"
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.securityproperties.com/thornton/reserve-at-thornton-i-ii-apartments"
UNSUPPORTED_CSS = "[aria-label='Your browser is not supported']"
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.theloftsorlando.com/"
UNSUPPORTED_CSS = "[aria-label='Your browser is not supported']"
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://thepointeatcentral.prospectportal.com/Apartments/module/application_authentication?_ga=2.250831814.1585158328.1588776830-1793033216.1588776830"
UNSUPPORTED_CSS = "[aria-label='Your browser is not supported']"
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://www.vanallenapartments.com/"
UNSUPPORTED_CSS = "[aria-label='Your browser is not supported']"
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert not client.is_displayed(unsupported)
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
unsupported = client.await_css(UNSUPPORTED_CSS)
assert client.is_displayed(unsupported)

View File

@ -0,0 +1,20 @@
import pytest
URL = "https://open.toutiao.com/a6966170645738783269/?__publisher_id__=4221768740&channel_id=88805669586&dt=R7Plusm&fr=normal&from_gid=6956432767005491719&gy=2cb247169b873bc0f78107b5a569f282d129ede38a56330ac9edc00743af6ba6f301248cddcb5b2376b2b286f219a9938e69c1c33941e7892a56b16c8617ebb0b1cd50cb401ece07ea7107a158f0b3b0cb95539be68ebda39413081f8dfe1d7ef83abb830d081642aa72639dc2c3e34109c846be7df23727854e76248ce909576f29134ee85086a27255c0745783a0b2f39d213d1a0ee09adb787da51569e05f525c3ad201d6638c&item_id=6966170645738783269&label=related_news&oppo_anchor=&react_gray=1&req_id=2021070203235101015120108107B22076&utm_campaign=open&utm_medium=webview&utm_source=o_llq_api"
API_MISSING_MSG = "navigator.connection is undefined"
GOOD_CSS = "#pageletArticleContent"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(GOOD_CSS, is_displayed=True)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL, await_console_message=API_MISSING_MSG)

View File

@ -0,0 +1,23 @@
import pytest
# The gallery on this page only sets img[src] to a non-1x1-spacer if the error
# doesn't happen during page load, which doesn't happen with a Chrome UA.
URL = "https://www.coldwellbankerhomes.com/ri/little-compton/kvc-17_1,17_2/"
ERROR_MSG = 'can\'t access property "dataset", v[0] is undefined'
SUCCESS_CSS = "img[src='https://m.cbhomes.com/p/412/1333515/48cd7692a01247A/s23cc.jpg']"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(SUCCESS_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL, await_console_message=ERROR_MSG)

View File

@ -0,0 +1,32 @@
import pytest
URL = "https://www.schoolnutritionandfitness.com/webmenus2/#/view?id=6331c49ce96f1e9c468b45be&siteCode=1641"
ELEM_CSS = "react-app td > div"
HEIGHT_CUTOFF = 10
def get_elem_height(client):
elem = client.await_css(ELEM_CSS, is_displayed=True)
assert elem
return client.execute_script(
"""
return arguments[0].getBoundingClientRect().height;
""",
elem,
)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert get_elem_height(client) > HEIGHT_CUTOFF
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert get_elem_height(client) < HEIGHT_CUTOFF

View File

@ -0,0 +1,23 @@
import pytest
URL = "https://www.argaam.com/"
MOBILE_CSS = ".mobile-data-container"
DESKTOP_CSS = ".ticker_box"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(MOBILE_CSS)
assert not client.find_css(DESKTOP_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert client.await_css(DESKTOP_CSS)
assert not client.find_css(MOBILE_CSS)

View File

@ -0,0 +1,25 @@
import pytest
# The site serves a different mobile page to Firefox than Chrome
URL = "https://www.mobile.de/"
MOBILE_CSS = "header [data-testid='header-burger-menu']"
DESKTOP_CSS = "header [data-testid='header-mobile-small-screen']"
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(MOBILE_CSS)
assert not client.find_css(DESKTOP_CSS)
@pytest.mark.only_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert client.await_css(DESKTOP_CSS)
assert not client.find_css(MOBILE_CSS)

View File

@ -18,6 +18,11 @@ def pytest_generate_tests(metafunc):
argvalues = []
ids = []
if "only_platforms" in marks:
for mark in metafunc.function.pytestmark:
if mark.name == "only_platforms":
otherargs["only_platforms"] = mark.args
if "skip_platforms" in marks:
for mark in metafunc.function.pytestmark:
if mark.name == "skip_platforms":

View File

@ -1,7 +1,8 @@
[pytest]
console_output_style = classic
markers =
skip_platforms: skip tests on specific platforms (mac, linux, windows)
only_platforms: only run tests on specific platforms (mac, linux, windows, android)
skip_platforms: skip tests on specific platforms (mac, linux, windows, android)
with_shims: enable web-compat shims
without_shims: disable web-compat shims
without_storage_partitioning: disable partitioning of non-cookie third-party web storage