Skip to content

Commit 64d248f

Browse files
committed
[py] Add test for Data URL in BiDi Network request handler
1 parent f8396b9 commit 64d248f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

common/src/web/data_url.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Page containing an image encoded as a Data URL</title>
6+
</head>
7+
<body>
8+
<img src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" alt="star" id="data-url-image">
9+
</body>
10+
</html>

py/test/selenium/webdriver/common/bidi_network_tests.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
import pytest
1819

1920
from selenium.webdriver.common.bidi.browsing_context import ReadinessState
2021
from selenium.webdriver.common.bidi.network import Request
@@ -93,3 +94,16 @@ def test_remove_auth_handler(driver):
9394
assert callback_id is not None, "Request handler not added"
9495
driver.network.remove_auth_handler(callback_id)
9596
assert driver.network.intercepts == [], "Intercept not removed"
97+
98+
99+
@pytest.mark.xfail_chrome(reason="Data URLs in Network requests are not implemented in Chrome yet")
100+
@pytest.mark.xfail_edge(reason="Data URLs in Network requests are not implemented in Edge yet")
101+
@pytest.mark.xfail_firefox(reason="Data URLs in Network requests are not implemented in Firefox yet")
102+
def test_handler_with_data_url_request(driver, pages):
103+
def callback(request: Request):
104+
request.continue_request()
105+
106+
driver.network.add_request_handler("before_request", callback)
107+
url = pages.url("data_url.html")
108+
driver.browsing_context.navigate(context=driver.current_window_handle, url=url, wait=ReadinessState.COMPLETE)
109+
driver.find_elements(By.ID, "data-url-image").is_displayed(), "Request with Data URL failed"

0 commit comments

Comments
 (0)