diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/webcompat/shims/tests/common.py | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/webcompat/shims/tests/common.py')
-rw-r--r-- | testing/webcompat/shims/tests/common.py | 41 |
1 files changed, 41 insertions, 0 deletions
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], + ) |