Add required inspector fields for Elements and Network (#5754)

This commit is contained in:
Darin Dimitrov
2018-04-27 17:04:52 +03:00
committed by GitHub
parent 03cfc0cee3
commit 1cb5e7387d
2 changed files with 30 additions and 5 deletions

View File

@@ -70,6 +70,8 @@ export namespace NetworkAgent {
url: string; url: string;
method: string; method: string;
headers: any; headers: any;
initialPriority: string;
referrerPolicy: string;
postData?: string; postData?: string;
} }
@@ -79,6 +81,7 @@ export namespace NetworkAgent {
request: Request; request: Request;
timestamp: number; timestamp: number;
type: string; type: string;
wallTime: number;
} }
export interface Response { export interface Response {
@@ -88,6 +91,10 @@ export namespace NetworkAgent {
headers: any; headers: any;
headersText?: string; headersText?: string;
mimeType: string; mimeType: string;
connectionReused: boolean;
connectionId: number;
encodedDataLength: number;
securityState: string;
fromDiskCache?: boolean; fromDiskCache?: boolean;
} }
@@ -113,13 +120,23 @@ export namespace NetworkAgent {
const requestIdStr = requestId.toString(); const requestIdStr = requestId.toString();
// Content-Type and content-type are both common in headers spelling // Content-Type and content-type are both common in headers spelling
const mimeType: string = <string>headers["Content-Type"] || <string>headers["content-type"] || "application/octet-stream"; const mimeType: string = <string>headers["Content-Type"] || <string>headers["content-type"] || "application/octet-stream";
const contentLengthHeader: string = <string>headers["Content-Length"] || <string>headers["content-length"];
var contentLength = parseInt(contentLengthHeader, 10);
if (isNaN(contentLength)) {
contentLength = 0;
}
const response: NetworkAgent.Response = { const response: NetworkAgent.Response = {
url: result.url || "", url: result.url || "",
status: result.statusCode, status: result.statusCode,
statusText: result.statusText || "", statusText: result.statusText || "",
headers: headers, headers: headers,
mimeType: mimeType, mimeType: mimeType,
fromDiskCache: false fromDiskCache: false,
connectionReused: true,
connectionId: 0,
encodedDataLength: contentLength,
securityState: "info"
} }
const responseData: NetworkAgent.ResponseData = { const responseData: NetworkAgent.ResponseData = {
@@ -130,7 +147,11 @@ export namespace NetworkAgent {
} }
global.__inspector.responseReceived(responseData); global.__inspector.responseReceived(responseData);
global.__inspector.loadingFinished({ requestId: requestIdStr, timestamp: getTimeStamp() }); global.__inspector.loadingFinished({
requestId: requestIdStr,
timestamp: getTimeStamp(),
encodedDataLength: contentLength
});
const hasTextContent = responseData.type === "Document" || responseData.type === "Script"; const hasTextContent = responseData.type === "Document" || responseData.type === "Script";
let data; let data;
@@ -164,7 +185,9 @@ export namespace NetworkAgent {
url: options.url, url: options.url,
method: options.method, method: options.method,
headers: options.headers || {}, headers: options.headers || {},
postData: options.content ? options.content.toString() : "" postData: options.content ? options.content.toString() : "",
initialPriority: "Medium",
referrerPolicy: "no-referrer-when-downgrade"
} }
const requestData: NetworkAgent.RequestData = { const requestData: NetworkAgent.RequestData = {
@@ -172,7 +195,8 @@ export namespace NetworkAgent {
url: request.url, url: request.url,
request: request, request: request,
timestamp: getTimeStamp(), timestamp: getTimeStamp(),
type: "Document" type: "Document",
wallTime: 0
} }
global.__inspector.requestWillBeSent(requestData); global.__inspector.requestWillBeSent(requestData);

View File

@@ -210,7 +210,8 @@ export class DOMNode {
localName: this.localName, localName: this.localName,
nodeValue: this.nodeValue, nodeValue: this.nodeValue,
children: this.children.map(c => c.toObject()), children: this.children.map(c => c.toObject()),
attributes: this.attributes attributes: this.attributes,
backendNodeId: 0
}; };
} }
} }