chore: ignore third-party execution contexts (#32437)
* Only track main and utility world contexts * Properly update click metadata
This commit is contained in:
parent
cfae7f755c
commit
d7b9cf21db
|
|
@ -690,15 +690,16 @@ class FrameSession {
|
||||||
if (!frame || this._eventBelongsToStaleFrame(frame._id))
|
if (!frame || this._eventBelongsToStaleFrame(frame._id))
|
||||||
return;
|
return;
|
||||||
const delegate = new CRExecutionContext(this._client, contextPayload);
|
const delegate = new CRExecutionContext(this._client, contextPayload);
|
||||||
let worldName: types.World|null = null;
|
let worldName: types.World;
|
||||||
if (contextPayload.auxData && !!contextPayload.auxData.isDefault)
|
if (contextPayload.auxData && !!contextPayload.auxData.isDefault)
|
||||||
worldName = 'main';
|
worldName = 'main';
|
||||||
else if (contextPayload.name === UTILITY_WORLD_NAME)
|
else if (contextPayload.name === UTILITY_WORLD_NAME)
|
||||||
worldName = 'utility';
|
worldName = 'utility';
|
||||||
|
else
|
||||||
|
return;
|
||||||
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
||||||
(context as any)[contextDelegateSymbol] = delegate;
|
(context as any)[contextDelegateSymbol] = delegate;
|
||||||
if (worldName)
|
frame._contextCreated(worldName, context);
|
||||||
frame._contextCreated(worldName, context);
|
|
||||||
this._contextIdToContext.set(contextPayload.id, context);
|
this._contextIdToContext.set(contextPayload.id, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,9 @@ export function isNonRecoverableDOMError(error: Error) {
|
||||||
export class FrameExecutionContext extends js.ExecutionContext {
|
export class FrameExecutionContext extends js.ExecutionContext {
|
||||||
readonly frame: frames.Frame;
|
readonly frame: frames.Frame;
|
||||||
private _injectedScriptPromise?: Promise<js.JSHandle>;
|
private _injectedScriptPromise?: Promise<js.JSHandle>;
|
||||||
readonly world: types.World | null;
|
readonly world: types.World;
|
||||||
|
|
||||||
constructor(delegate: js.ExecutionContextDelegate, frame: frames.Frame, world: types.World|null) {
|
constructor(delegate: js.ExecutionContextDelegate, frame: frames.Frame, world: types.World) {
|
||||||
super(frame, delegate, world || 'content-script');
|
super(frame, delegate, world || 'content-script');
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
|
|
||||||
|
|
@ -163,15 +163,16 @@ export class FFPage implements PageDelegate {
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return;
|
return;
|
||||||
const delegate = new FFExecutionContext(this._session, executionContextId);
|
const delegate = new FFExecutionContext(this._session, executionContextId);
|
||||||
let worldName: types.World|null = null;
|
let worldName: types.World;
|
||||||
if (auxData.name === UTILITY_WORLD_NAME)
|
if (auxData.name === UTILITY_WORLD_NAME)
|
||||||
worldName = 'utility';
|
worldName = 'utility';
|
||||||
else if (!auxData.name)
|
else if (!auxData.name)
|
||||||
worldName = 'main';
|
worldName = 'main';
|
||||||
|
else
|
||||||
|
return;
|
||||||
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
||||||
(context as any)[contextDelegateSymbol] = delegate;
|
(context as any)[contextDelegateSymbol] = delegate;
|
||||||
if (worldName)
|
frame._contextCreated(worldName, context);
|
||||||
frame._contextCreated(worldName, context);
|
|
||||||
this._contextIdToContext.set(executionContextId, context);
|
this._contextIdToContext.set(executionContextId, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ export class Mouse {
|
||||||
|
|
||||||
async click(x: number, y: number, options: { delay?: number, button?: types.MouseButton, clickCount?: number } = {}, metadata?: CallMetadata) {
|
async click(x: number, y: number, options: { delay?: number, button?: types.MouseButton, clickCount?: number } = {}, metadata?: CallMetadata) {
|
||||||
if (metadata)
|
if (metadata)
|
||||||
metadata.point = { x: this._x, y: this._y };
|
metadata.point = { x, y };
|
||||||
const { delay = null, clickCount = 1 } = options;
|
const { delay = null, clickCount = 1 } = options;
|
||||||
if (delay) {
|
if (delay) {
|
||||||
this.move(x, y, { forClick: true });
|
this.move(x, y, { forClick: true });
|
||||||
|
|
|
||||||
|
|
@ -502,15 +502,16 @@ export class WKPage implements PageDelegate {
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return;
|
return;
|
||||||
const delegate = new WKExecutionContext(this._session, contextPayload.id);
|
const delegate = new WKExecutionContext(this._session, contextPayload.id);
|
||||||
let worldName: types.World|null = null;
|
let worldName: types.World;
|
||||||
if (contextPayload.type === 'normal')
|
if (contextPayload.type === 'normal')
|
||||||
worldName = 'main';
|
worldName = 'main';
|
||||||
else if (contextPayload.type === 'user' && contextPayload.name === UTILITY_WORLD_NAME)
|
else if (contextPayload.type === 'user' && contextPayload.name === UTILITY_WORLD_NAME)
|
||||||
worldName = 'utility';
|
worldName = 'utility';
|
||||||
|
else
|
||||||
|
return;
|
||||||
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
||||||
(context as any)[contextDelegateSymbol] = delegate;
|
(context as any)[contextDelegateSymbol] = delegate;
|
||||||
if (worldName)
|
frame._contextCreated(worldName, context);
|
||||||
frame._contextCreated(worldName, context);
|
|
||||||
this._contextIdToContext.set(contextPayload.id, context);
|
this._contextIdToContext.set(contextPayload.id, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue