Skip to content

Commit

Permalink
Fix linting error and update new cli command description
Browse files Browse the repository at this point in the history
  • Loading branch information
KS authored and KS committed Sep 12, 2023
1 parent 4242208 commit 31ac351
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
17 changes: 14 additions & 3 deletions lib/chrome/webdriver/chromium.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ export class Chromium {
await this.android.resetPowerUsage();
}

if (this.collectTracingEvents && !this.isTracing && this.options.chrome.timelineRecordingType !== 'custom' ) {
if (
this.collectTracingEvents &&
!this.isTracing &&
this.options.chrome.timelineRecordingType !== 'custom'
) {
this.isTracing = true;
return this.cdpClient.startTrace();
}
Expand All @@ -174,7 +178,11 @@ export class Chromium {
*/
async afterPageCompleteCheck(runner, index, url, alias) {
const result = { url, alias };
if (this.collectTracingEvents && this.isTracing && this.options.chrome.timelineRecordingType !== 'custom') {
if (
this.collectTracingEvents &&
this.isTracing &&
this.options.chrome.timelineRecordingType !== 'custom'
) {
// We are ready and can stop collecting events
this.isTracing = false;
this.events = await this.cdpClient.stopTrace();
Expand Down Expand Up @@ -334,7 +342,10 @@ export class Chromium {
await this.storageManager.gzip(filename, gzFilename, true);
}

if (this.collectTracingEvents && this.options.chrome.timelineRecordingType !== 'custom') {
if (
this.collectTracingEvents &&
this.options.chrome.timelineRecordingType !== 'custom'
) {
const trace = parse(this.events, result.url);
const name = this.options.enableProfileRun
? `trace-${index}-extra-run.json`
Expand Down
8 changes: 3 additions & 5 deletions lib/core/engine/command/chromeTrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ export class chromeTrace {
constructor(engineDelegate, index, options, result) {
this.engineDelegate = engineDelegate;
this.options = options;
// this.result = context.result;
this.result = result;
this.index = index;
}

async start() {
if (this.options.browser === 'chrome') {
if (this.options.chrome.timelineRecordingType === 'custom') {
Expand Down Expand Up @@ -97,7 +96,7 @@ export class chromeTrace {
}

if (!this.options.skipHar) {
for (let harRequest of this.hars[index - 1].log.entries) {
for (let harRequest of this.hars[this.index - 1].log.entries) {
if (renderBlockingInfo[harRequest.request.url]) {
harRequest._renderBlocking =
renderBlockingInfo[harRequest.request.url];
Expand All @@ -106,8 +105,7 @@ export class chromeTrace {
}

result.renderBlocking.requests = renderBlockingInfo;

}
}
} else {
throw new Error('Trace only works in Chrome');
}
Expand Down
7 changes: 1 addition & 6 deletions lib/core/engine/iteration.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,7 @@ export class Iteration {
engineDelegate,
options.browser
);
const trace = new chromeTrace(
engineDelegate,
index,
options,
result
);
const trace = new chromeTrace(engineDelegate, index, options, result);
const android = new Android(options);
const debug = new Debug(browser, options);
const commands = {
Expand Down
3 changes: 1 addition & 2 deletions lib/support/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ export function parseCommandLine() {
})
.option('chrome.timelineRecordingType', {
alias: 'chrome.traceRecordingType',
describe:
'Collect the timeline data. Drag and drop the JSON in your Chrome detvools timeline panel or check out the CPU metrics in the Browsertime.json',
describe: 'Expose the start/stop commands for the chrome trace',
default: 'pageload',
choices: ['pageload', 'custom'],
type: 'string',
Expand Down

0 comments on commit 31ac351

Please sign in to comment.