Merge pull request #513 from rakatyal/breakonload
Adding a landing page to support hitting breakpoints on load
This commit is contained in:
Коммит
95e5908e7a
|
@ -32,6 +32,8 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
|
|||
private _chromeProc: ChildProcess;
|
||||
private _overlayHelper: utils.DebounceHelper;
|
||||
private _chromePID: number;
|
||||
private _breakOnLoadActive = false;
|
||||
private _userRequestedUrl: string;
|
||||
|
||||
public initialize(args: DebugProtocol.InitializeRequestArguments): DebugProtocol.Capabilities {
|
||||
this._overlayHelper = new utils.DebounceHelper(/*timeoutMs=*/200);
|
||||
|
@ -91,6 +93,14 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
|
|||
}
|
||||
|
||||
if (launchUrl) {
|
||||
if (args.breakOnLoadStrategy !== 'none') {
|
||||
// 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";
|
||||
this._breakOnLoadActive = true;
|
||||
}
|
||||
|
||||
chromeArgs.push(launchUrl);
|
||||
}
|
||||
|
||||
|
@ -114,6 +124,14 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
|
|||
return super.attach(args);
|
||||
}
|
||||
|
||||
public configurationDone(): Promise<void> {
|
||||
if (this._breakOnLoadActive) {
|
||||
// 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
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче