chore: remove Page.prototype.target from WebDriver BiDi (#11873)

This commit is contained in:
jrandolf 2024-02-08 14:08:02 +01:00 committed by GitHub
parent 15c986c2bc
commit 8a9fb1051a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 7 deletions

View File

@ -144,7 +144,6 @@ export class BidiPage extends Page {
#keyboard: BidiKeyboard;
#browsingContext: BrowsingContext;
#browserContext: BidiBrowserContext;
#target: BiDiPageTarget;
_client(): CDPSession {
return this.mainFrame().context().cdpSession;
@ -152,13 +151,11 @@ export class BidiPage extends Page {
constructor(
browsingContext: BrowsingContext,
browserContext: BidiBrowserContext,
target: BiDiPageTarget
browserContext: BidiBrowserContext
) {
super();
this.#browsingContext = browsingContext;
this.#browserContext = browserContext;
this.#target = target;
this.#connection = browsingContext.connection;
for (const [event, subscriber] of this.#browsingContextEvents) {
@ -794,7 +791,7 @@ export class BidiPage extends Page {
}
override target(): BiDiPageTarget {
return this.#target;
throw new UnsupportedOperation();
}
override waitForFileChooser(): never {

View File

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

View File

@ -583,7 +583,7 @@ describe('Page', function () {
// 3. After that, remove the iframe.
frame.remove();
});
// 4. The target should always be the last one.
// 4. The target will always be the last one.
const popupTarget = page.browserContext().targets().at(-1)!;
// 5. Connect to the popup and make sure it doesn't throw and is not the same page.
expect(await popupTarget.page()).not.toBe(page);