mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +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 = {};
|
this.commands = {};
|
||||||
|
|
||||||
attachCSSInspectorCommandCallbacks(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 {
|
get enabled(): boolean {
|
||||||
|
@ -20,6 +20,10 @@ export class DOMDomainDebugger implements inspectorCommandTypes.DOMDomain.DOMDom
|
|||||||
|
|
||||||
attachDOMInspectorEventCallbacks(this.events);
|
attachDOMInspectorEventCallbacks(this.events);
|
||||||
attachDOMInspectorCommandCallbacks(this.commands);
|
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 {
|
get enabled(): boolean {
|
||||||
|
@ -64,7 +64,7 @@ export class Request {
|
|||||||
this._resourceType = "Other";
|
this._resourceType = "Other";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._mimeType = value;
|
this._mimeType = value;
|
||||||
|
|
||||||
var resourceType = "Other";
|
var resourceType = "Other";
|
||||||
@ -112,19 +112,19 @@ export class Request {
|
|||||||
this._resourceType = value;
|
this._resourceType = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public responseReceived(response: inspectorCommandTypes.NetworkDomain.Response): void {
|
public responseReceived(response: inspectorCommandTypes.NetworkDomain.Response): void {
|
||||||
if (this._networkDomainDebugger.enabled) {
|
if (this._networkDomainDebugger.enabled) {
|
||||||
this._networkDomainDebugger.events.responseReceived(this.requestID, frameId, loaderId, __inspectorTimestamp(), <any>this.resourceType, response);
|
this._networkDomainDebugger.events.responseReceived(this.requestID, frameId, loaderId, __inspectorTimestamp(), <any>this.resourceType, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadingFinished(): void {
|
public loadingFinished(): void {
|
||||||
if (this._networkDomainDebugger.enabled) {
|
if (this._networkDomainDebugger.enabled) {
|
||||||
this._networkDomainDebugger.events.loadingFinished(this.requestID, __inspectorTimestamp());
|
this._networkDomainDebugger.events.loadingFinished(this.requestID, __inspectorTimestamp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public requestWillBeSent(request: inspectorCommandTypes.NetworkDomain.Request): void {
|
public requestWillBeSent(request: inspectorCommandTypes.NetworkDomain.Request): void {
|
||||||
if (this._networkDomainDebugger.enabled) {
|
if (this._networkDomainDebugger.enabled) {
|
||||||
this._networkDomainDebugger.events.requestWillBeSent(this.requestID, frameId, loaderId, request.url, request, __inspectorTimestamp(), { type: "Script" });
|
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 {
|
export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomain.NetworkDomainDispatcher {
|
||||||
private _enabled: boolean;
|
private _enabled: boolean;
|
||||||
public events: inspectorCommandTypes.NetworkDomain.NetworkFrontend;
|
public events: inspectorCommandTypes.NetworkDomain.NetworkFrontend;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.events = new inspectorCommands.NetworkDomain.NetworkFrontend();
|
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 {
|
get enabled(): boolean {
|
||||||
@ -156,7 +160,7 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
|
|||||||
}
|
}
|
||||||
this._enabled = true;
|
this._enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables network tracking, prevents network events from being sent to the client.
|
* 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;
|
this._enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies whether to always send extra HTTP headers with the requests from this page.
|
* Specifies whether to always send extra HTTP headers with the requests from this page.
|
||||||
*/
|
*/
|
||||||
setExtraHTTPHeaders(params: inspectorCommandTypes.NetworkDomain.SetExtraHTTPHeadersMethodArguments): void {
|
setExtraHTTPHeaders(params: inspectorCommandTypes.NetworkDomain.SetExtraHTTPHeadersMethodArguments): void {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns content served for the given request.
|
* Returns content served for the given request.
|
||||||
*/
|
*/
|
||||||
@ -187,9 +191,9 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
|
|||||||
body: body,
|
body: body,
|
||||||
base64Encoded: !resource_data.hasTextContent
|
base64Encoded: !resource_data.hasTextContent
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells whether clearing browser cache is supported.
|
* Tells whether clearing browser cache is supported.
|
||||||
*/
|
*/
|
||||||
@ -198,14 +202,14 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
|
|||||||
result: false
|
result: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears browser cache.
|
* Clears browser cache.
|
||||||
*/
|
*/
|
||||||
clearBrowserCache(): void {
|
clearBrowserCache(): void {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells whether clearing browser cookies is supported.
|
* Tells whether clearing browser cookies is supported.
|
||||||
*/
|
*/
|
||||||
@ -214,21 +218,21 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
|
|||||||
result: false
|
result: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears browser cookies.
|
* Clears browser cookies.
|
||||||
*/
|
*/
|
||||||
clearBrowserCookies(): void {
|
clearBrowserCookies(): void {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles ignoring cache for each request. If <code>true</code>, cache will not be used.
|
* Toggles ignoring cache for each request. If <code>true</code>, cache will not be used.
|
||||||
*/
|
*/
|
||||||
setCacheDisabled(params: inspectorCommandTypes.NetworkDomain.SetCacheDisabledMethodArguments): void {
|
setCacheDisabled(params: inspectorCommandTypes.NetworkDomain.SetCacheDisabledMethodArguments): void {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a resource in the context of a frame on the inspected page without cross origin checks.
|
* 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
|
status: 200
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static idSequence: number = 0;
|
public static idSequence: number = 0;
|
||||||
create(): Request {
|
create(): Request {
|
||||||
let id = (++NetworkDomainDebugger.idSequence).toString();
|
let id = (++NetworkDomainDebugger.idSequence).toString();
|
||||||
@ -264,4 +268,4 @@ export class RuntimeDomainDebugger {
|
|||||||
compileScript(): { scriptId?: string, exceptionDetails?: Object } {
|
compileScript(): { scriptId?: string, exceptionDetails?: Object } {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user