fix(html): allow serving html report w/ traces off relative path (#9668)

Fixes #9652
This commit is contained in:
Pavel Feldman 2021-10-20 16:52:13 -08:00 committed by GitHub
parent 962525b592
commit f853176df3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 14 deletions

View File

@ -188,7 +188,7 @@ const TestResultView: React.FC<{
{!!traces.length && <Chip header='Traces'> {!!traces.length && <Chip header='Traces'>
{traces.map((a, i) => <div key={`trace-${i}`}> {traces.map((a, i) => <div key={`trace-${i}`}>
<a href={`trace/index.html?trace=${window.location.origin}/` + a.path}> <a href={`trace/index.html?trace=${new URL(a.path!, window.location.href)}`}>
<img src='trace.png' style={{ width: 192, height: 117, marginLeft: 20 }} /> <img src='trace.png' style={{ width: 192, height: 117, marginLeft: 20 }} />
</a> </a>
</div>)} </div>)}

View File

@ -19,9 +19,9 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" sizes="32x32" href="/trace/icon-32x32.png"> <link rel="icon" type="image/png" sizes="32x32" href="icon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/trace/icon-16x16.png"> <link rel="icon" type="image/png" sizes="16x16" href="icon-16x16.png">
<link rel="manifest" href="/trace/manifest.webmanifest"> <link rel="manifest" href="manifest.webmanifest">
<title>Playwright Trace Viewer</title> <title>Playwright Trace Viewer</title>
</head> </head>
<body> <body>

View File

@ -23,9 +23,7 @@ import '../common.css';
(async () => { (async () => {
applyTheme(); applyTheme();
navigator.serviceWorker.register('/trace/sw.bundle.js', { navigator.serviceWorker.register('sw.bundle.js');
scope: '/trace/'
});
if (!navigator.serviceWorker.controller) { if (!navigator.serviceWorker.controller) {
await new Promise<void>(f => { await new Promise<void>(f => {
navigator.serviceWorker.oncontrollerchange = () => f(); navigator.serviceWorker.oncontrollerchange = () => f();

View File

@ -2,28 +2,27 @@
"theme_color": "#000", "theme_color": "#000",
"background_color": "#fff", "background_color": "#fff",
"display": "browser", "display": "browser",
"scope": "/trace", "start_url": "index.html",
"start_url": "/trace/index.html",
"name": "Playwright Trace Viewer", "name": "Playwright Trace Viewer",
"short_name": "Trace Viewer", "short_name": "Trace Viewer",
"icons": [ "icons": [
{ {
"src": "/trace/icon-192x192.png", "src": "icon-192x192.png",
"sizes": "192x192", "sizes": "192x192",
"type": "image/png" "type": "image/png"
}, },
{ {
"src": "/trace/icon-256x256.png", "src": "icon-256x256.png",
"sizes": "256x256", "sizes": "256x256",
"type": "image/png" "type": "image/png"
}, },
{ {
"src": "/trace/icon-384x384.png", "src": "icon-384x384.png",
"sizes": "384x384", "sizes": "384x384",
"type": "image/png" "type": "image/png"
}, },
{ {
"src": "/trace/icon-512x512.png", "src": "icon-512x512.png",
"sizes": "512x512", "sizes": "512x512",
"type": "image/png" "type": "image/png"
} }

View File

@ -40,7 +40,7 @@ export const Workbench: React.FunctionComponent<{
React.useEffect(() => { React.useEffect(() => {
(async () => { (async () => {
if (traceURL) { if (traceURL) {
const contextEntry = (await fetch(`/trace/context?trace=${traceURL}`).then(response => response.json())) as ContextEntry; const contextEntry = (await fetch(`context?trace=${traceURL}`).then(response => response.json())) as ContextEntry;
modelUtil.indexModel(contextEntry); modelUtil.indexModel(contextEntry);
setContextEntry(contextEntry); setContextEntry(contextEntry);
} else { } else {