Skip to content
Open
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
2 changes: 1 addition & 1 deletion packages/playwright-core/src/tools/backend/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class Response {
addSection('Ran Playwright code', this._code, 'js');

// Render tab titles upon changes or when more than one tab.
const tabSnapshot = this._context.currentTab() ? await this._context.currentTabOrDie().captureSnapshot(this._includeSnapshotRoot, this._includeSnapshotDepth, this._includeSnapshotBoxes, this._clientWorkspace) : undefined;
const tabSnapshot = this._context.currentTab() ? await this._context.currentTabOrDie().captureSnapshot(this._includeSnapshotRoot, this._includeSnapshotDepth, this._includeSnapshotBoxes, this._clientWorkspace, this._includeSnapshot !== 'none') : undefined;
const tabHeaders = await Promise.all(this._context.tabs().map(tab => tab.headerSnapshot()));
if (this._includeSnapshot !== 'none' || tabHeaders.some(header => header.changed)) {
if (tabHeaders.length !== 1)
Expand Down
34 changes: 23 additions & 11 deletions packages/playwright-core/src/tools/backend/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,19 +406,31 @@ export class Tab extends EventEmitter<TabEventsInterface> {
this._requests.length = 0;
}

async captureSnapshot(root: playwright.Locator | undefined, depth: number | undefined, boxes: boolean | undefined, relativeTo: string | undefined): Promise<TabSnapshot> {
async captureSnapshot(root: playwright.Locator | undefined, depth: number | undefined, boxes: boolean | undefined, relativeTo: string | undefined, includeAria: boolean = true): Promise<TabSnapshot> {
await this._initializedPromise;
let tabSnapshot: TabSnapshot | undefined;
const modalStates = await this._raceAgainstModalStates(async () => {
const ariaSnapshot = root
? await root.ariaSnapshot({ mode: 'ai', depth, boxes })
: await this.page.ariaSnapshot({ mode: 'ai', depth, boxes });
tabSnapshot = {
ariaSnapshot,
modalStates: [],
events: [],
};
});
let modalStates: ModalState[] = [];
if (includeAria) {
modalStates = await this._raceAgainstModalStates(async () => {
const ariaSnapshot = root
? await root.ariaSnapshot({ mode: 'ai', depth, boxes })
: await this.page.ariaSnapshot({ mode: 'ai', depth, boxes });
tabSnapshot = {
ariaSnapshot,
modalStates: [],
events: [],
};
});
} else if (this.modalStates().length) {
// Matches the aria path's modal fallback below, without the race: there

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't welcome low snr comments, coding agents are stubborn at not listening to our claude.md though.

// is no tree walk for a modal to interrupt.
modalStates = this.modalStates();
} else {
// The caller will not render the aria snapshot, so skip the accessibility
// tree walk, which dominates response latency on heavy pages. Console and
// events are still reported via the shared tail below.
tabSnapshot = { ariaSnapshot: '', modalStates: [], events: [] };
}
if (tabSnapshot) {
tabSnapshot.consoleLink = await this._consoleLog.take(relativeTo);
tabSnapshot.events = this._recentEventEntries;
Expand Down
Loading