diff options
Diffstat (limited to 'testing/webcompat/shims/tests')
7 files changed, 157 insertions, 0 deletions
diff --git a/testing/webcompat/shims/tests/__init__.py b/testing/webcompat/shims/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testing/webcompat/shims/tests/__init__.py diff --git a/testing/webcompat/shims/tests/common.py b/testing/webcompat/shims/tests/common.py new file mode 100644 index 0000000000..307e39c74d --- /dev/null +++ b/testing/webcompat/shims/tests/common.py @@ -0,0 +1,41 @@ +GPT_SHIM_MSG = "Google Publisher Tags is being shimmed by Firefox" +GAGTA_SHIM_MSG = "Google Analytics and Tag Manager is being shimmed by Firefox" + + +async def is_gtag_placeholder_displayed(client, url, finder, **kwargs): + await client.navigate(url, **kwargs) + client.execute_async_script( + """ + const done = arguments[0]; + if (window.dataLayer?.push?.toString() === [].push.toString()) { + return done(); + } + setTimeout(() => { + dataLayer.push({ + event: "datalayerReady", + eventTimeout: 1, + eventCallback: done, + }); + }, 100); + """ + ) + return client.is_displayed(client.find_element(finder)) + + +async def clicking_link_navigates(client, url, finder, **kwargs): + await client.navigate(url, **kwargs) + elem = client.await_element(finder) + return client.session.execute_async_script( + """ + const elem = arguments[0], + done = arguments[1]; + window.onbeforeunload = function() { + done(true); + }; + elem.click(); + setTimeout(() => { + done(false); + }, 1000); + """, + args=[elem], + ) diff --git a/testing/webcompat/shims/tests/test_1624914_google_trends.py b/testing/webcompat/shims/tests/test_1624914_google_trends.py new file mode 100644 index 0000000000..dea81e3ea4 --- /dev/null +++ b/testing/webcompat/shims/tests/test_1624914_google_trends.py @@ -0,0 +1,26 @@ +import pytest + +URL = "https://knowyourmeme.com/memes/awesome-face-epic-smiley" +IFRAME = "iframe#trends-widget-1" + + +@pytest.mark.asyncio +@pytest.mark.with_shims +async def test_works_with_shims(client): + await client.load_page_and_wait_for_iframe(URL, client.css(IFRAME)) + assert client.await_css("svg") + + +@pytest.mark.asyncio +@pytest.mark.without_tcp +@pytest.mark.without_shims +async def test_works_without_etp(client): + await client.load_page_and_wait_for_iframe(URL, client.css(IFRAME)) + assert client.await_css("body.neterror") + + +@pytest.mark.asyncio +@pytest.mark.without_shims +async def test_needs_shims(client): + await client.load_page_and_wait_for_iframe(URL, client.css(IFRAME)) + assert client.await_css("body.neterror") diff --git a/testing/webcompat/shims/tests/test_1694168_google_analytics_and_tag_manager.py b/testing/webcompat/shims/tests/test_1694168_google_analytics_and_tag_manager.py new file mode 100644 index 0000000000..a00e617bdb --- /dev/null +++ b/testing/webcompat/shims/tests/test_1694168_google_analytics_and_tag_manager.py @@ -0,0 +1,23 @@ +import pytest + +URL = "https://agspares.co.nz/category/Super-Store-Tractor-Linkage-Pins-Lynch-Pins-R-Clips" +ITEM = ".productsListed.item a[onclick]" + + +from .common import GAGTA_SHIM_MSG, clicking_link_navigates + + +@pytest.mark.asyncio +@pytest.mark.with_strict_etp +@pytest.mark.with_shims +async def test_enabled(client): + assert await clicking_link_navigates( + client, URL, client.css(ITEM), await_console_message=GAGTA_SHIM_MSG + ) + + +@pytest.mark.asyncio +@pytest.mark.with_strict_etp +@pytest.mark.without_shims +async def test_disabled(client): + assert not await clicking_link_navigates(client, URL, client.css(ITEM)) diff --git a/testing/webcompat/shims/tests/test_1762851_google_publisher_tags.py b/testing/webcompat/shims/tests/test_1762851_google_publisher_tags.py new file mode 100644 index 0000000000..3b52ce8480 --- /dev/null +++ b/testing/webcompat/shims/tests/test_1762851_google_publisher_tags.py @@ -0,0 +1,23 @@ +import pytest + +URL = "https://www.carousell.sg/search/ps3/?searchId=DjgOQf" +PLACEHOLDER = "[id*='Desktop_Search_FWB']" + + +from .common import GPT_SHIM_MSG, is_gtag_placeholder_displayed + + +@pytest.mark.asyncio +@pytest.mark.with_strict_etp +@pytest.mark.with_shims +async def test_enabled(client): + assert not await is_gtag_placeholder_displayed( + client, URL, client.css(PLACEHOLDER), await_console_message=GPT_SHIM_MSG + ) + + +@pytest.mark.asyncio +@pytest.mark.with_strict_etp +@pytest.mark.without_shims +async def test_disabled(client): + assert not await is_gtag_placeholder_displayed(client, URL, client.css(PLACEHOLDER)) diff --git a/testing/webcompat/shims/tests/test_1767270_rva311_com_pbm_fix.py b/testing/webcompat/shims/tests/test_1767270_rva311_com_pbm_fix.py new file mode 100644 index 0000000000..bf708af877 --- /dev/null +++ b/testing/webcompat/shims/tests/test_1767270_rva311_com_pbm_fix.py @@ -0,0 +1,21 @@ +import pytest + +URL = "https://www.rva311.com/rvaone" +SHIM_ACTIVE_MSG = "Private Browsing Web APIs is being shimmed by Firefox" +IDB_FAILURE_MSG = "InvalidStateError: A mutation operation was attempted on a database" + + +@pytest.mark.asyncio +@pytest.mark.with_private_browsing +@pytest.mark.with_shims +async def test_with_shim(client): + await client.navigate(URL, await_console_message=SHIM_ACTIVE_MSG) + assert client.await_css("#root nav", is_displayed=True) + + +@pytest.mark.asyncio +@pytest.mark.with_private_browsing +@pytest.mark.without_shims +async def test_without_shim(client): + await client.navigate(URL, await_console_message=IDB_FAILURE_MSG) + assert client.find_css("#root [class*='loading-dot']", is_displayed=True) diff --git a/testing/webcompat/shims/tests/test_1775099_google_publisher_tags.py b/testing/webcompat/shims/tests/test_1775099_google_publisher_tags.py new file mode 100644 index 0000000000..1e4e595561 --- /dev/null +++ b/testing/webcompat/shims/tests/test_1775099_google_publisher_tags.py @@ -0,0 +1,23 @@ +import pytest + +URL = "https://themighty.com/topic/fibromyalgia/difficulties-sitting-chronic-pain-fibromyalgia/" +PLACEHOLDER = ".tm-ads" + + +from .common import GPT_SHIM_MSG, is_gtag_placeholder_displayed + + +@pytest.mark.asyncio +@pytest.mark.with_strict_etp +@pytest.mark.with_shims +async def test_enabled(client): + assert not await is_gtag_placeholder_displayed( + client, URL, client.css(PLACEHOLDER), await_console_message=GPT_SHIM_MSG + ) + + +@pytest.mark.asyncio +@pytest.mark.with_strict_etp +@pytest.mark.without_shims +async def test_disabled(client): + assert await is_gtag_placeholder_displayed(client, URL, client.css(PLACEHOLDER)) |