minimise changes

This commit is contained in:
Simon Knott 2024-10-29 13:46:25 +01:00
parent 1d17703320
commit a92dcb1cd1
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
3 changed files with 9 additions and 32 deletions

View file

@ -1,28 +0,0 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// needs to work both in window and service worker, so we use `self`
const searchParams = new URLSearchParams(self.location.search); // see `installRootRedirect`
const testServerBaseURL = new URL(self.location.href);
const testServerPort = searchParams.get('testServerPort');
if (testServerPort)
testServerBaseURL.port = testServerPort;
const testServerWebSocketURL = new URL(`/${searchParams.get('ws')}`, testServerBaseURL);
testServerWebSocketURL.protocol = (self.location.protocol === 'https:' ? 'wss:' : 'ws:');
export { searchParams, testServerBaseURL, testServerWebSocketURL };

View file

@ -24,7 +24,7 @@ import type { ContextEntry } from '../types/entries';
import type { SourceLocation } from './modelUtil';
import { MultiTraceModel } from './modelUtil';
import { Workbench } from './workbench';
import { testServerBaseURL } from '../searchParams';
import { testServerBaseURL } from './uiModeView';
export const TraceView: React.FC<{
item: { treeItem?: TreeItem, testFile?: SourceLocation, testCase?: reporterTypes.TestCase },
@ -120,7 +120,7 @@ async function loadSingleTraceFile(tracePathOrURL: URL): Promise<MultiTraceModel
function formatUrl(tracePathOrURL: URL) {
if (tracePathOrURL.protocol === 'file:') {
const url = new URL('/trace/file', location.href);
const url = new URL('/trace/file', testServerBaseURL);
url.searchParams.set('path', tracePathOrURL.pathname);
return url;
}

View file

@ -37,7 +37,6 @@ import { FiltersView } from './uiModeFiltersView';
import { TestListView } from './uiModeTestListView';
import { TraceView } from './uiModeTraceView';
import { SettingsView } from './settingsView';
import { testServerWebSocketURL, searchParams } from '../searchParams';
let xtermSize = { cols: 80, rows: 24 };
const xtermDataSource: XtermDataSource = {
@ -47,6 +46,12 @@ const xtermDataSource: XtermDataSource = {
resize: () => {},
};
const searchParams = new URLSearchParams(window.location.search);
export const testServerBaseURL = new URL(self.location.href);
testServerBaseURL.port = searchParams.get('testServerPort') ?? testServerBaseURL.port;
const wsURL = new URL(`/${searchParams.get('ws')}`, testServerBaseURL);
wsURL.protocol = (window.location.protocol === 'https:' ? 'wss:' : 'ws:');
const queryParams = {
args: searchParams.getAll('arg'),
grep: searchParams.get('grep') || undefined,
@ -106,7 +111,7 @@ export const UIModeView: React.FC<{}> = ({
const inputRef = React.useRef<HTMLInputElement>(null);
const reloadTests = React.useCallback(() => {
setTestServerConnection(new TestServerConnection(new WebSocketTestServerTransport(testServerWebSocketURL)));
setTestServerConnection(new TestServerConnection(new WebSocketTestServerTransport(wsURL)));
}, []);
// Load tests on startup.