From cbce7cbdec363809db7818387993a3355d780117 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Thu, 10 Jun 2021 22:24:04 -0700 Subject: [PATCH] fix(tracing): do not stall on dialogs (#7059) --- src/server/trace/recorder/tracing.ts | 8 ++++++++ tests/tracing.spec.ts | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/server/trace/recorder/tracing.ts b/src/server/trace/recorder/tracing.ts index 5b37f9add6d40..9d9e5f6ae4f91 100644 --- a/src/server/trace/recorder/tracing.ts +++ b/src/server/trace/recorder/tracing.ts @@ -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; @@ -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); diff --git a/tests/tracing.spec.ts b/tests/tracing.spec.ts index f97af0df615aa..8a0bceea545a3 100644 --- a/tests/tracing.spec.ts +++ b/tests/tracing.spec.ts @@ -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(); + }); + + await page.evaluate(() => { + confirm('are you sure'); + }); + await context.tracing.stop(); +}); + + for (const params of [ { id: 'fit',