Skip to content

Commit 182a71f

Browse files
cherry-pick(#23695): chore: miscellaneous trace viewer fixes
- properly annotate continued requests - nest `attach` steps inside the related `expect` step - fix primary-id-to-non-primary-id mapping - make sure images in trace are not draggable Fixes #23693 --------- Signed-off-by: Andrey Lushnikov <aslushnikov@gmail.com> Co-authored-by: Max Schmitt <max@schmitt.mx>
1 parent ba20378 commit 182a71f

File tree

11 files changed

+16
-13
lines changed

11 files changed

+16
-13
lines changed

packages/playwright-core/src/server/chromium/crServiceWorker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export class CRServiceWorker extends Worker {
114114
const r = new network.Route(request, route);
115115
if (this._browserContext._requestInterceptor?.(r, request))
116116
return;
117-
r.continue();
117+
r.continue({ isFallback: true });
118118
}
119119
}
120120

packages/playwright-core/src/server/frames.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export class FrameManager {
294294
frame.setPendingDocument({ documentId: request._documentId, request });
295295
if (request._isFavicon) {
296296
if (route)
297-
route.continue(request, {});
297+
route.continue(request, { isFallback: true });
298298
return;
299299
}
300300
this._page.emitOnContext(BrowserContext.Events.Request, request);
@@ -306,7 +306,7 @@ export class FrameManager {
306306
return;
307307
if (this._page._browserContext._requestInterceptor?.(r, request))
308308
return;
309-
r.continue();
309+
r.continue({ isFallback: true });
310310
}
311311
}
312312

packages/playwright-core/src/server/network.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export class Route extends SdkObject {
313313
headers.push({ name: 'vary', value: 'Origin' });
314314
}
315315

316-
async continue(overrides: types.NormalizedContinueOverrides = {}) {
316+
async continue(overrides: types.NormalizedContinueOverrides) {
317317
this._startHandling();
318318
if (overrides.url) {
319319
const newUrl = new URL(overrides.url);

packages/playwright-core/src/server/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export type NormalizedContinueOverrides = {
146146
method?: string,
147147
headers?: HeadersArray,
148148
postData?: Buffer,
149-
isFallback?: boolean,
149+
isFallback: boolean,
150150
};
151151

152152
export type EmulatedSize = { viewport: Size, screen: Size };

packages/playwright-test/src/worker/testInfo.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ export class TestInfoImpl implements TestInfo {
238238
const visit = (step: TestStepInternal) => {
239239
// Never nest into under another lax element, it could be a series
240240
// of no-reply actions, ala page.continue().
241-
if (!step.endWallTime && step.category === data.category && !step.laxParent)
241+
const canNest = step.category === data.category || step.category === 'expect' && data.category === 'attach';
242+
if (!step.endWallTime && canNest && !step.laxParent)
242243
parentStep = step;
243244
step.steps.forEach(visit);
244245
};
@@ -352,6 +353,7 @@ export class TestInfoImpl implements TestInfo {
352353
title: `attach "${name}"`,
353354
category: 'attach',
354355
wallTime: Date.now(),
356+
laxParent: true,
355357
});
356358
this._attachWithoutStep(attachment);
357359
step.complete({});

packages/trace-viewer/src/ui/attachmentsTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const AttachmentsTab: React.FunctionComponent<{
4545
{screenshots.size ? <div className='attachments-section'>Screenshots</div> : undefined}
4646
{[...screenshots].map((a, i) => {
4747
return <div className='attachment-item' key={`screenshot-${i}`}>
48-
<div><img src={attachmentURL(traceUrl, a)} /></div>
48+
<div><img draggable='false' src={attachmentURL(traceUrl, a)} /></div>
4949
<div><a target='_blank' href={attachmentURL(traceUrl, a)}>{a.name}</a></div>
5050
</div>;
5151
})}

packages/trace-viewer/src/ui/modelUtil.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ function mergeActions(contexts: ContextEntry[]) {
138138
existing.parentId = nonPrimaryIdToPrimaryId.get(action.parentId) ?? action.parentId;
139139
continue;
140140
}
141+
if (action.parentId)
142+
action.parentId = nonPrimaryIdToPrimaryId.get(action.parentId) ?? action.parentId;
141143
map.set(key, { ...action, context });
142144
}
143145
}

packages/trace-viewer/src/ui/networkResourceDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const NetworkResourceDetails: React.FunctionComponent<{
103103
{resource.request.postData ? <div className='network-request-body'>{formatBody(requestBody, requestContentType)}</div> : ''}
104104
<div className='network-request-details-header'>Response Body</div>
105105
{!resource.response.content._sha1 ? <div className='network-request-response-body'>Response body is not available for this request.</div> : ''}
106-
{responseBody !== null && responseBody.dataUrl ? <img src={responseBody.dataUrl} /> : ''}
106+
{responseBody !== null && responseBody.dataUrl ? <img draggable='false' src={responseBody.dataUrl} /> : ''}
107107
{responseBody !== null && responseBody.text ? <div className='network-request-response-body'>{formatBody(responseBody.text, resource.response.content.mimeType)}</div> : ''}
108108
</div>
109109
</Expandable>

packages/web/src/components/imageDiffView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ const ImageWithSize: React.FunctionComponent<{
161161
<span style={{ flex: 'none', margin: '0 5px' }}>x</span>
162162
<span style={{ flex: '1 1 0', textAlign: 'start' }}>{ size ? size.height : ''}</span>
163163
</div>
164-
<img src={src} onLoad={() => {
164+
<img draggable='false' src={src} onLoad={() => {
165165
onLoad?.();
166166
if (ref.current)
167167
setSize({ width: ref.current.naturalWidth, height: ref.current.naturalHeight });

tests/library/trace-viewer.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ test('should have network request overrides', async ({ page, server, runAndTrace
229229
await traceViewer.selectAction('http://localhost');
230230
await traceViewer.showNetworkTab();
231231
await expect(traceViewer.networkRequests).toContainText([/200GET\/frame.htmltext\/html/]);
232-
await expect(traceViewer.networkRequests).toContainText([/abort.*style.cssx-unknown/]);
232+
await expect(traceViewer.networkRequests).toContainText([/aborted.*style.cssx-unknown/]);
233+
await expect(traceViewer.networkRequests).not.toContainText([/continued/]);
233234
});
234235

235236
test('should have network request overrides 2', async ({ page, server, runAndTrace }) => {
@@ -240,7 +241,7 @@ test('should have network request overrides 2', async ({ page, server, runAndTra
240241
await traceViewer.selectAction('http://localhost');
241242
await traceViewer.showNetworkTab();
242243
await expect(traceViewer.networkRequests).toContainText([/200GET\/frame.htmltext\/html/]);
243-
await expect(traceViewer.networkRequests).toContainText([/continue.*script.jsapplication\/javascript/]);
244+
await expect(traceViewer.networkRequests).toContainText([/continued.*script.jsapplication\/javascript/]);
244245
});
245246

246247
test('should show snapshot URL', async ({ page, runAndTrace, server }) => {

0 commit comments

Comments
 (0)