Revert "chore: ignore third-party execution contexts (#32437)"

This reverts commit d7b9cf21db.
This commit is contained in:
Yury Semikhatsky 2024-09-23 15:03:32 -07:00
parent b888e3c0d2
commit 3c73bc3b24
4 changed files with 11 additions and 14 deletions

View file

@ -694,15 +694,14 @@ class FrameSession {
if (!frame || this._eventBelongsToStaleFrame(frame._id))
return;
const delegate = new CRExecutionContext(this._client, contextPayload);
let worldName: types.World;
let worldName: types.World|null = null;
if (contextPayload.auxData && !!contextPayload.auxData.isDefault)
worldName = 'main';
else if (contextPayload.name === UTILITY_WORLD_NAME)
worldName = 'utility';
else
return;
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
(context as any)[contextDelegateSymbol] = delegate;
if (worldName)
frame._contextCreated(worldName, context);
this._contextIdToContext.set(contextPayload.id, context);
}

View file

@ -50,9 +50,9 @@ export function isNonRecoverableDOMError(error: Error) {
export class FrameExecutionContext extends js.ExecutionContext {
readonly frame: frames.Frame;
private _injectedScriptPromise?: Promise<js.JSHandle>;
readonly world: types.World;
readonly world: types.World | null;
constructor(delegate: js.ExecutionContextDelegate, frame: frames.Frame, world: types.World) {
constructor(delegate: js.ExecutionContextDelegate, frame: frames.Frame, world: types.World|null) {
super(frame, delegate, world || 'content-script');
this.frame = frame;
this.world = world;

View file

@ -163,15 +163,14 @@ export class FFPage implements PageDelegate {
if (!frame)
return;
const delegate = new FFExecutionContext(this._session, executionContextId);
let worldName: types.World;
let worldName: types.World|null = null;
if (auxData.name === UTILITY_WORLD_NAME)
worldName = 'utility';
else if (!auxData.name)
worldName = 'main';
else
return;
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
(context as any)[contextDelegateSymbol] = delegate;
if (worldName)
frame._contextCreated(worldName, context);
this._contextIdToContext.set(executionContextId, context);
}

View file

@ -502,15 +502,14 @@ export class WKPage implements PageDelegate {
if (!frame)
return;
const delegate = new WKExecutionContext(this._session, contextPayload.id);
let worldName: types.World;
let worldName: types.World|null = null;
if (contextPayload.type === 'normal')
worldName = 'main';
else if (contextPayload.type === 'user' && contextPayload.name === UTILITY_WORLD_NAME)
worldName = 'utility';
else
return;
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
(context as any)[contextDelegateSymbol] = delegate;
if (worldName)
frame._contextCreated(worldName, context);
this._contextIdToContext.set(contextPayload.id, context);
}