mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
fix(debugger): Enable iOS inspector modules on creation
When the application is being debugged with `--debug-brk --bundle` options, the JS implementation objects handling the debugging protocol are created after their corresponding domains' `enable` methods have been called by the debugger frontend. As a workaround we now manually call `enable` in their constructors. related to https://github.com/NativeScript/ios-runtime/issues/1055 and https://github.com/NativeScript/ios-runtime/issues/1057
This commit is contained in:
@ -18,6 +18,10 @@ export class CSSDomainDebugger implements inspectorCommandTypes.CSSDomain.CSSDom
|
||||
this.commands = {};
|
||||
|
||||
attachCSSInspectorCommandCallbacks(this.commands);
|
||||
|
||||
// By default start enabled because we can miss the "enable" event when
|
||||
// running with `--debug-brk` -- the frontend will send it before we've been created
|
||||
this.enable();
|
||||
}
|
||||
|
||||
get enabled(): boolean {
|
||||
|
@ -20,6 +20,10 @@ export class DOMDomainDebugger implements inspectorCommandTypes.DOMDomain.DOMDom
|
||||
|
||||
attachDOMInspectorEventCallbacks(this.events);
|
||||
attachDOMInspectorCommandCallbacks(this.commands);
|
||||
|
||||
// By default start enabled because we can miss the "enable event when
|
||||
// running with `--debug-brk` -- the frontend will send it before we've been created
|
||||
this.enable();
|
||||
}
|
||||
|
||||
get enabled(): boolean {
|
||||
|
@ -64,7 +64,7 @@ export class Request {
|
||||
this._resourceType = "Other";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this._mimeType = value;
|
||||
|
||||
var resourceType = "Other";
|
||||
@ -112,19 +112,19 @@ export class Request {
|
||||
this._resourceType = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public responseReceived(response: inspectorCommandTypes.NetworkDomain.Response): void {
|
||||
if (this._networkDomainDebugger.enabled) {
|
||||
this._networkDomainDebugger.events.responseReceived(this.requestID, frameId, loaderId, __inspectorTimestamp(), <any>this.resourceType, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public loadingFinished(): void {
|
||||
if (this._networkDomainDebugger.enabled) {
|
||||
this._networkDomainDebugger.events.loadingFinished(this.requestID, __inspectorTimestamp());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public requestWillBeSent(request: inspectorCommandTypes.NetworkDomain.Request): void {
|
||||
if (this._networkDomainDebugger.enabled) {
|
||||
this._networkDomainDebugger.events.requestWillBeSent(this.requestID, frameId, loaderId, request.url, request, __inspectorTimestamp(), { type: "Script" });
|
||||
@ -136,9 +136,13 @@ export class Request {
|
||||
export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomain.NetworkDomainDispatcher {
|
||||
private _enabled: boolean;
|
||||
public events: inspectorCommandTypes.NetworkDomain.NetworkFrontend;
|
||||
|
||||
|
||||
constructor() {
|
||||
this.events = new inspectorCommands.NetworkDomain.NetworkFrontend();
|
||||
|
||||
// By default start enabled because we can miss the "enable" event when
|
||||
// running with `--debug-brk` -- the frontend will send it before we've been created
|
||||
this.enable();
|
||||
}
|
||||
|
||||
get enabled(): boolean {
|
||||
@ -156,7 +160,7 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
|
||||
}
|
||||
this._enabled = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disables network tracking, prevents network events from being sent to the client.
|
||||
*/
|
||||
@ -166,14 +170,14 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
|
||||
}
|
||||
this._enabled = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specifies whether to always send extra HTTP headers with the requests from this page.
|
||||
*/
|
||||
setExtraHTTPHeaders(params: inspectorCommandTypes.NetworkDomain.SetExtraHTTPHeadersMethodArguments): void {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns content served for the given request.
|
||||
*/
|
||||
@ -187,9 +191,9 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
|
||||
body: body,
|
||||
base64Encoded: !resource_data.hasTextContent
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tells whether clearing browser cache is supported.
|
||||
*/
|
||||
@ -198,14 +202,14 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
|
||||
result: false
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears browser cache.
|
||||
*/
|
||||
clearBrowserCache(): void {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tells whether clearing browser cookies is supported.
|
||||
*/
|
||||
@ -214,21 +218,21 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
|
||||
result: false
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears browser cookies.
|
||||
*/
|
||||
clearBrowserCookies(): void {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Toggles ignoring cache for each request. If <code>true</code>, cache will not be used.
|
||||
*/
|
||||
setCacheDisabled(params: inspectorCommandTypes.NetworkDomain.SetCacheDisabledMethodArguments): void {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads a resource in the context of a frame on the inspected page without cross origin checks.
|
||||
*/
|
||||
@ -245,7 +249,7 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
|
||||
status: 200
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static idSequence: number = 0;
|
||||
create(): Request {
|
||||
let id = (++NetworkDomainDebugger.idSequence).toString();
|
||||
@ -264,4 +268,4 @@ export class RuntimeDomainDebugger {
|
||||
compileScript(): { scriptId?: string, exceptionDetails?: Object } {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user