test: implement page target for BiDi to run the console test (#11480)

This commit is contained in:
Alex Rudenko 2023-12-01 10:55:58 +01:00 committed by GitHub
parent be081ba17a
commit 37bcb77494
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -89,6 +89,7 @@ import type {BiDiNetworkIdle} from './lifecycle.js';
import {getBiDiReadinessState, rewriteNavigationError} from './lifecycle.js';
import {BidiNetworkManager} from './NetworkManager.js';
import {createBidiHandle} from './Realm.js';
import type {BiDiPageTarget} from './Target.js';
/**
* @internal
@ -159,6 +160,7 @@ export class BidiPage extends Page {
#keyboard: BidiKeyboard;
#browsingContext: BrowsingContext;
#browserContext: BidiBrowserContext;
#target: BiDiPageTarget;
_client(): CDPSession {
return this.mainFrame().context().cdpSession;
@ -166,11 +168,13 @@ export class BidiPage extends Page {
constructor(
browsingContext: BrowsingContext,
browserContext: BidiBrowserContext
browserContext: BidiBrowserContext,
target: BiDiPageTarget
) {
super();
this.#browsingContext = browsingContext;
this.#browserContext = browserContext;
this.#target = target;
this.#connection = browsingContext.connection;
for (const [event, subscriber] of this.#browsingContextEvents) {
@ -846,8 +850,8 @@ export class BidiPage extends Page {
throw new UnsupportedOperation();
}
override target(): never {
throw new UnsupportedOperation();
override target(): BiDiPageTarget {
return this.#target;
}
override waitForFileChooser(): never {

View File

@ -119,7 +119,7 @@ export class BiDiPageTarget extends BiDiBrowsingContextTarget {
) {
super(browserContext, browsingContext);
this.#page = new BidiPage(browsingContext, browserContext);
this.#page = new BidiPage(browsingContext, browserContext, this);
}
override async page(): Promise<BidiPage> {

View File

@ -983,6 +983,12 @@
"parameters": ["webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[page.spec] Page Page.Events.Console should not throw when there are console messages in detached iframes",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[page.spec] Page Page.Events.Console should work",
"platforms": ["darwin", "linux", "win32"],