diff --git a/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json b/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json index e2c7ed009..62a886f9d 100644 --- a/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json +++ b/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json @@ -705,21 +705,6 @@ "FAIL" ] }, - { - "comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one", - "testIdPattern": "[acceptInsecureCerts.spec] *", - "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": "[injected.spec] *", diff --git a/lib/PuppeteerSharp.Tests/IgnoreHttpsErrorsTests/AcceptInsecureCertsTests.cs b/lib/PuppeteerSharp.Tests/IgnoreHttpsErrorsTests/AcceptInsecureCertsTests.cs index 2f1937946..85cf3a298 100644 --- a/lib/PuppeteerSharp.Tests/IgnoreHttpsErrorsTests/AcceptInsecureCertsTests.cs +++ b/lib/PuppeteerSharp.Tests/IgnoreHttpsErrorsTests/AcceptInsecureCertsTests.cs @@ -39,7 +39,7 @@ public async Task ShouldWorkWithMixedContent() }); await Page.GoToAsync(TestConstants.HttpsPrefix + "/mixedcontent.html", new NavigationOptions { - WaitUntil = new[] { WaitUntilNavigation.Load } + WaitUntil = [WaitUntilNavigation.Load] }); Assert.That(Page.Frames, Has.Length.EqualTo(2)); // Make sure blocked iframe has functional execution context diff --git a/lib/PuppeteerSharp.Tests/IgnoreHttpsErrorsTests/ResponseSecurityDetailsTests.cs b/lib/PuppeteerSharp.Tests/IgnoreHttpsErrorsTests/ResponseSecurityDetailsTests.cs index 8c9f26d3d..775c81f8b 100644 --- a/lib/PuppeteerSharp.Tests/IgnoreHttpsErrorsTests/ResponseSecurityDetailsTests.cs +++ b/lib/PuppeteerSharp.Tests/IgnoreHttpsErrorsTests/ResponseSecurityDetailsTests.cs @@ -16,26 +16,29 @@ public ResponseSecurityDetailsTests() : base() DefaultOptions.AcceptInsecureCerts = true; } - [Test, PuppeteerTest("acceptInsecureCerts.spec", "Response.securityDetails", "Should Work")] + [Test, PuppeteerTest("acceptInsecureCerts.spec", "acceptInsecureCerts Response.securityDetails", "Should Work")] public async Task ShouldWork() { - // Checking for the TLS socket is it is in upstreams proves to be flaky in .net framework. + // Checking for the TLS socket is it is in upstreams proves to be flaky in .NET Framework. // We don't need to test that here. var response = await Page.GoToAsync(TestConstants.HttpsPrefix + "/empty.html"); - Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK)); - Assert.That(response.SecurityDetails, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK)); + Assert.That(response.SecurityDetails, Is.Not.Null); + }); Assert.That(response.SecurityDetails.Protocol, Does.Contain("TLS")); } - [Test, PuppeteerTest("acceptInsecureCerts.spec", "Response.securityDetails", "should be |null| for non-secure requests")] + [Test, PuppeteerTest("acceptInsecureCerts.spec", "acceptInsecureCerts Response.securityDetails", "should be |null| for non-secure requests")] public async Task ShouldBeNullForNonSecureRequests() { var response = await Page.GoToAsync(TestConstants.EmptyPage); Assert.That(response.SecurityDetails, Is.Null); } - [Test, PuppeteerTest("acceptInsecureCerts.spec", "Response.securityDetails", "Network redirects should report SecurityDetails")] + [Test, PuppeteerTest("acceptInsecureCerts.spec", "acceptInsecureCerts Response.securityDetails", "Network redirects should report SecurityDetails")] [Ignore("This is super flaky")] public async Task NetworkRedirectsShouldReportSecurityDetails() { @@ -55,10 +58,13 @@ await Task.WhenAll( var response = responseTask.Result; - Assert.That(responses, Has.Count.EqualTo(2)); - Assert.That(responses[0].Status, Is.EqualTo(HttpStatusCode.Found)); - Assert.That(TestUtils.CurateProtocol(response.SecurityDetails.Protocol), - Is.EqualTo(TestUtils.CurateProtocol(requestTask.Result.ToString()))); + Assert.Multiple(() => + { + Assert.That(responses, Has.Count.EqualTo(2)); + Assert.That(responses[0].Status, Is.EqualTo(HttpStatusCode.Found)); + Assert.That(TestUtils.CurateProtocol(response.SecurityDetails.Protocol), + Is.EqualTo(TestUtils.CurateProtocol(requestTask.Result.ToString()))); + }); } } } diff --git a/lib/PuppeteerSharp/Bidi/BidiFrame.cs b/lib/PuppeteerSharp/Bidi/BidiFrame.cs index bc98d2e54..cd8b62180 100644 --- a/lib/PuppeteerSharp/Bidi/BidiFrame.cs +++ b/lib/PuppeteerSharp/Bidi/BidiFrame.cs @@ -40,7 +40,7 @@ public class BidiFrame : Frame internal BidiFrame(BidiPage parentPage, BidiFrame parentFrame, BrowsingContext browsingContext) { - Client = new BidiCdpSession(this, parentPage.BidiBrowser.LoggerFactory); + Client = new BidiCdpSession(this, parentPage?.BidiBrowser?.LoggerFactory ?? parentFrame?.BidiPage?.BidiBrowser?.LoggerFactory); ParentPage = parentPage; ParentFrame = parentFrame; BrowsingContext = browsingContext; diff --git a/lib/PuppeteerSharp/Bidi/BidiHttpResponse.cs b/lib/PuppeteerSharp/Bidi/BidiHttpResponse.cs index 490c570e1..acc920f07 100644 --- a/lib/PuppeteerSharp/Bidi/BidiHttpResponse.cs +++ b/lib/PuppeteerSharp/Bidi/BidiHttpResponse.cs @@ -39,6 +39,10 @@ private BidiHttpResponse(WebDriverBiDi.Network.ResponseData data, BidiHttpReques Status = (HttpStatusCode)data.Status; Url = data.Url; _fromCache = data.FromCache; + + // TODO: Implement SecurityDetails support when webdriverbidi-net library supports extensibility + // The upstream puppeteer implementation accesses a non-standard 'goog:securityDetails' property + // which is not yet exposed in the webdriverbidi-net library } // Internal constructor for synthetic responses (e.g., cached history navigation) diff --git a/lib/PuppeteerSharp/Bidi/BidiPage.cs b/lib/PuppeteerSharp/Bidi/BidiPage.cs index 746af5666..aaeb038c2 100644 --- a/lib/PuppeteerSharp/Bidi/BidiPage.cs +++ b/lib/PuppeteerSharp/Bidi/BidiPage.cs @@ -57,7 +57,19 @@ internal BidiPage(BidiBrowserContext browserContext, BrowsingContext browsingCon public override Target Target { get; } /// - public override IFrame[] Frames { get; } + public override IFrame[] Frames + { + get + { + var frames = new List