mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 13:45:36 +03:00
fix(websocket): remove "skip frames" logic (#4435)
This optimization turned out to be racy, so better remove it for now.
This commit is contained in:
parent
cd18ddb693
commit
e69315f711
@ -579,8 +579,6 @@ export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitia
|
|||||||
on(event: string | symbol, listener: Listener): this {
|
on(event: string | symbol, listener: Listener): this {
|
||||||
if (event === Events.Page.FileChooser && !this.listenerCount(event))
|
if (event === Events.Page.FileChooser && !this.listenerCount(event))
|
||||||
this._channel.setFileChooserInterceptedNoReply({ intercepted: true });
|
this._channel.setFileChooserInterceptedNoReply({ intercepted: true });
|
||||||
if (event === Events.Page.WebSocket && !this.listenerCount(event))
|
|
||||||
this._channel.setWebSocketFramesReportingEnabledNoReply({ enabled: true });
|
|
||||||
super.on(event, listener);
|
super.on(event, listener);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -588,8 +586,6 @@ export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitia
|
|||||||
addListener(event: string | symbol, listener: Listener): this {
|
addListener(event: string | symbol, listener: Listener): this {
|
||||||
if (event === Events.Page.FileChooser && !this.listenerCount(event))
|
if (event === Events.Page.FileChooser && !this.listenerCount(event))
|
||||||
this._channel.setFileChooserInterceptedNoReply({ intercepted: true });
|
this._channel.setFileChooserInterceptedNoReply({ intercepted: true });
|
||||||
if (event === Events.Page.WebSocket && !this.listenerCount(event))
|
|
||||||
this._channel.setWebSocketFramesReportingEnabledNoReply({ enabled: true });
|
|
||||||
super.addListener(event, listener);
|
super.addListener(event, listener);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -598,9 +594,6 @@ export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitia
|
|||||||
super.off(event, listener);
|
super.off(event, listener);
|
||||||
if (event === Events.Page.FileChooser && !this.listenerCount(event))
|
if (event === Events.Page.FileChooser && !this.listenerCount(event))
|
||||||
this._channel.setFileChooserInterceptedNoReply({ intercepted: false });
|
this._channel.setFileChooserInterceptedNoReply({ intercepted: false });
|
||||||
// Note: we do not stop reporting web socket frames, since
|
|
||||||
// user might not listen to 'websocket' anymore, but still have
|
|
||||||
// a functioning WebSocket object.
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,9 +601,6 @@ export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitia
|
|||||||
super.removeListener(event, listener);
|
super.removeListener(event, listener);
|
||||||
if (event === Events.Page.FileChooser && !this.listenerCount(event))
|
if (event === Events.Page.FileChooser && !this.listenerCount(event))
|
||||||
this._channel.setFileChooserInterceptedNoReply({ intercepted: false });
|
this._channel.setFileChooserInterceptedNoReply({ intercepted: false });
|
||||||
// Note: we do not stop reporting web socket frames, since
|
|
||||||
// user might not listen to 'websocket' anymore, but still have
|
|
||||||
// a functioning WebSocket object.
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,10 +158,6 @@ export class PageDispatcher extends Dispatcher<Page, channels.PageInitializer> i
|
|||||||
await this._page._setFileChooserIntercepted(params.intercepted);
|
await this._page._setFileChooserIntercepted(params.intercepted);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setWebSocketFramesReportingEnabledNoReply(params: channels.PageSetWebSocketFramesReportingEnabledNoReplyParams): Promise<void> {
|
|
||||||
this._page._setWebSocketFramesReportingEnabled(params.enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
async keyboardDown(params: channels.PageKeyboardDownParams): Promise<void> {
|
async keyboardDown(params: channels.PageKeyboardDownParams): Promise<void> {
|
||||||
await this._page.keyboard.down(params.key);
|
await this._page.keyboard.down(params.key);
|
||||||
}
|
}
|
||||||
|
@ -728,7 +728,6 @@ export interface PageChannel extends Channel {
|
|||||||
setDefaultNavigationTimeoutNoReply(params: PageSetDefaultNavigationTimeoutNoReplyParams, metadata?: Metadata): Promise<PageSetDefaultNavigationTimeoutNoReplyResult>;
|
setDefaultNavigationTimeoutNoReply(params: PageSetDefaultNavigationTimeoutNoReplyParams, metadata?: Metadata): Promise<PageSetDefaultNavigationTimeoutNoReplyResult>;
|
||||||
setDefaultTimeoutNoReply(params: PageSetDefaultTimeoutNoReplyParams, metadata?: Metadata): Promise<PageSetDefaultTimeoutNoReplyResult>;
|
setDefaultTimeoutNoReply(params: PageSetDefaultTimeoutNoReplyParams, metadata?: Metadata): Promise<PageSetDefaultTimeoutNoReplyResult>;
|
||||||
setFileChooserInterceptedNoReply(params: PageSetFileChooserInterceptedNoReplyParams, metadata?: Metadata): Promise<PageSetFileChooserInterceptedNoReplyResult>;
|
setFileChooserInterceptedNoReply(params: PageSetFileChooserInterceptedNoReplyParams, metadata?: Metadata): Promise<PageSetFileChooserInterceptedNoReplyResult>;
|
||||||
setWebSocketFramesReportingEnabledNoReply(params: PageSetWebSocketFramesReportingEnabledNoReplyParams, metadata?: Metadata): Promise<PageSetWebSocketFramesReportingEnabledNoReplyResult>;
|
|
||||||
addInitScript(params: PageAddInitScriptParams, metadata?: Metadata): Promise<PageAddInitScriptResult>;
|
addInitScript(params: PageAddInitScriptParams, metadata?: Metadata): Promise<PageAddInitScriptResult>;
|
||||||
close(params: PageCloseParams, metadata?: Metadata): Promise<PageCloseResult>;
|
close(params: PageCloseParams, metadata?: Metadata): Promise<PageCloseResult>;
|
||||||
emulateMedia(params: PageEmulateMediaParams, metadata?: Metadata): Promise<PageEmulateMediaResult>;
|
emulateMedia(params: PageEmulateMediaParams, metadata?: Metadata): Promise<PageEmulateMediaResult>;
|
||||||
@ -840,13 +839,6 @@ export type PageSetFileChooserInterceptedNoReplyOptions = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
export type PageSetFileChooserInterceptedNoReplyResult = void;
|
export type PageSetFileChooserInterceptedNoReplyResult = void;
|
||||||
export type PageSetWebSocketFramesReportingEnabledNoReplyParams = {
|
|
||||||
enabled: boolean,
|
|
||||||
};
|
|
||||||
export type PageSetWebSocketFramesReportingEnabledNoReplyOptions = {
|
|
||||||
|
|
||||||
};
|
|
||||||
export type PageSetWebSocketFramesReportingEnabledNoReplyResult = void;
|
|
||||||
export type PageAddInitScriptParams = {
|
export type PageAddInitScriptParams = {
|
||||||
source: string,
|
source: string,
|
||||||
};
|
};
|
||||||
|
@ -625,10 +625,6 @@ Page:
|
|||||||
parameters:
|
parameters:
|
||||||
intercepted: boolean
|
intercepted: boolean
|
||||||
|
|
||||||
setWebSocketFramesReportingEnabledNoReply:
|
|
||||||
parameters:
|
|
||||||
enabled: boolean
|
|
||||||
|
|
||||||
addInitScript:
|
addInitScript:
|
||||||
parameters:
|
parameters:
|
||||||
source: string
|
source: string
|
||||||
|
@ -330,9 +330,6 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
|||||||
scheme.PageSetFileChooserInterceptedNoReplyParams = tObject({
|
scheme.PageSetFileChooserInterceptedNoReplyParams = tObject({
|
||||||
intercepted: tBoolean,
|
intercepted: tBoolean,
|
||||||
});
|
});
|
||||||
scheme.PageSetWebSocketFramesReportingEnabledNoReplyParams = tObject({
|
|
||||||
enabled: tBoolean,
|
|
||||||
});
|
|
||||||
scheme.PageAddInitScriptParams = tObject({
|
scheme.PageAddInitScriptParams = tObject({
|
||||||
source: tString,
|
source: tString,
|
||||||
});
|
});
|
||||||
|
@ -359,16 +359,12 @@ export class FrameManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onWebSocketFrameSent(requestId: string, opcode: number, data: string) {
|
onWebSocketFrameSent(requestId: string, opcode: number, data: string) {
|
||||||
if (!this._page._webSocketFramesReportingEnabled)
|
|
||||||
return;
|
|
||||||
const ws = this._webSockets.get(requestId);
|
const ws = this._webSockets.get(requestId);
|
||||||
if (ws)
|
if (ws)
|
||||||
ws.frameSent(opcode, data);
|
ws.frameSent(opcode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
webSocketFrameReceived(requestId: string, opcode: number, data: string) {
|
webSocketFrameReceived(requestId: string, opcode: number, data: string) {
|
||||||
if (!this._page._webSocketFramesReportingEnabled)
|
|
||||||
return;
|
|
||||||
const ws = this._webSockets.get(requestId);
|
const ws = this._webSockets.get(requestId);
|
||||||
if (ws)
|
if (ws)
|
||||||
ws.frameReceived(opcode, data);
|
ws.frameReceived(opcode, data);
|
||||||
|
@ -147,7 +147,6 @@ export class Page extends EventEmitter {
|
|||||||
_ownedContext: BrowserContext | undefined;
|
_ownedContext: BrowserContext | undefined;
|
||||||
readonly selectors: Selectors;
|
readonly selectors: Selectors;
|
||||||
_video: Video | null = null;
|
_video: Video | null = null;
|
||||||
_webSocketFramesReportingEnabled = false;
|
|
||||||
|
|
||||||
constructor(delegate: PageDelegate, browserContext: BrowserContext) {
|
constructor(delegate: PageDelegate, browserContext: BrowserContext) {
|
||||||
super();
|
super();
|
||||||
@ -441,10 +440,6 @@ export class Page extends EventEmitter {
|
|||||||
await this._delegate.setFileChooserIntercepted(enabled);
|
await this._delegate.setFileChooserIntercepted(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
_setWebSocketFramesReportingEnabled(enabled: boolean) {
|
|
||||||
this._webSocketFramesReportingEnabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
videoStarted(video: Video) {
|
videoStarted(video: Video) {
|
||||||
this._video = video;
|
this._video = video;
|
||||||
this.emit(Page.Events.VideoStarted, video);
|
this.emit(Page.Events.VideoStarted, video);
|
||||||
|
Loading…
Reference in New Issue
Block a user