Skip to content

Conversation

@kblok
Copy link
Member

@kblok kblok commented Jan 4, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 4, 2026 15:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables passing several network-related tests for the WebDriver BiDi implementation by fixing event handling issues and adjusting test expectations for known BiDi limitations.

  • Refactored SyncBrowsingContextsAsync to use proper async/await and event handler cleanup
  • Added "once" behavior emulation to prevent duplicate Success/Error event firings in request handling
  • Updated network tests to filter out favicon requests that can interfere with test assertions
  • Added specific test expectations for known BiDi limitations (missing RemoteAddress, Firefox-specific issues)

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/PuppeteerSharp/Bidi/Core/Browser.cs Converted SyncBrowsingContextsAsync to proper async method with try/finally event handler cleanup
lib/PuppeteerSharp/Bidi/BidiHttpRequest.cs Added boolean flags to prevent duplicate Success/Error event firings during redirects
lib/PuppeteerSharp/Bidi/BidiFrame.cs Added boolean flags to prevent duplicate Success/Error event firings for frame requests
lib/PuppeteerSharp.Tests/NetworkTests/NetworkEventTests.cs Added favicon filtering to prevent spurious requests from affecting test assertions; removed debug console output
lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json Removed blanket network test FAIL expectation; added specific FAIL expectations for known BiDi limitations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +500 to +511
var successFired = false;
var errorFired = false;

request.Success += (_, _) =>
{
// Emulate 'once' behavior - only fire once
if (successFired)
{
return;
}

successFired = true;
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The boolean flags successFired and errorFired are not thread-safe. If the event handlers fire concurrently from different threads, both could read false before either sets it to true, causing the event to fire multiple times. Consider using Interlocked.CompareExchange or a thread-safe flag to ensure the "once" behavior is maintained in multi-threaded scenarios.

Copilot uses AI. Check for mistakes.
Comment on lines +639 to +650
var successFired = false;
var errorFired = false;

args.Request.Success += (o, eventArgs) =>
{
// Emulate 'once' behavior - only fire once
if (successFired)
{
return;
}

successFired = true;
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The boolean flags successFired and errorFired are not thread-safe. If the event handlers fire concurrently from different threads, both could read false before either sets it to true, causing the event to fire multiple times. Consider using Interlocked.CompareExchange or a thread-safe flag to ensure the "once" behavior is maintained in multi-threaded scenarios.

Copilot uses AI. Check for mistakes.
Comment on lines +517 to +523
// Emulate 'once' behavior - only fire once
if (errorFired)
{
return;
}

errorFired = true;
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The boolean flag errorFired is not thread-safe. If the error event handler fires concurrently from different threads, both could read false before either sets it to true, causing the event to fire multiple times. Consider using Interlocked.CompareExchange or a thread-safe flag to ensure the "once" behavior is maintained in multi-threaded scenarios.

Copilot uses AI. Check for mistakes.
Comment on lines +656 to +662
// Emulate 'once' behavior - only fire once
if (errorFired)
{
return;
}

errorFired = true;
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The boolean flag errorFired is not thread-safe. If the error event handler fires concurrently from different threads, both could read false before either sets it to true, causing the event to fire multiple times. Consider using Interlocked.CompareExchange or a thread-safe flag to ensure the "once" behavior is maintained in multi-threaded scenarios.

Copilot uses AI. Check for mistakes.
@kblok kblok merged commit 848461e into v21 Jan 8, 2026
24 of 27 checks passed
@kblok kblok deleted the bidi-pass-network-tests branch January 8, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants