[@types/chrome]: Add HAREntry and HARLog to chrome.devtools.network (#43407)

This commit is contained in:
yellott 2020-03-27 17:46:00 +02:00 committed by GitHub
parent 633eb9e9d4
commit 65c25fecb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

6
types/chrome/har-format/index.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
import { Entry, Log } from 'har-format';
declare global {
export type HARFormatEntry = Entry;
export type HARFormatLog = Log;
}

View File

@ -14,6 +14,7 @@
// TypeScript Version: 2.4
/// <reference types="filesystem" />
/// <reference path="har-format/index.d.ts" />
////////////////////
// Global object
@ -1865,8 +1866,12 @@ declare namespace chrome.devtools.inspectedWindow {
* Availability: Since Chrome 18.
*/
declare namespace chrome.devtools.network {
/** Represents a HAR entry for a specific finished request. */
export interface HAREntry extends HARFormatEntry { }
/** Represents a HAR log that contains all known network requests. */
export interface HARLog extends HARFormatLog { }
/** Represents a network request for a document resource (script, image and so on). See HAR Specification for reference. */
export interface Request {
export interface Request extends chrome.devtools.network.HAREntry {
/**
* Returns content of the response body.
* @param callback A function that receives the response body when the request completes.
@ -1889,7 +1894,7 @@ declare namespace chrome.devtools.network {
* function(object harLog) {...};
* Parameter harLog: A HAR log. See HAR specification for details.
*/
export function getHAR(callback: (harLog: Object) => void): void;
export function getHAR(callback: (harLog: HARLog) => void): void;
/** Fired when a network request is finished and all request data are available. */
export var onRequestFinished: RequestFinishedEvent;

View File

@ -439,3 +439,13 @@ function testStorage() {
var myOldValue: { x: number } = changes["myKey"].oldValue;
});
}
chrome.devtools.network.onRequestFinished.addListener((request: chrome.devtools.network.Request) => {
request; // $ExpectType Request
console.log('request: ', request);
});
chrome.devtools.network.getHAR((harLog: chrome.devtools.network.HARLog) => {
harLog; // $ExpectType HARLog
console.log('harLog: ', harLog)
});