mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat(uimode) uses relative paths to establish websocket connection (#29617)
This commit is contained in:
parent
56028269bb
commit
bd8d044433
@ -20,7 +20,9 @@ const callbacks = new Map<number, { resolve: (arg: any) => void, reject: (arg: E
|
|||||||
|
|
||||||
export async function connect(options: { onEvent: (method: string, params?: any) => void, onClose: () => void }): Promise<(method: string, params?: any) => Promise<any>> {
|
export async function connect(options: { onEvent: (method: string, params?: any) => void, onClose: () => void }): Promise<(method: string, params?: any) => Promise<any>> {
|
||||||
const guid = new URLSearchParams(window.location.search).get('ws');
|
const guid = new URLSearchParams(window.location.search).get('ws');
|
||||||
const ws = new WebSocket(`${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${window.location.hostname}:${window.location.port}/${guid}`);
|
const wsURL = new URL(`../${guid}`, window.location.toString());
|
||||||
|
wsURL.protocol = (window.location.protocol === 'https:' ? 'wss:' : 'ws:');
|
||||||
|
const ws = new WebSocket(wsURL);
|
||||||
await new Promise(f => ws.addEventListener('open', f));
|
await new Promise(f => ws.addEventListener('open', f));
|
||||||
ws.addEventListener('close', options.onClose);
|
ws.addEventListener('close', options.onClose);
|
||||||
ws.addEventListener('message', event => {
|
ws.addEventListener('message', event => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user