Skip to content

Commit

Permalink
fix: add fragment to url (#2079)
Browse files Browse the repository at this point in the history
Closes #2077

---------

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Lightning00Blade <Lightning00Blade@users.noreply.github.com>
  • Loading branch information
Lightning00Blade and Lightning00Blade authored Mar 27, 2024
1 parent d37d406 commit d416b6c
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 30 deletions.
11 changes: 8 additions & 3 deletions src/bidiMapper/domains/network/NetworkRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
46 changes: 46 additions & 0 deletions tests/network/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@

[test_redirect_document[https coop\]]
expected: [FAIL, PASS]

[test_url_with_fragment]
expected: FAIL
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@

[test_www_authenticate]
expected: FAIL

[test_url_with_fragment]
expected: FAIL

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@

[test_redirect_document[https coop\]]
expected: [FAIL, PASS]

[test_url_with_fragment]
expected: FAIL
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@

[test_www_authenticate]
expected: FAIL

[test_url_with_fragment]
expected: FAIL

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@

[test_redirect_document[https coop\]]
expected: [FAIL, PASS]

[test_url_with_fragment]
expected: FAIL
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@

[test_response_status[407-Proxy Authentication Required\]]
expected: FAIL

[test_url_with_fragment]
expected: FAIL

0 comments on commit d416b6c

Please sign in to comment.