Bug 2044337 - add a header-altering webcompat intervention for okini.net; r=ksenia,webcompat-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D306539
This commit is contained in:
committed by
twisniewski@mozilla.com
parent
eccc9556d3
commit
8f853959be
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"label": "okini.net",
|
||||
"bugs": {
|
||||
"2044337": {
|
||||
"issue": "page-fails-to-load",
|
||||
"matches": ["*://www.okini.net/*"]
|
||||
}
|
||||
},
|
||||
"interventions": [
|
||||
{
|
||||
"platforms": ["all"],
|
||||
"min_version": 141,
|
||||
"alter_request_headers": [
|
||||
{
|
||||
"headers": ["TE"],
|
||||
"replacement": "moz_no_te_trailers"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -18,6 +18,12 @@ from webdriver.bidi.error import InvalidArgumentException, NoSuchFrameException
|
||||
from webdriver.bidi.modules.script import ContextTarget
|
||||
|
||||
|
||||
def escape_xpath_string_quotes(text):
|
||||
if not "'" in text:
|
||||
return f"'{text}'"
|
||||
return "concat('" + """', "'", '""".join(text.split("'")) + "')"
|
||||
|
||||
|
||||
class Client:
|
||||
def __init__(self, request, session, event_loop):
|
||||
self.request = request
|
||||
@@ -805,7 +811,8 @@ class Client:
|
||||
)
|
||||
|
||||
async def await_text(self, text, **kwargs):
|
||||
xpath = f"//*[text()[contains(.,'{text}')]]"
|
||||
escaped_text = escape_xpath_string_quotes(text)
|
||||
xpath = f"//*[text()[contains(.,{escaped_text})]]"
|
||||
return await self.await_xpath(self, xpath, **kwargs)
|
||||
|
||||
async def await_xpath(
|
||||
@@ -1181,7 +1188,8 @@ class Client:
|
||||
|
||||
def find_text(self, text, is_displayed=None, **kwargs):
|
||||
try:
|
||||
e = self.find_xpath(f"//*[text()[contains(.,'{text}')]]", **kwargs)
|
||||
escaped_text = escape_xpath_string_quotes(text)
|
||||
e = self.find_xpath(f"//*[text()[contains(.,{escaped_text})]]", **kwargs)
|
||||
return self._do_is_displayed_check(e, is_displayed)
|
||||
except webdriver.error.NoSuchElementException:
|
||||
return None
|
||||
|
||||
@@ -118,6 +118,7 @@ async def get_accept_button(client, in_headless_mode):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.only_firefox_versions(min=141)
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.with_interventions
|
||||
async def test_with_interventions(client, in_headless_mode):
|
||||
@@ -125,6 +126,7 @@ async def test_with_interventions(client, in_headless_mode):
|
||||
assert client.await_css(OOPS_CSS, is_displayed=True)
|
||||
|
||||
|
||||
@pytest.mark.only_firefox_versions(min=141)
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client, in_headless_mode):
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import pytest
|
||||
|
||||
URL = "https://www.okini.net/"
|
||||
SUPPORTED_CSS = "table"
|
||||
UNSUPPORTED_TEXT = "Sorry, that's an error"
|
||||
|
||||
|
||||
@pytest.mark.only_firefox_versions(min=141)
|
||||
@pytest.mark.asyncio
|
||||
@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 not client.find_text(UNSUPPORTED_TEXT, is_displayed=True)
|
||||
|
||||
|
||||
@pytest.mark.only_firefox_versions(min=141)
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.without_interventions
|
||||
async def test_disabled(client):
|
||||
await client.navigate(URL, wait="none")
|
||||
assert client.await_text(UNSUPPORTED_TEXT, is_displayed=True)
|
||||
assert not client.find_css(SUPPORTED_CSS, is_displayed=True)
|
||||
Reference in New Issue
Block a user