revert all non-build changes

This commit is contained in:
Simon Knott 2024-11-07 15:19:07 +01:00
parent c424ad6758
commit 814bf0d311
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
5 changed files with 7 additions and 18 deletions

View file

@ -134,14 +134,7 @@ export async function installRootRedirect(server: HttpServer, traceUrls: string[
for (const reporter of options.reporter || []) for (const reporter of options.reporter || [])
params.append('reporter', reporter); params.append('reporter', reporter);
let baseUrl = ''; const urlPath = `./trace/${options.webApp || 'index.html'}?${params.toString()}`;
if (process.env.PW_HMR === '1') {
params.set('testServerPort', '' + server.port());
baseUrl = 'http://localhost:44223'; // port is hardcoded in build.js
}
const urlPath = `${baseUrl}/trace/${options.webApp || 'index.html'}?${params.toString()}`;
server.routePath('/', (_, response) => { server.routePath('/', (_, response) => {
response.statusCode = 302; response.statusCode = 302;
response.setHeader('Location', urlPath); response.setHeader('Location', urlPath);

View file

@ -85,8 +85,7 @@ async function doFetch(event: FetchEvent): Promise<Response> {
// the https urls. // the https urls.
const isDeployedAsHttps = self.registration.scope.startsWith('https://'); const isDeployedAsHttps = self.registration.scope.startsWith('https://');
// test server runs on a different port in HMR mode, so we only look at the hostname if (request.url.startsWith(self.registration.scope)) {
if (new URL(request.url).hostname === new URL(self.registration.scope).hostname) {
const url = new URL(unwrapPopoutUrl(request.url)); const url = new URL(unwrapPopoutUrl(request.url));
const relativePath = url.pathname.substring(scopePath.length - 1); const relativePath = url.pathname.substring(scopePath.length - 1);
if (relativePath === '/ping') { if (relativePath === '/ping') {

View file

@ -26,7 +26,6 @@ import type { StackFrame } from '@protocol/channels';
import { CopyToClipboard } from './copyToClipboard'; import { CopyToClipboard } from './copyToClipboard';
import { ToolbarButton } from '@web/components/toolbarButton'; import { ToolbarButton } from '@web/components/toolbarButton';
import { Toolbar } from '@web/components/toolbar'; import { Toolbar } from '@web/components/toolbar';
import { filePathToTraceURL } from './uiModeTraceView';
export const SourceTab: React.FunctionComponent<{ export const SourceTab: React.FunctionComponent<{
stack?: StackFrame[], stack?: StackFrame[],
@ -74,7 +73,7 @@ export const SourceTab: React.FunctionComponent<{
try { try {
let response = await fetch(`sha1/src@${sha1}.txt`); let response = await fetch(`sha1/src@${sha1}.txt`);
if (response.status === 404) if (response.status === 404)
response = await fetch(filePathToTraceURL(file)); response = await fetch(`file?path=${encodeURIComponent(file)}`);
if (response.status >= 400) if (response.status >= 400)
source.content = `<Unable to read "${file}">`; source.content = `<Unable to read "${file}">`;
else else

View file

@ -24,7 +24,6 @@ import type { ContextEntry } from '../types/entries';
import type { SourceLocation } from './modelUtil'; import type { SourceLocation } from './modelUtil';
import { MultiTraceModel } from './modelUtil'; import { MultiTraceModel } from './modelUtil';
import { Workbench } from './workbench'; import { Workbench } from './workbench';
import { testServerBaseURL } from './uiModeView';
export const TraceView: React.FC<{ export const TraceView: React.FC<{
item: { treeItem?: TreeItem, testFile?: SourceLocation, testCase?: reporterTypes.TestCase }, item: { treeItem?: TreeItem, testFile?: SourceLocation, testCase?: reporterTypes.TestCase },
@ -127,7 +126,7 @@ function formatUrl(traceURL: URL) {
} }
export function filePathToTraceURL(path: string) { export function filePathToTraceURL(path: string) {
const url = new URL('file', testServerBaseURL); const url = new URL('file', location.href);
url.searchParams.set('path', path); url.searchParams.set('path', path);
return url; return url;
} }

View file

@ -46,10 +46,9 @@ const xtermDataSource: XtermDataSource = {
resize: () => {}, resize: () => {},
}; };
export const testServerBaseURL = new URL(window.location.href); const searchParams = new URLSearchParams(window.location.search);
const searchParams = testServerBaseURL.searchParams; const guid = searchParams.get('ws');
testServerBaseURL.port = searchParams.get('testServerPort') ?? testServerBaseURL.port; const wsURL = new URL(`../${guid}`, window.location.toString());
const wsURL = new URL(`/${searchParams.get('ws')}`, testServerBaseURL);
wsURL.protocol = (window.location.protocol === 'https:' ? 'wss:' : 'ws:'); wsURL.protocol = (window.location.protocol === 'https:' ? 'wss:' : 'ws:');
const queryParams = { const queryParams = {
args: searchParams.getAll('arg'), args: searchParams.getAll('arg'),