Skip to content

Commit 79d29a2

Browse files
author
Thiago Perrotta
committed
align network module with BiDi spec
Bug: #765 Spec: https://w3c.github.io/webdriver-bidi/#module-network
1 parent fce48df commit 79d29a2

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

Diff for: src/bidiMapper/domains/network/networkRequest.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class NetworkRequest {
161161
};
162162
}
163163

164-
#getBaseEventParams(): Network.BaseEventParams {
164+
#getBaseEventParams(): Network.BaseParameters {
165165
return {
166166
context: this.#requestWillBeSentEvent?.frameId ?? null,
167167
navigation: this.#requestWillBeSentEvent?.loaderId ?? null,
@@ -221,8 +221,6 @@ export class NetworkRequest {
221221
// TODO: implement.
222222
tlsStart: 0,
223223
// TODO: implement.
224-
tlsEnd: 0,
225-
// TODO: implement.
226224
requestStart: 0,
227225
// TODO: implement.
228226
responseStart: 0,
@@ -309,7 +307,6 @@ export class NetworkRequest {
309307
fromCache:
310308
this.#responseReceivedEvent.response.fromDiskCache ||
311309
this.#responseReceivedEvent.response.fromPrefetchCache,
312-
// TODO: implement.
313310
headers: this.#getHeaders(
314311
this.#responseReceivedEvent.response.headers
315312
),

Diff for: src/protocol/protocol.ts

+26-7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface EventResponse<MethodType, ParamsType> {
3232
export type BiDiCommand =
3333
| BrowsingContext.Command
3434
| CDP.Command
35+
| Network.Command
3536
| Script.Command
3637
| Session.Command;
3738

@@ -51,6 +52,7 @@ export namespace Message {
5152
export type CommandRequest = Pick<RawCommandRequest, 'id'> & BiDiCommand;
5253
export type CommandResponse = Pick<RawCommandRequest, 'id'> & ResultData;
5354

55+
export type EmptyCommand = never;
5456
export type EmptyParams = Record<string, never>;
5557
export type EmptyResult = {result: Record<string, never>};
5658

@@ -60,6 +62,7 @@ export namespace Message {
6062
| BrowsingContext.Result
6163
| CDP.Result
6264
| ErrorResult
65+
| Network.Result
6366
| Script.Result
6467
| Session.Result;
6568
// keep-sorted end
@@ -1018,9 +1021,14 @@ export namespace Log {
10181021
}
10191022

10201023
export namespace Network {
1024+
export type Command = Message.EmptyCommand;
1025+
1026+
export type Result = Message.EmptyResult;
1027+
10211028
export type Event =
10221029
| BeforeRequestSentEvent
10231030
| ResponseCompletedEvent
1031+
| ResponseStartedEvent
10241032
| FetchErrorEvent;
10251033

10261034
export type BeforeRequestSentEvent = EventResponse<
@@ -1033,6 +1041,11 @@ export namespace Network {
10331041
ResponseCompletedParams
10341042
>;
10351043

1044+
export type ResponseStartedEvent = EventResponse<
1045+
EventNames.ResponseStartedEvent,
1046+
ResponseStartedParams
1047+
>;
1048+
10361049
export type FetchErrorEvent = EventResponse<
10371050
EventNames.FetchErrorEvent,
10381051
FetchErrorParams
@@ -1068,12 +1081,13 @@ export namespace Network {
10681081
connectStart: number;
10691082
connectEnd: number;
10701083
tlsStart: number;
1071-
tlsEnd: number;
10721084
requestStart: number;
10731085
responseStart: number;
10741086
responseEnd: number;
10751087
};
10761088

1089+
export type Request = string;
1090+
10771091
export type RequestData = {
10781092
request: string;
10791093
url: string;
@@ -1085,8 +1099,8 @@ export namespace Network {
10851099
timings: FetchTimingInfo;
10861100
};
10871101

1088-
export type BaseEventParams = {
1089-
context: string | null;
1102+
export type BaseParameters = {
1103+
context: CommonDataTypes.BrowsingContext | null;
10901104
navigation: BrowsingContext.Navigation | null;
10911105
redirectCount: number;
10921106
request: RequestData;
@@ -1119,24 +1133,29 @@ export namespace Network {
11191133
content: ResponseContent;
11201134
};
11211135

1122-
export type BeforeRequestSentParams = BaseEventParams & {
1136+
export type BeforeRequestSentParams = BaseParameters & {
11231137
initiator: Initiator;
11241138
};
11251139

1126-
export type ResponseCompletedParams = BaseEventParams & {
1140+
export type ResponseCompletedParams = BaseParameters & {
11271141
response: ResponseData;
11281142
};
11291143

1130-
export type FetchErrorParams = BaseEventParams & {
1144+
export type ResponseStartedParams = BaseParameters & {
1145+
response: ResponseData;
1146+
};
1147+
1148+
export type FetchErrorParams = BaseParameters & {
11311149
errorText: string;
11321150
};
11331151

11341152
export const AllEvents = 'network';
11351153

11361154
export enum EventNames {
11371155
BeforeRequestSentEvent = 'network.beforeRequestSent',
1138-
ResponseCompletedEvent = 'network.responseCompleted',
11391156
FetchErrorEvent = 'network.fetchError',
1157+
ResponseStartedEvent = 'network.responseStarted',
1158+
ResponseCompletedEvent = 'network.responseCompleted',
11401159
}
11411160
}
11421161

0 commit comments

Comments
 (0)