Skip to content

Migrate to WebDriverBiDi RemoteValue type-safe subclass API#3399

Merged
kblok merged 9 commits intomasterfrom
feature/webdriverbidi-remotevalue-redesign
Apr 1, 2026
Merged

Migrate to WebDriverBiDi RemoteValue type-safe subclass API#3399
kblok merged 9 commits intomasterfrom
feature/webdriverbidi-remotevalue-redesign

Conversation

@kblok
Copy link
Copy Markdown
Member

@kblok kblok commented Mar 24, 2026

Summary

  • Adapts PuppeteerSharp to the new WebDriverBiDi.NET RemoteValue redesign (webdriverbidi-net/webdriverbidi-net#55)
  • RemoteValueType is now an enum replacing string-based comparisons across all BiDi files
  • RemoteValue.Value/.HasValue/.Handle moved to typed subclasses (ValueHoldingRemoteValue, IObjectReferenceRemoteValue)
  • ArgumentValueLocalValue, ValueAs<T>()ConvertTo<T>()/pattern matching
  • Replaced manual SerializeRemoteValue (60+ lines) with native RemoteValue.ToLocalValue()
  • Updated SetScriptingEnabledCommandParameters, SetCacheBehaviorCommandParameters, and SubscribeCommandParameters constructors

Notes

  • Currently uses a local project reference to the WebDriverBiDi PR branch for testing. Will switch to NuGet package reference once the WebDriverBiDi release is published.
  • Firefox BiDi tests: 843 passed, 37 failed (pre-existing), 294 skipped

Test plan

  • Build succeeds with 0 errors
  • Firefox BiDi test suite passes (37 failures are pre-existing, not related to this change)
  • Switch to NuGet package reference when WebDriverBiDi release is published

🤖 Generated with Claude Code

kblok and others added 2 commits March 24, 2026 17:45
Adapt PuppeteerSharp to the new WebDriverBiDi.NET RemoteValue redesign
(webdriverbidi-net/webdriverbidi-net#55) which replaces the flat
RemoteValue class with a type-safe subclass hierarchy.

Key changes:
- RemoteValueType is now an enum (was string-based comparisons)
- RemoteValue.Value/HasValue/Handle moved to typed subclasses
- ArgumentValue replaced by LocalValue
- ValueAs<T>() replaced by ConvertTo<T>() / pattern matching
- SerializeRemoteValue replaced by native ToLocalValue()
- Updated command parameter constructors

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…asing

Use the published NuGet package instead of a local project reference.
Fix RemoteValue.Type ToString to use lowercase for consistency with upstream.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kblok kblok marked this pull request as ready for review March 26, 2026 16:31
kblok and others added 2 commits March 26, 2026 19:46
…ctReference

The migration to the type-safe RemoteValue API incorrectly changed
FormatArgumentAsync to call ToLocalValue() for both handle and no-handle
cases. For handles, this recursively serializes the value instead of
passing it by reference, breaking ExposeFunctionAsync (resolve/reject
functions can't be serialized). Use RemoteObjectReference(handle) for
the has-handle path, matching the pre-migration ToRemoteReference()
behavior.

Reverts to local ProjectReference pending a WebDriverBiDi library fix
for handle assignment on CollectionRemoteValue types.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- NumberRemoteValue replaces LongRemoteValue/DoubleRemoteValue
- GetValueObject handles CollectionRemoteValue and
  KeyValuePairCollectionRemoteValue which don't extend
  ValueHoldingRemoteValue in v0.0.49
- Use IObjectReferenceRemoteValue.ToRemoteObjectReference() for
  passing handles by reference in FormatArgumentAsync

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kblok kblok force-pushed the feature/webdriverbidi-remotevalue-redesign branch from 850173a to 808f778 Compare March 30, 2026 14:34
kblok and others added 5 commits March 30, 2026 16:55
- Use GetValueObject for all RemoteValue items in array deserialization,
  not just ValueHoldingRemoteValue
- Add no-handle fallback for BidiElementHandle in FormatArgumentAsync,
  matching the existing BidiJSHandle guard

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use GetValueObject consistently for all RemoteValue types in
DeserializeRemoteValueDictionary (property and dictionary paths),
not just ValueHoldingRemoteValue. Fixes null properties when
deserializing objects containing arrays or nested objects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace remaining ValueHoldingRemoteValue checks with GetValueObject
in the deep object deserialization path. Fixes circular object
detection and nested array/object deserialization for types that
don't extend ValueHoldingRemoteValue in v0.0.49.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- BidiJSHandle.JsonValueAsync: extract values from CollectionRemoteValue
  and KeyValuePairCollectionRemoteValue, not just ValueHoldingRemoteValue
- BidiJSHandle.GetPropertyAsync: for handleless objects (e.g. console log
  args from BiDi events), look up properties directly from the
  RemoteValueDictionary instead of round-tripping through the browser

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v0.0.49 introduced WebDriverBiDiConnectionException (not a subclass of
WebDriverBiDiException) for remote disconnections. Catch it in
EvaluateAsync and wrap as TargetClosedException to match expected
behavior when the browser closes during command execution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kblok kblok merged commit d6ee78b into master Apr 1, 2026
16 checks passed
@kblok kblok deleted the feature/webdriverbidi-remotevalue-redesign branch April 1, 2026 13:40
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.

1 participant