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

View File

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

View File

@ -983,6 +983,12 @@
"parameters": ["webDriverBiDi"], "parameters": ["webDriverBiDi"],
"expectations": ["PASS"] "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", "testIdPattern": "[page.spec] Page Page.Events.Console should work",
"platforms": ["darwin", "linux", "win32"], "platforms": ["darwin", "linux", "win32"],