diff --git a/index.bs b/index.bs index 1a5bad4d..f60d2e9e 100644 --- a/index.bs +++ b/index.bs @@ -253,7 +253,9 @@ Command = { CommandData = ( SessionCommand // - BrowsingContextCommand + BrowsingContextCommand // + NetworkCommand // + ScriptCommand ) EmptyParams = { *text } @@ -286,6 +288,7 @@ ResultData = ( EmptyResult // SessionResult // BrowsingContextResult // + NetworkResult // ScriptResult ) @@ -298,8 +301,9 @@ Event = { EventData = ( BrowsingContextEvent // - ScriptEvent // - LogEvent + LogEvent // + NetworkEvent // + ScriptEvent ) @@ -3631,6 +3635,271 @@ opened steps given |window|, |type| and |message|. +## The network Module ## {#module-network} + +The network module contains commands and events +relating to network requests. + +### Definition ### {#module-network-definition} + +
+ +NetworkCommand = ( +) + ++ +[=local end definition=] + +
+ +NetworkResult = ( +) + +NetworkEvent = ( + NetworkBeforeSendRequest // + NetworkResponseStarted // + NetworkResponseCompleted // + NetworkError +) + ++ +### Types ### {#module-network-types} + +#### The network.Cookie type #### {#type-network-Cookie} + +[=Remote end definition=] and [=local end definition=] + +
+NetworkCookie = { + name: text, + ? value: text, + ? binaryValue: [ uint ] + domain: text, + path: text, + expires: uint, + size: unit, + httpOnly: boolean, + secure: boolean, + session: boolean, + sameSite: "strict" / "lax" / "none", +}; ++ +The
NetworkCookie
type represents a cookie.
+
+If the cookie value can be represented as a UTF-8 encoded string, the
+value
field will be present. Otherwise the binaryValue
+field will be present and consist of an array of integers representing the bytes
+of the cookie value.
+
+#### The network.FetchTimingInfo type #### {#type-network-FetchTimingInfo}
+
+[=Remote end definition=] and [=local end definition=]
+
++NetworkFetchTimingInfo = { + requestTime: uint, + redirectStart: uint, + redirectEnd: uint, + fetchStart: uint, + dnsStart: uint, + dnsEnd: uint, + connectStart: uint, + connectEnd: uint, + tlsStart: uint, + tlsEnd: uint, + requestStart: uint, + responseStart: uint, + responseHeadersEnd: uint, + responseEnd: uint, +}; ++ +The
NetworkFetchTimingInfo
type represents the time of each part of
+the request, relative to requestTime
.
+
+TODO: Add service worker fields
+
+#### The network.Header type #### {#type-network-Header}
+
+[=Remote end definition=] and [=local end definition=]
+
++NetworkHeader = { + name: text, + ? value: text, + ? binaryValue: [ uint ] +}; ++ +The
NetworkHeader
type represents a single request header.
+
+If the header value can be represented as a UTF-8 encoded string, the
+value
field will be present. Otherwise the binaryValue
+field will be present and consist of an array of integers representing the bytes
+of the header.
+
+#### The network.Initiator type #### {#type-network-Initiator}
+
+[=Remote end definition=] and [=local end definition=]
+
++NetworkInitiator = { + type: "parser" / "script" / "preflight" / "other", + ?columnNumber: uint, + ?lineNumber: uint, + ?stackTrace: StackTrace, + ?request: NetworkRequest +}; ++ +The
NetworkInitiatior
type represents the source of a network request.
+
+TODO: Align more closely with Fetch here?
+
+#### The network.Request type #### {#type-network-RequestId}
+
+[=Remote end definition=] and [=local end definition=]
+
++NetworkRequest = text; ++ +Each network request has an associated request id, which is a string +uniquely identifying that request. + +#### The network.RequestData type #### {#type-network-RequestData} + +[=Remote end definition=] and [=local end definition=] + +
+NetworkRequestData = { + url: text, + method: text, + headers: [ *NetworkHeader ], + cookies: [ *NetworkCookie ], + ?body: text, + bodySize: uint, + headersSize: uint +}; ++ +The
RequestData
type represents an ongoing network request.
+
+TODO: Body is actually bytes, not clear how to handle it as text
+
+#### The network.ResponseData type #### {#type-network-ResponseData}
+
+[=Remote end definition=] and [=local end definition=]
+
++NetworkResponseData = { + url: text, + protocol: text, + status: unit, + statusText: text, + headers: [ *NetworkHeader ], + cookies: [ *NetworkCookie ], + mimeType: text, + bytesReceived: uint, + timings: NetworkFetchTimingInfo, +}; ++ +### Events ### {#module-network-events} + +#### The network.beforeRequestSent Event #### {#event-network-beforeSendRequest} +
+ NetworkBeforeRequestSentEvent = { + method: "network.beforeRequestSent", + params: NetworkBeforeRequestSentParams + } + + NetworkBeforeRequestSentParams = { + request: NetworkRequest, + navigation: Navigation / null, + context: BrowsingContext / null, + requestData: NetworkRequestData, + initiator: NetworkInitiator + timestamp: number, + } ++
+ NetworkFetchErrorEvent = { + method: "network.fetchError", + params: NetworkFetchErrorParams + } + + NetworkFetchErrorParams = { + request: NetworkRequest, + errorText: text, + timestamp: number, + } ++
+ NetworkResponseCompletedEvent = { + method: "network.responseCompleted", + params: NetworkResponseCompleteParams + } + + NetworkResponseCompletedParams = { + request: NetworkRequest, + navigation: Navigation / null, + context: BrowsingContext / null, + responseData: NetworkResponseData, + timestamp: number, + } ++
+ NetworkResponseStartedEvent = { + method: "network.responseStartedEvent", + params: NetworkResponseStartedParams + } + + NetworkResponseStartedParams = { + request: NetworkRequest, + navigaton: Navigation / null, + context: BrowsingContext / null, + responseData: NetworkResponseData, + timestamp: number, + } ++