Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
Adding a landing page to support hitting breakpoints on load
Browse files Browse the repository at this point in the history
  • Loading branch information
Raghav Katyal committed Oct 23, 2017
1 parent 50fd20d commit 9af35a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/chromeDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
private _chromeProc: ChildProcess;
private _overlayHelper: utils.DebounceHelper;
private _chromePID: number;
private _userRequestedUrl: string;

public initialize(args: DebugProtocol.InitializeRequestArguments): DebugProtocol.Capabilities {
this._overlayHelper = new utils.DebounceHelper(/*timeoutMs=*/200);
Expand Down Expand Up @@ -88,6 +89,10 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
}

if (launchUrl) {
// We store the launch file/url provided and temporarily launch and attach to about:blank page. Once we receive configurationDone() event, we redirect the page to this file/url
// This is done to facilitate hitting breakpoints on load
this._userRequestedUrl = launchUrl;
launchUrl = "about:blank";
chromeArgs.push(launchUrl);
}

Expand All @@ -111,6 +116,12 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
return super.attach(args);
}

public configurationDone(): Promise<void> {
// This means all the setBreakpoints requests have been completed. So we can navigate to the original file/url.
this.chrome.Page.navigate({url: this._userRequestedUrl});
return super.configurationDone();
}

public commonArgs(args: ICommonRequestArgs): void {
if (!args.webRoot && args.pathMapping && args.pathMapping['/']) {
// Adapt pathMapping['/'] as the webRoot when not set, since webRoot is explicitly used in many places
Expand Down
2 changes: 1 addition & 1 deletion test/chromeDebugAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ suite('ChromeDebugAdapter', () => {
function spawn(chromePath: string, args: string[]): any {
assert(chromePath.toLowerCase().indexOf('chrome') >= 0);
assert(args.indexOf('--remote-debugging-port=9222') >= 0);
assert(args.indexOf('file:///c:/path%20with%20space/index.html') >= 0);
assert(args.indexOf('about:blank') >= 0); // We now launch to about:blank first and then redirect later
assert(args.indexOf('abc') >= 0);
assert(args.indexOf('def') >= 0);
spawnCalled = true;
Expand Down

0 comments on commit 9af35a7

Please sign in to comment.