From 4f678526d9a7bbf353c7de589e82066d62718d85 Mon Sep 17 00:00:00 2001 From: Stuart Schechter Date: Sun, 29 Sep 2024 18:55:06 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#70711=20Main=20by?= =?UTF-8?q?=20@UppaJung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/har-format/index.d.ts | 40 +++++++++++++++++++++-- types/har-format/test/har-format-tests.ts | 17 ++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/types/har-format/index.d.ts b/types/har-format/index.d.ts index 9583ee0fd3a40e..5fa6d378cec825 100644 --- a/types/har-format/index.d.ts +++ b/types/har-format/index.d.ts @@ -295,6 +295,40 @@ export interface Chunk { bytes: number; ts: number; } +/** + * _non-standard_ + * + * This object describes the initiator of a request (the location of the + * code that issued the request) and is used to populate the Entry's + * non-standard `_initiator` field. + */ +export interface Initiator { + /** + * presumably equivalent to _initiator_type + * + * values "parser" and "other" have been observed in Chrome's HARs + */ + "type": string; + /** + * The URL of the code file in which the code that issued the + * request represented by the Entry (this object's parent) resides. + * This would otherwise be the string in the Entry's `_initiator` field. + */ + "url"?: string | null | undefined; + /** + * The line number of the code that issued the request represented + * by the Entry to which this Initiator object has been attached. + */ + "lineNumber"?: number | null | undefined; + /** + * The column number of the code that issued the request. + */ + "column"?: number | null | undefined; + /** + * The detail information that would be in `_initiator_detail`. + */ + "detail"?: string | null | undefined; +} /** * This object represents an array with all exported HTTP requests. Sorting * entries by `startedDateTime` (starting from the oldest) is preferred way how @@ -421,15 +455,15 @@ export interface Entry { /** _non-standard_ */ _index?: number | null | undefined; /** _non-standard_ */ - _initiator?: string | null | undefined; + _initiator?: Initiator | string | null | undefined; /** _non-standard_ */ - _initiator_column?: string | null | undefined; + _initiator_column?: number | null | undefined; /** _non-standard_ */ _initiator_detail?: string | null | undefined; /** _non-standard_ */ _initiator_function?: string | null | undefined; /** _non-standard_ */ - _initiator_line?: string | null | undefined; + _initiator_line?: number | null | undefined; /** _non-standard_ */ _initiator_type?: string | null | undefined; /** _non-standard_ */ diff --git a/types/har-format/test/har-format-tests.ts b/types/har-format/test/har-format-tests.ts index ff550e05adfad2..944d6a3dee98a2 100644 --- a/types/har-format/test/har-format-tests.ts +++ b/types/har-format/test/har-format-tests.ts @@ -65,6 +65,23 @@ const paramsPostData: harFormat.PostData = { ], }; +// An initiator object in a HAR generated by Chrome 128.0.6613.138 +// by loading wikipedia.org +const _initiatorVerbose: { _initiator: harFormat.Initiator } = { + "_initiator": { + "type": "parser", + "url": "https://www.wikipedia.org/", + "lineNumber": 30, + }, +}; +// An initiator object generated by Chrome for a request returned from +// disk cache ("_fromCache": disk) +const _initiatorMinimal: { _initiator: harFormat.Initiator } = { + "_initiator": { + "type": "other", + }, +}; + // @ts-expect-error const missingPostData: harFormat.PostData = { mimeType: "text/plain",