mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Add required inspector fields for Elements and Network (#5754)
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
@@ -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
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user