Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/server/trace/recorder/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { CallMetadata, InstrumentationListener, SdkObject } from '../../instrume
import { Page } from '../../page';
import * as trace from '../common/traceEvents';
import { TraceSnapshotter } from './traceSnapshotter';
import { Dialog } from '../../dialog';

export type TracerOptions = {
name?: string;
Expand Down Expand Up @@ -128,6 +129,13 @@ export class Tracing implements InstrumentationListener {
return;
if (!this._snapshotter.started())
return;

if (sdkObject instanceof Dialog && name === 'before') {
// A call on the dialog is going to dismiss it and resume the evaluation.
// We can't be capturing the snapshot before dismiss action is performed.
return;
}

const snapshotName = `${name}@${metadata.id}`;
metadata.snapshots.push({ title: name, snapshotName });
await this._snapshotter!.captureSnapshot(sdkObject.attribution.page, snapshotName, element);
Expand Down
15 changes: 15 additions & 0 deletions tests/tracing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ test('should collect two traces', async ({ context, page, server }, testInfo) =>
}
});

test('should not stall on dialogs', async ({ page, context, server }) => {
await context.tracing.start({ screenshots: true, snapshots: true });
await page.goto(server.EMPTY_PAGE);

page.on('dialog', async dialog => {
await dialog.accept();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to catch this promise and await it? I am worried that dialog.accept will race with context.close and throw an unhandled promise rejection.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we are ok since the following call to confirm is blocking and is serialized with the accept ack.

});

await page.evaluate(() => {
confirm('are you sure');
});
await context.tracing.stop();
});


for (const params of [
{
id: 'fit',
Expand Down