Skip to content

Commit a8272d8

Browse files
authored
Merge branch 'trunk' into patch-2
2 parents 78d4bd5 + 58ed777 commit a8272d8

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
import time
1819

20+
import pytest
21+
22+
from selenium.common.exceptions import WebDriverException
1923
from selenium.webdriver.common.bidi.browsing_context import ReadinessState
2024
from selenium.webdriver.common.bidi.network import Request
2125
from selenium.webdriver.common.by import By
@@ -93,3 +97,27 @@ def test_remove_auth_handler(driver):
9397
assert callback_id is not None, "Request handler not added"
9498
driver.network.remove_auth_handler(callback_id)
9599
assert driver.network.intercepts == [], "Intercept not removed"
100+
101+
102+
@pytest.mark.xfail_chrome(reason="Data URLs in Network requests are not implemented in Chrome yet")
103+
@pytest.mark.xfail_edge(reason="Data URLs in Network requests are not implemented in Edge yet")
104+
@pytest.mark.xfail_firefox(reason="Data URLs in Network requests are not implemented in Firefox yet")
105+
def test_handler_with_data_url_request(driver, pages):
106+
data_requests = []
107+
exceptions = []
108+
109+
def callback(request: Request):
110+
if request.url.startswith("data:"):
111+
data_requests.append(request)
112+
try:
113+
request.continue_request()
114+
except WebDriverException as e:
115+
exceptions.append(e)
116+
117+
driver.network.add_request_handler("before_request", callback)
118+
url = pages.url("data_url.html")
119+
driver.browsing_context.navigate(context=driver.current_window_handle, url=url, wait=ReadinessState.COMPLETE)
120+
time.sleep(1) # give callback time to complete
121+
assert driver.find_element(By.ID, "data-url-image").is_displayed()
122+
assert len(data_requests) > 0, "BiDi event not captured"
123+
assert len(exceptions) == 0, "Exception raised when continuing request in callback"

0 commit comments

Comments
 (0)