From 8d9816d2963addf45d000013f21e889c54e617f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Wed, 4 Dec 2024 17:13:11 -0300 Subject: [PATCH] Bidi: Pass browser target (#2835) --- .../TestExpectations/TestExpectations.local.json | 15 --------------- .../BrowserTests/TargetTests.cs | 4 ---- lib/PuppeteerSharp/Bidi/BidiBrowser.cs | 3 +++ lib/PuppeteerSharp/Bidi/BidiBrowserTarget.cs | 2 +- lib/PuppeteerSharp/Browser.cs | 2 +- 5 files changed, 5 insertions(+), 21 deletions(-) diff --git a/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json b/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json index 5a0b033bb..6e3206240 100644 --- a/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json +++ b/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json @@ -120,21 +120,6 @@ "FAIL" ] }, - { - "comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one", - "testIdPattern": "[browser.spec] *Browser.target*", - "platforms": [ - "darwin", - "linux", - "win32" - ], - "parameters": [ - "webDriverBiDi" - ], - "expectations": [ - "FAIL" - ] - }, { "comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one", "testIdPattern": "[navigation.spec] navigation Page.waitForNavigation*", diff --git a/lib/PuppeteerSharp.Tests/BrowserTests/TargetTests.cs b/lib/PuppeteerSharp.Tests/BrowserTests/TargetTests.cs index 3f5fbfcc5..f1022f4ac 100644 --- a/lib/PuppeteerSharp.Tests/BrowserTests/TargetTests.cs +++ b/lib/PuppeteerSharp.Tests/BrowserTests/TargetTests.cs @@ -5,10 +5,6 @@ namespace PuppeteerSharp.Tests.BrowserTests { public class TargetTests : PuppeteerBrowserBaseTest { - public TargetTests() : base() - { - } - [Test, Retry(2), PuppeteerTest("browser.spec", "Browser.target", "should return browser target")] public void ShouldReturnBrowserTarget() => Assert.That(Browser.Target.Type, Is.EqualTo(TargetType.Browser)); diff --git a/lib/PuppeteerSharp/Bidi/BidiBrowser.cs b/lib/PuppeteerSharp/Bidi/BidiBrowser.cs index bd36678b9..64bbed1a7 100644 --- a/lib/PuppeteerSharp/Bidi/BidiBrowser.cs +++ b/lib/PuppeteerSharp/Bidi/BidiBrowser.cs @@ -53,6 +53,9 @@ private BidiBrowser(Core.Browser browserCore, LaunchOptions options, ILoggerFact /// public override bool IsClosed { get; } + /// + public override ITarget Target => _target; + internal static string[] SubscribeModules { get; } = [ "browsingContext", diff --git a/lib/PuppeteerSharp/Bidi/BidiBrowserTarget.cs b/lib/PuppeteerSharp/Bidi/BidiBrowserTarget.cs index b05fc82b2..922b98553 100644 --- a/lib/PuppeteerSharp/Bidi/BidiBrowserTarget.cs +++ b/lib/PuppeteerSharp/Bidi/BidiBrowserTarget.cs @@ -28,7 +28,7 @@ internal class BidiBrowserTarget(BidiBrowser bidiBrowser) : Target { public override string Url { get; } - public override TargetType Type { get; } + public override TargetType Type => TargetType.Browser; public override ITarget Opener { get; } diff --git a/lib/PuppeteerSharp/Browser.cs b/lib/PuppeteerSharp/Browser.cs index c59a19f54..bdcf12372 100644 --- a/lib/PuppeteerSharp/Browser.cs +++ b/lib/PuppeteerSharp/Browser.cs @@ -55,7 +55,7 @@ public abstract class Browser : IBrowser public bool IsConnected => !Connection.IsClosed; /// - public ITarget Target => Targets().FirstOrDefault(t => t.Type == TargetType.Browser); + public virtual ITarget Target => Targets().FirstOrDefault(t => t.Type == TargetType.Browser); internal TaskQueue ScreenshotTaskQueue { get; } = new();