mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: ignore spurious bindingCalled events (#6538)
This commit is contained in:
parent
e6b8c77d94
commit
5e5fed1deb
@ -537,7 +537,15 @@ export class DOMWorld {
|
||||
private async _onBindingCalled(
|
||||
event: Protocol.Runtime.BindingCalledEvent
|
||||
): Promise<void> {
|
||||
const { type, name, seq, args } = JSON.parse(event.payload);
|
||||
let payload: { type: string; name: string; seq: number; args: unknown[] };
|
||||
try {
|
||||
payload = JSON.parse(event.payload);
|
||||
} catch {
|
||||
// The binding was either called by something in the page or it was
|
||||
// called before our wrapper was initialized.
|
||||
return;
|
||||
}
|
||||
const { type, name, seq, args } = payload;
|
||||
if (type !== 'internal' || !this._ctxBindings.has(name)) return;
|
||||
if (!this._hasContext()) return;
|
||||
const context = await this.executionContext();
|
||||
|
@ -1132,7 +1132,15 @@ export class Page extends EventEmitter {
|
||||
private async _onBindingCalled(
|
||||
event: Protocol.Runtime.BindingCalledEvent
|
||||
): Promise<void> {
|
||||
const { type, name, seq, args } = JSON.parse(event.payload);
|
||||
let payload: { type: string; name: string; seq: number; args: unknown[] };
|
||||
try {
|
||||
payload = JSON.parse(event.payload);
|
||||
} catch {
|
||||
// The binding was either called by something in the page or it was
|
||||
// called before our wrapper was initialized.
|
||||
return;
|
||||
}
|
||||
const { type, name, seq, args } = payload;
|
||||
if (type !== 'exposedFun' || !this._pageBindings.has(name)) return;
|
||||
let expression = null;
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user