chore: enable _client for Chrome BiDi (#10688)
This commit is contained in:
parent
f4c711e25b
commit
512a0f2a9d
@ -4,9 +4,8 @@ import ProtocolMapping from 'devtools-protocol/types/protocol-mapping.js';
|
|||||||
import {WaitForOptions} from '../../api/Page.js';
|
import {WaitForOptions} from '../../api/Page.js';
|
||||||
import {assert} from '../../util/assert.js';
|
import {assert} from '../../util/assert.js';
|
||||||
import {Deferred} from '../../util/Deferred.js';
|
import {Deferred} from '../../util/Deferred.js';
|
||||||
import type {CDPSession, Connection as CDPConnection} from '../Connection.js';
|
import {CDPSession, Connection as CDPConnection} from '../Connection.js';
|
||||||
import {ProtocolError, TargetCloseError, TimeoutError} from '../Errors.js';
|
import {ProtocolError, TargetCloseError, TimeoutError} from '../Errors.js';
|
||||||
import {EventEmitter} from '../EventEmitter.js';
|
|
||||||
import {PuppeteerLifeCycleEvent} from '../LifecycleWatcher.js';
|
import {PuppeteerLifeCycleEvent} from '../LifecycleWatcher.js';
|
||||||
import {getPageContent, setPageContent, waitWithTimeout} from '../util.js';
|
import {getPageContent, setPageContent, waitWithTimeout} from '../util.js';
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ export const cdpSessions = new Map<string, CDPSessionWrapper>();
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export class CDPSessionWrapper extends EventEmitter implements CDPSession {
|
export class CDPSessionWrapper extends CDPSession {
|
||||||
#context: BrowsingContext;
|
#context: BrowsingContext;
|
||||||
#sessionId = Deferred.create<string>();
|
#sessionId = Deferred.create<string>();
|
||||||
#detached = false;
|
#detached = false;
|
||||||
@ -70,11 +69,11 @@ export class CDPSessionWrapper extends EventEmitter implements CDPSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connection(): CDPConnection | undefined {
|
override connection(): CDPConnection | undefined {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
async send<T extends keyof ProtocolMapping.Commands>(
|
override async send<T extends keyof ProtocolMapping.Commands>(
|
||||||
method: T,
|
method: T,
|
||||||
...paramArgs: ProtocolMapping.Commands[T]['paramsType']
|
...paramArgs: ProtocolMapping.Commands[T]['paramsType']
|
||||||
): Promise<ProtocolMapping.Commands[T]['returnType']> {
|
): Promise<ProtocolMapping.Commands[T]['returnType']> {
|
||||||
@ -92,7 +91,7 @@ export class CDPSessionWrapper extends EventEmitter implements CDPSession {
|
|||||||
return result.result;
|
return result.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
async detach(): Promise<void> {
|
override async detach(): Promise<void> {
|
||||||
cdpSessions.delete(this.id());
|
cdpSessions.delete(this.id());
|
||||||
await this.#context.cdpSession.send('Target.detachFromTarget', {
|
await this.#context.cdpSession.send('Target.detachFromTarget', {
|
||||||
sessionId: this.id(),
|
sessionId: this.id(),
|
||||||
@ -100,7 +99,7 @@ export class CDPSessionWrapper extends EventEmitter implements CDPSession {
|
|||||||
this.#detached = true;
|
this.#detached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
id(): string {
|
override id(): string {
|
||||||
const val = this.#sessionId.value();
|
const val = this.#sessionId.value();
|
||||||
return val instanceof Error || val === undefined ? '' : val;
|
return val instanceof Error || val === undefined ? '' : val;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
|
|||||||
import {ElementHandle} from '../../api/ElementHandle.js';
|
import {ElementHandle} from '../../api/ElementHandle.js';
|
||||||
import {Frame as BaseFrame} from '../../api/Frame.js';
|
import {Frame as BaseFrame} from '../../api/Frame.js';
|
||||||
import {Deferred} from '../../util/Deferred.js';
|
import {Deferred} from '../../util/Deferred.js';
|
||||||
|
import {CDPSession} from '../Connection.js';
|
||||||
import {UTILITY_WORLD_NAME} from '../FrameManager.js';
|
import {UTILITY_WORLD_NAME} from '../FrameManager.js';
|
||||||
import {PuppeteerLifeCycleEvent} from '../LifecycleWatcher.js';
|
import {PuppeteerLifeCycleEvent} from '../LifecycleWatcher.js';
|
||||||
import {TimeoutSettings} from '../TimeoutSettings.js';
|
import {TimeoutSettings} from '../TimeoutSettings.js';
|
||||||
@ -74,6 +75,10 @@ export class Frame extends BaseFrame {
|
|||||||
context.setFrame(this);
|
context.setFrame(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override _client(): CDPSession {
|
||||||
|
return this.context().cdpSession;
|
||||||
|
}
|
||||||
|
|
||||||
override mainRealm(): Sandbox {
|
override mainRealm(): Sandbox {
|
||||||
return this.sandboxes[MAIN_SANDBOX];
|
return this.sandboxes[MAIN_SANDBOX];
|
||||||
}
|
}
|
||||||
|
@ -132,6 +132,10 @@ export class Page extends PageBase {
|
|||||||
#browsingContext: BrowsingContext;
|
#browsingContext: BrowsingContext;
|
||||||
#browserContext: BrowserContext;
|
#browserContext: BrowserContext;
|
||||||
|
|
||||||
|
_client(): CDPSession {
|
||||||
|
return this.mainFrame().context().cdpSession;
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
browsingContext: BrowsingContext,
|
browsingContext: BrowsingContext,
|
||||||
browserContext: BrowserContext
|
browserContext: BrowserContext
|
||||||
|
@ -1193,6 +1193,18 @@
|
|||||||
"parameters": ["webDriverBiDi"],
|
"parameters": ["webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["PASS"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[page.spec] Page Page.close should set the page close state",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[page.spec] Page Page.close should terminate network waiters",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[page.spec] Page Page.close should terminate network waiters",
|
"testIdPattern": "[page.spec] Page Page.close should terminate network waiters",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -2177,6 +2189,12 @@
|
|||||||
"parameters": ["chrome", "webDriverBiDi"],
|
"parameters": ["chrome", "webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["PASS"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[frame.spec] Frame specs Frame.client should return the client instance",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["chrome", "webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[frame.spec] Frame specs Frame.evaluate should throw for detached frames",
|
"testIdPattern": "[frame.spec] Frame specs Frame.evaluate should throw for detached frames",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -3203,6 +3221,12 @@
|
|||||||
"parameters": ["cdp", "firefox"],
|
"parameters": ["cdp", "firefox"],
|
||||||
"expectations": ["SKIP"]
|
"expectations": ["SKIP"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[page.spec] Page Page.client should return the client instance",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["chrome", "webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[page.spec] Page Page.close should not be visible in browser.pages",
|
"testIdPattern": "[page.spec] Page Page.close should not be visible in browser.pages",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
Loading…
Reference in New Issue
Block a user