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; #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;
@ -152,13 +151,11 @@ 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) {
@ -794,7 +791,7 @@ export class BidiPage extends Page {
} }
override target(): BiDiPageTarget { override target(): BiDiPageTarget {
return this.#target; throw new UnsupportedOperation();
} }
override waitForFileChooser(): never { override waitForFileChooser(): never {

View File

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

View File

@ -583,7 +583,7 @@ describe('Page', function () {
// 3. After that, remove the iframe. // 3. After that, remove the iframe.
frame.remove(); 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)!; 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. // 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); expect(await popupTarget.page()).not.toBe(page);