Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions common/src/web/data_url.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Page containing an image encoded as a Data URL</title>
</head>
<body>
<img src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" alt="star" id="data-url-image">
</body>
</html>
28 changes: 28 additions & 0 deletions py/test/selenium/webdriver/common/bidi_network_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
# specific language governing permissions and limitations
# under the License.

import time

import pytest

from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common.bidi.browsing_context import ReadinessState
from selenium.webdriver.common.bidi.network import Request
from selenium.webdriver.common.by import By
Expand Down Expand Up @@ -93,3 +97,27 @@ def test_remove_auth_handler(driver):
assert callback_id is not None, "Request handler not added"
driver.network.remove_auth_handler(callback_id)
assert driver.network.intercepts == [], "Intercept not removed"


@pytest.mark.xfail_chrome(reason="Data URLs in Network requests are not implemented in Chrome yet")
@pytest.mark.xfail_edge(reason="Data URLs in Network requests are not implemented in Edge yet")
@pytest.mark.xfail_firefox(reason="Data URLs in Network requests are not implemented in Firefox yet")
def test_handler_with_data_url_request(driver, pages):
data_requests = []
exceptions = []

def callback(request: Request):
if request.url.startswith("data:"):
data_requests.append(request)
try:
request.continue_request()
except WebDriverException as e:
exceptions.append(e)

driver.network.add_request_handler("before_request", callback)
url = pages.url("data_url.html")
driver.browsing_context.navigate(context=driver.current_window_handle, url=url, wait=ReadinessState.COMPLETE)
time.sleep(1) # give callback time to complete
assert driver.find_element(By.ID, "data-url-image").is_displayed()
assert len(data_requests) > 0, "BiDi event not captured"
assert len(exceptions) == 0, "Exception raised when continuing request in callback"
Loading