Skip to content

Commit

Permalink
fix: add fragment to url
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade committed Mar 27, 2024
1 parent 5e6dbc2 commit 6707ec5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 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

0 comments on commit 6707ec5

Please sign in to comment.