Skip to content

Commit b2ccfc3

Browse files
authored
chore(trace-viewer): support opening a source location in embedded trace viewer (#32175)
Related: microsoft/playwright-vscode#513
1 parent e7b7c71 commit b2ccfc3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@ import { MultiTraceModel } from './modelUtil';
2020
import './embeddedWorkbenchLoader.css';
2121
import { Workbench } from './workbench';
2222
import { currentTheme, toggleTheme } from '@web/theme';
23+
import type { SourceLocation } from './modelUtil';
2324

2425
function openPage(url: string, target?: string) {
2526
if (url)
26-
window.parent!.postMessage({ command: 'openExternal', params: { url, target } }, '*');
27+
window.parent!.postMessage({ method: 'openExternal', params: { url, target } }, '*');
28+
}
29+
30+
function openSourceLocation({ file, line, column }: SourceLocation) {
31+
window.parent!.postMessage({ method: 'openSourceLocation', params: { file, line, column } }, '*');
2732
}
2833

2934
export const EmbeddedWorkbenchLoader: React.FunctionComponent = () => {
@@ -86,7 +91,7 @@ export const EmbeddedWorkbenchLoader: React.FunctionComponent = () => {
8691
<div className='progress'>
8792
<div className='inner-progress' style={{ width: progress.total ? (100 * progress.done / progress.total) + '%' : 0 }}></div>
8893
</div>
89-
<Workbench model={model} openPage={openPage} showSettings />
94+
<Workbench model={model} openPage={openPage} onOpenExternally={openSourceLocation} showSettings />
9095
{!traceURLs.length && <div className='empty-state'>
9196
<div className='title'>Select test to see the trace</div>
9297
</div>}

0 commit comments

Comments
 (0)