Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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] *",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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())));
});
}
}
}
2 changes: 1 addition & 1 deletion lib/PuppeteerSharp/Bidi/BidiFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions lib/PuppeteerSharp/Bidi/BidiHttpResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 13 additions & 1 deletion lib/PuppeteerSharp/Bidi/BidiPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,19 @@ internal BidiPage(BidiBrowserContext browserContext, BrowsingContext browsingCon
public override Target Target { get; }

/// <inheritdoc />
public override IFrame[] Frames { get; }
public override IFrame[] Frames
{
get
{
var frames = new List<IFrame> { BidiMainFrame };
for (var i = 0; i < frames.Count; i++)
{
frames.AddRange(frames[i].ChildFrames);
}

return frames.ToArray();
}
}

/// <inheritdoc />
public override WebWorker[] Workers { get; }
Expand Down
2 changes: 1 addition & 1 deletion lib/PuppeteerSharp/Bidi/WindowRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal class WindowRealm(BrowsingContext browsingContext, string sandbox = nul

public override Session Session => Context.UserContext.Browser.Session;

public override ContextTarget Target => new(Context.Id); // TODO: Add sandbox
public override ContextTarget Target => new(Context.Id) { Sandbox = _sandbox };

public string ExecutionContextId { get; set; }

Expand Down
Loading