Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Fix #118 - send scriptLoaded events
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Jul 26, 2017
1 parent 11ff523 commit e086511
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/chrome/chromeDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
private _columnBreakpointsEnabled: boolean;

private _smartStepCount = 0;
private _scriptEventsBeforeInitializedEventFired: ScriptEvent[] = [];
private _earlyScripts: Crdp.Debugger.ScriptParsedEvent[] = [];

private _initialSourceMapsP = Promise.resolve();

Expand Down Expand Up @@ -371,12 +371,6 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
}
}

private sendScriptEventsBeforeInitializedEventFired(): void {
this._scriptEventsBeforeInitializedEventFired.forEach(element => {
this._session.sendEvent(element);
});
}

/**
* This event tells the client to begin sending setBP requests, etc. Some consumers need to override this
* to send it at a later time of their choosing.
Expand All @@ -387,8 +381,9 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
this._initialSourceMapsP.then(() => {
this._session.sendEvent(new InitializedEvent());
this._initialSourceMapsP = null;
this.sendScriptEventsBeforeInitializedEventFired();
this._scriptEventsBeforeInitializedEventFired = null;

this._earlyScripts.forEach(script => this.sendScriptEvents(script));
this._earlyScripts = null;
});
}
}
Expand Down Expand Up @@ -569,14 +564,23 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
this._initialSourceMapsP = <Promise<any>>Promise.all([this._initialSourceMapsP, sourceMapsP]);
}

this.scriptToScriptEvent(script)
.then((scriptEvent: ScriptEvent) => {
if (this._scriptEventsBeforeInitializedEventFired !== null) {
this._scriptEventsBeforeInitializedEventFired.push(scriptEvent);
} else {
this._session.sendEvent(scriptEvent);
}
});
if (this._earlyScripts) {
this._earlyScripts.push(script);
} else {
this.sendScriptEvents(script);
}
}

/**
* Send a 'script' and 'scriptLoaded' event... these will probably be consolidated in the future.
*/
private async sendScriptEvents(script: Crdp.Debugger.ScriptParsedEvent): Promise<void> {
const scriptEvent = await this.scriptToScriptEvent(script);
this._session.sendEvent(scriptEvent);

const properlyCasedScriptUrl = this.fixPathCasing(script.url);
const displayPath = this.realPathToDisplayPath(properlyCasedScriptUrl);
this._session.sendEvent(new Event('scriptLoaded', { path: displayPath }));
}

private async resolveSkipFiles(script: CrdpScript, mappedUrl: string, sources: string[], toggling?: boolean): Promise<void> {
Expand Down

0 comments on commit e086511

Please sign in to comment.