Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions packages/dev-middleware/src/__tests__/InspectorDebuggerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import until from 'wait-for-expect';
import WebSocket from 'ws';

export class DebuggerAgent {
_ws: ?WebSocket;
_readyPromise: Promise<void>;
#ws: ?WebSocket;
#readyPromise: Promise<void>;

constructor(url: string, signal?: AbortSignal) {
const ws = new WebSocket(url, {
// The mock server uses a self-signed certificate.
rejectUnauthorized: false,
});
this._ws = ws;
this.#ws = ws;
ws.on('message', data => {
this.__handle(JSON.parse(data.toString()));
});
Expand All @@ -37,7 +37,7 @@ export class DebuggerAgent {
this.close();
});
}
this._readyPromise = new Promise<void>((resolve, reject) => {
this.#readyPromise = new Promise<void>((resolve, reject) => {
ws.once('open', () => {
resolve();
});
Expand All @@ -50,29 +50,29 @@ export class DebuggerAgent {
__handle(message: JSONSerializable): void {}

send(message: JSONSerializable) {
if (!this._ws) {
if (!this.#ws) {
return;
}
this._ws.send(JSON.stringify(message));
this.#ws.send(JSON.stringify(message));
}

ready(): Promise<void> {
return this._readyPromise;
return this.#readyPromise;
}

close() {
if (!this._ws) {
if (!this.#ws) {
return;
}
try {
this._ws.terminate();
this.#ws.terminate();
} catch {}
this._ws = null;
this.#ws = null;
}

// $FlowIgnore[unsafe-getters-setters]
get socket(): WebSocket {
return nullthrows(this._ws);
return nullthrows(this.#ws);
}
}

Expand Down
24 changes: 12 additions & 12 deletions packages/dev-middleware/src/__tests__/InspectorDeviceUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import type {
import WebSocket from 'ws';

export class DeviceAgent {
_ws: ?WebSocket;
_readyPromise: Promise<void>;
#ws: ?WebSocket;
#readyPromise: Promise<void>;

constructor(url: string, signal?: AbortSignal) {
const ws = new WebSocket(url, {
// The mock server uses a self-signed certificate.
rejectUnauthorized: false,
});
this._ws = ws;
this.#ws = ws;
ws.on('message', data => {
this.__handle(JSON.parse(data.toString()));
});
Expand All @@ -40,7 +40,7 @@ export class DeviceAgent {
this.close();
});
}
this._readyPromise = new Promise<void>((resolve, reject) => {
this.#readyPromise = new Promise<void>((resolve, reject) => {
ws.once('open', () => {
resolve();
});
Expand All @@ -53,24 +53,24 @@ export class DeviceAgent {
__handle(message: MessageToDevice): void {}

send(message: MessageFromDevice) {
if (!this._ws) {
if (!this.#ws) {
return;
}
this._ws.send(JSON.stringify(message));
this.#ws.send(JSON.stringify(message));
}

ready(): Promise<void> {
return this._readyPromise;
return this.#readyPromise;
}

close() {
if (!this._ws) {
if (!this.#ws) {
return;
}
try {
this._ws.terminate();
this.#ws.terminate();
} catch {}
this._ws = null;
this.#ws = null;
}

sendWrappedEvent(pageId: string, event: JSONSerializable) {
Expand Down Expand Up @@ -110,7 +110,7 @@ export class DeviceMock extends DeviceAgent {
break;
case 'getPages':
const result = this.getPages(message);
this._sendPayloadIfNonNull('getPages', result);
this.#sendPayloadIfNonNull('getPages', result);
break;
case 'wrappedEvent':
this.wrappedEvent(message);
Expand All @@ -125,7 +125,7 @@ export class DeviceMock extends DeviceAgent {
}
}

_sendPayloadIfNonNull<Event: MessageFromDevice['event']>(
#sendPayloadIfNonNull<Event: MessageFromDevice['event']>(
event: Event,
maybePayload:
| MessageFromDevice['payload']
Expand Down
Loading