From a92dcb1cd18bee2a5226f33ba547df3e59e816e4 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Tue, 29 Oct 2024 13:46:25 +0100 Subject: [PATCH] minimise changes --- packages/trace-viewer/src/searchParams.ts | 28 ------------------- .../trace-viewer/src/ui/uiModeTraceView.tsx | 4 +-- packages/trace-viewer/src/ui/uiModeView.tsx | 9 ++++-- 3 files changed, 9 insertions(+), 32 deletions(-) delete mode 100644 packages/trace-viewer/src/searchParams.ts diff --git a/packages/trace-viewer/src/searchParams.ts b/packages/trace-viewer/src/searchParams.ts deleted file mode 100644 index 1ad9f4482f..0000000000 --- a/packages/trace-viewer/src/searchParams.ts +++ /dev/null @@ -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 }; \ No newline at end of file diff --git a/packages/trace-viewer/src/ui/uiModeTraceView.tsx b/packages/trace-viewer/src/ui/uiModeTraceView.tsx index de6fde259d..5655ffbb9a 100644 --- a/packages/trace-viewer/src/ui/uiModeTraceView.tsx +++ b/packages/trace-viewer/src/ui/uiModeTraceView.tsx @@ -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 {}, }; +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(null); const reloadTests = React.useCallback(() => { - setTestServerConnection(new TestServerConnection(new WebSocketTestServerTransport(testServerWebSocketURL))); + setTestServerConnection(new TestServerConnection(new WebSocketTestServerTransport(wsURL))); }, []); // Load tests on startup.