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

Commit

Permalink
Merge pull request #610 from digeff/launch_timings_telemetry_master
Browse files Browse the repository at this point in the history
Now we report the times of the different tasks that happen until we launch and show the user page
  • Loading branch information
roblourens authored Mar 12, 2018
2 parents 843b5a1 + 6bd4981 commit 449d8e5
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 57 deletions.
142 changes: 91 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"license": "SEE LICENSE IN LICENSE.txt",
"dependencies": {
"vscode-chrome-debug-core": "^3.23.3",
"vscode-chrome-debug-core": "^3.23.4",
"vscode-debugadapter": "^1.27.0",
"vscode-nls": "^3.2.1"
},
Expand Down
22 changes: 18 additions & 4 deletions src/chromeDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as os from 'os';
import * as fs from 'fs';
import * as path from 'path';

import {ChromeDebugAdapter as CoreDebugAdapter, logger, utils as coreUtils, ISourceMapPathOverrides} from 'vscode-chrome-debug-core';
import {ChromeDebugAdapter as CoreDebugAdapter, logger, utils as coreUtils, ISourceMapPathOverrides, ChromeDebugSession} from 'vscode-chrome-debug-core';
import {spawn, ChildProcess, fork, execSync} from 'child_process';
import {Crdp} from 'vscode-chrome-debug-core';
import {DebugProtocol} from 'vscode-debugprotocol';
Expand Down Expand Up @@ -130,13 +130,26 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
return super.attach(args);
}

public configurationDone(): Promise<void> {
protected hookConnectionEvents(): void {
super.hookConnectionEvents();
this.chrome.Page.onFrameNavigated(params => this.onFrameNavigated(params));
}

protected onFrameNavigated(params: Crdp.Page.FrameNavigatedEvent): void {
if (params.frame.url === this._userRequestedUrl) {
// Chrome started to navigate to the user's requested url
this.events.emit(ChromeDebugSession.FinishedStartingUpEventName);
}
}

public async configurationDone(): Promise<void> {
if (this._userRequestedUrl) {
// 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 });
this.chrome.Page.navigate({ url: this._userRequestedUrl }).then(() =>
this.events.emitMilestoneReached("RequestedNavigateToUserPage"));
}

return super.configurationDone();
await super.configurationDone();
}

public commonArgs(args: ICommonRequestArgs): void {
Expand Down Expand Up @@ -236,6 +249,7 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
}

private spawnChrome(chromePath: string, chromeArgs: string[], env: {[key: string]: string}, cwd: string, usingRuntimeExecutable: boolean): ChildProcess {
this.events.emitStepStarted("LaunchTarget.LaunchExe");
if (coreUtils.getPlatform() === coreUtils.Platform.Windows && !usingRuntimeExecutable) {
const options = {
execArgv: [],
Expand Down
4 changes: 4 additions & 0 deletions test/chromeDebugAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as testUtils from './testUtils';

/** Not mocked - use for type only */
import {ChromeDebugAdapter as _ChromeDebugAdapter} from '../src/chromeDebugAdapter';
import { StepProgressEventsEmitter } from 'vscode-chrome-debug-core/out/src/executionTimingsReporter';

class MockChromeDebugSession {
public sendEvent(event: DebugProtocol.Event): void {
Expand Down Expand Up @@ -55,6 +56,9 @@ suite('ChromeDebugAdapter', () => {
.returns(() => Promise.resolve());
mockChromeConnection
.setup(x => x.onClose(It.isAny()));
mockChromeConnection
.setup(x => x.events)
.returns(x => new StepProgressEventsEmitter());

// Instantiate the ChromeDebugAdapter, injecting the mock ChromeConnection
const cDAClass: typeof _ChromeDebugAdapter = require(MODULE_UNDER_TEST).ChromeDebugAdapter;
Expand Down
3 changes: 2 additions & 1 deletion test/debugProtocolMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ function getInspectorStubs(mockEventEmitter) {

function getPageStubs() {
return {
enable() { }
enable() { },
onFrameNavigated() { }
}
}

Expand Down

0 comments on commit 449d8e5

Please sign in to comment.