From d416b6c86011147121f5adea7e447bcd14d8b662 Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:14:08 +0100 Subject: [PATCH] fix: add fragment to url (#2079) Closes #2077 --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Lightning00Blade --- .../domains/network/NetworkRequest.ts | 11 +++-- tests/network/test_network.py | 46 +++++++++++++++++++ .../before_request_sent.py.ini | 3 -- .../response_completed.py.ini | 3 -- .../response_started/response_started.py.ini | 3 -- .../before_request_sent.py.ini | 3 -- .../response_completed.py.ini | 3 -- .../response_started/response_started.py.ini | 3 -- .../before_request_sent.py.ini | 3 -- .../response_completed.py.ini | 3 -- .../response_started/response_started.py.ini | 3 -- 11 files changed, 54 insertions(+), 30 deletions(-) delete mode 100644 wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/before_request_sent/before_request_sent.py.ini delete mode 100644 wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/before_request_sent/before_request_sent.py.ini delete mode 100644 wpt-metadata/mapper/headless/webdriver/tests/bidi/network/before_request_sent/before_request_sent.py.ini diff --git a/src/bidiMapper/domains/network/NetworkRequest.ts b/src/bidiMapper/domains/network/NetworkRequest.ts index f923080150..96c343d3de 100644 --- a/src/bidiMapper/domains/network/NetworkRequest.ts +++ b/src/bidiMapper/domains/network/NetworkRequest.ts @@ -129,14 +129,19 @@ export class NetworkRequest { } get url(): string { - return ( + const fragment = + this.#request.info?.request.urlFragment ?? + this.#request.paused?.request.urlFragment ?? + ''; + const url = this.#response.info?.url ?? this.#response.paused?.request.url ?? this.#request.auth?.request.url ?? this.#request.info?.request.url ?? this.#request.paused?.request.url ?? - NetworkRequest.unknownParameter - ); + NetworkRequest.unknownParameter; + + return `${url}${fragment}`; } get method(): string { diff --git a/tests/network/test_network.py b/tests/network/test_network.py index 578bbbefce..77b359e753 100644 --- a/tests/network/test_network.py +++ b/tests/network/test_network.py @@ -69,6 +69,52 @@ async def test_network_before_request_sent_event_emitted( } +@pytest.mark.asyncio +async def test_network_before_request_sent_event_emitted_with_url_fragment( + websocket, context_id, base_url): + await subscribe(websocket, ["network.beforeRequestSent"], [context_id]) + + url_fragment = "#test" + url = f"{base_url}{url_fragment}" + + await send_JSON_command( + websocket, { + "method": "browsingContext.navigate", + "params": { + "url": url, + "wait": "complete", + "context": context_id + } + }) + + resp = await read_JSON_message(websocket) + + assert resp == { + 'type': 'event', + "method": "network.beforeRequestSent", + "params": { + "isBlocked": False, + "context": context_id, + "navigation": ANY_STR, + "redirectCount": 0, + "request": { + "request": ANY_STR, + "url": url, + "method": "GET", + "headers": ANY_LIST, + "cookies": [], + "headersSize": ANY_NUMBER, + "bodySize": 0, + "timings": ANY_DICT + }, + "initiator": { + "type": "other" + }, + "timestamp": ANY_TIMESTAMP + } + } + + @pytest.mark.asyncio async def test_network_global_subscription_enabled_in_new_context( websocket, create_context, base_url): diff --git a/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/before_request_sent/before_request_sent.py.ini b/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/before_request_sent/before_request_sent.py.ini deleted file mode 100644 index 05740c1fb4..0000000000 --- a/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/before_request_sent/before_request_sent.py.ini +++ /dev/null @@ -1,3 +0,0 @@ -[before_request_sent.py] - [test_url_with_fragment] - expected: FAIL diff --git a/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/response_completed/response_completed.py.ini b/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/response_completed/response_completed.py.ini index 3c5786447b..8fd7984946 100644 --- a/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/response_completed/response_completed.py.ini +++ b/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/response_completed/response_completed.py.ini @@ -7,6 +7,3 @@ [test_redirect_document[https coop\]] expected: [FAIL, PASS] - - [test_url_with_fragment] - expected: FAIL diff --git a/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/response_started/response_started.py.ini b/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/response_started/response_started.py.ini index a7f6fb35a2..67068feecb 100644 --- a/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/response_started/response_started.py.ini +++ b/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/response_started/response_started.py.ini @@ -7,6 +7,3 @@ [test_www_authenticate] expected: FAIL - - [test_url_with_fragment] - expected: FAIL diff --git a/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/before_request_sent/before_request_sent.py.ini b/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/before_request_sent/before_request_sent.py.ini deleted file mode 100644 index 05740c1fb4..0000000000 --- a/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/before_request_sent/before_request_sent.py.ini +++ /dev/null @@ -1,3 +0,0 @@ -[before_request_sent.py] - [test_url_with_fragment] - expected: FAIL diff --git a/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/response_completed/response_completed.py.ini b/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/response_completed/response_completed.py.ini index 3c5786447b..8fd7984946 100644 --- a/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/response_completed/response_completed.py.ini +++ b/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/response_completed/response_completed.py.ini @@ -7,6 +7,3 @@ [test_redirect_document[https coop\]] expected: [FAIL, PASS] - - [test_url_with_fragment] - expected: FAIL diff --git a/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/response_started/response_started.py.ini b/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/response_started/response_started.py.ini index a7f6fb35a2..67068feecb 100644 --- a/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/response_started/response_started.py.ini +++ b/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/response_started/response_started.py.ini @@ -7,6 +7,3 @@ [test_www_authenticate] expected: FAIL - - [test_url_with_fragment] - expected: FAIL diff --git a/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/before_request_sent/before_request_sent.py.ini b/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/before_request_sent/before_request_sent.py.ini deleted file mode 100644 index 05740c1fb4..0000000000 --- a/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/before_request_sent/before_request_sent.py.ini +++ /dev/null @@ -1,3 +0,0 @@ -[before_request_sent.py] - [test_url_with_fragment] - expected: FAIL diff --git a/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/response_completed/response_completed.py.ini b/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/response_completed/response_completed.py.ini index 3c5786447b..8fd7984946 100644 --- a/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/response_completed/response_completed.py.ini +++ b/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/response_completed/response_completed.py.ini @@ -7,6 +7,3 @@ [test_redirect_document[https coop\]] expected: [FAIL, PASS] - - [test_url_with_fragment] - expected: FAIL diff --git a/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/response_started/response_started.py.ini b/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/response_started/response_started.py.ini index f016291d9e..4f5d2dc0a4 100644 --- a/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/response_started/response_started.py.ini +++ b/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/response_started/response_started.py.ini @@ -4,6 +4,3 @@ [test_response_status[407-Proxy Authentication Required\]] expected: FAIL - - [test_url_with_fragment] - expected: FAIL