[rb] add objectOnly/preserveExtras/scalar-primitive BiDi schema signals#17784
Conversation
|
Thank you, @titusfortner for this code suggestion. The support packages contain example code that many users find helpful, but they do not necessarily represent After reviewing the change, unless it is a critical fix or a feature that is needed for Selenium We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks. |
PR Summary by Qodo[rb] Add BiDi schema signals for object-only unions, preserve-extras, and scalar primitives
AI Description
Diagram
High-Level Assessment
Files changed (22)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
22 rules 1.
|
b290135 to
e2b1e6f
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the shared WebDriver BiDi schema projector with three derived “signals” (objectOnly, preserveExtras, and improved scalar primitive typing) and updates the generated Ruby BiDi protocol layer + runtime to consume them, tightening wire-boundary validation and making unknown-key round-tripping behavior schema-driven.
Changes:
- Add projector-derived schema signals (
objectOnly,preserveExtras, and inline-enum primitive / scalar-tolerant inline unions) and unit tests for them in the JavaScript projector. - Update the Ruby BiDi generator and generated protocol to consume these signals (object-only unions reject scalars; only re-sendable extensible records preserve unknown keys; many previously-opaque scalar fields become strictly typed).
- Extend Ruby serialization runtime and add/expand Ruby unit specs covering the new validation behaviors.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rb/spec/unit/selenium/webdriver/bidi/serialization_spec.rb | Adds Ruby unit coverage for object-only unions, scalar-tolerant map-key behavior, preserve-extras gating, and stricter scalar primitive validation. |
| rb/sig/lib/selenium/webdriver/bidi/serialization.rbs | Updates RBS for new serialization helper methods/signatures (read_ref, updated read_list, scalar_value, object_only). |
| rb/sig/lib/selenium/webdriver/bidi/protocol/storage.rbs | Updates generated RBS to reflect preserve-extras gating (removes extensions where no longer stored). |
| rb/sig/lib/selenium/webdriver/bidi/protocol/session.rbs | Updates generated RBS to reflect preserve-extras gating (removes extensions where no longer stored). |
| rb/sig/lib/selenium/webdriver/bidi/protocol/network.rbs | Updates generated RBS to reflect preserve-extras gating (removes extensions where no longer stored). |
| rb/sig/lib/selenium/webdriver/bidi/protocol/emulation.rbs | Tightens RBS types for newly-typed scalar fields (e.g., scrollbar_type: String?). |
| rb/lib/selenium/webdriver/bidi/support/templates/module.rb.erb | Emits object_only on generated union classes when schema indicates unions are object-only. |
| rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb | Generator consumes new schema signals (objectOnly, preserveExtras, scalar) and hoists leaf scalar primitives through alias chains. |
| rb/lib/selenium/webdriver/bidi/serialization/union.rb | Implements object_only unions rejecting non-object inbound payloads. |
| rb/lib/selenium/webdriver/bidi/serialization/record.rb | Adds scalar-tolerant union-position parsing support (scalar metadata) and wires it through list/ref reads. |
| rb/lib/selenium/webdriver/bidi/protocol/web_extension.rb | Regenerated Ruby protocol with stricter primitive typing and object-only union flag adoption. |
| rb/lib/selenium/webdriver/bidi/protocol/storage.rb | Regenerated Ruby protocol reflecting preserveExtras and stricter primitive typing; marks object-only unions. |
| rb/lib/selenium/webdriver/bidi/protocol/session.rb | Regenerated Ruby protocol reflecting preserveExtras and object-only unions. |
| rb/lib/selenium/webdriver/bidi/protocol/script.rb | Regenerated Ruby protocol adopting object-only unions and scalar-tolerant map-key parsing metadata. |
| rb/lib/selenium/webdriver/bidi/protocol/network.rb | Regenerated Ruby protocol adopting object-only unions, preserve-extras gating, and stricter primitive typing. |
| rb/lib/selenium/webdriver/bidi/protocol/log.rb | Regenerated Ruby protocol adopting object-only unions and stricter primitive typing. |
| rb/lib/selenium/webdriver/bidi/protocol/input.rb | Regenerated Ruby protocol adopting object-only unions and stricter primitive typing. |
| rb/lib/selenium/webdriver/bidi/protocol/emulation.rb | Regenerated Ruby protocol adopting object-only unions and inline-enum primitive typing. |
| rb/lib/selenium/webdriver/bidi/protocol/browsing_context.rb | Regenerated Ruby protocol adopting object-only unions and stricter primitive typing. |
| rb/lib/selenium/webdriver/bidi/protocol/browser.rb | Regenerated Ruby protocol adopting object-only unions and stricter primitive typing. |
| rb/lib/selenium/webdriver/bidi/protocol/bluetooth.rb | Regenerated Ruby protocol with stricter primitive typing and object-only union flag adoption. |
| javascript/selenium-webdriver/project_bidi_schema.mjs | Adds derived schema-signal computation and projector support for inline-enum primitives and scalar-tolerant inline unions. |
| javascript/selenium-webdriver/project_bidi_schema_test.mjs | Adds projector unit tests covering the new derived schema signals. |
…es still reject scalars
|
Code review by qodo was updated up to the latest commit 42d4bba |
|
Code review by qodo was updated up to the latest commit e7ff8a5 |
🔗 Related Issues
Builds on #17781 (this branch is rebased onto it — merge that one first; the diff resolves to just the signal changes once #17781 lands on trunk).
Supports the low-level BiDi behavioral contract proposed in #17786: these changes make the Ruby layer exhibit the inbound-strictness items at runtime (object-only unions reject non-objects — item 5; strict primitive/shape field checks — item 6; preserve-extras scoped to extensible-and-re-sendable types — item 8), rather than merely type-checking. The derivations live in the shared projector, so the same signals let the other bindings comply too.
💥 What does this PR do?
Adds three derived signals to the shared BiDi schema projector and consumes them in the generated Ruby binding, so the wire boundary is validated instead of passing malformed payloads through opaque:
objectOnly— a union whose every arm is an object rejects a non-object payload instead of returning it unchanged. Unions with a real scalar arm (e.g.input.Origin) still pass scalars through.preserveExtras— only an extensible type that is also re-sendable (reachable from a command's params) stores and echoes unknown wire properties; a received-only extensible type now drops them.Every derivation lives in the shared projector, so bindings stay in parity by construction; each Ruby change is a one-line consume plus runtime support.
🔧 Implementation Notes
js-uint → integer), matching what the Python/Java generators already do — this is what lets Ruby strictly type ~280 previously-opaque scalar fields.objectOnly: the projector marks an inline union that carries a bare-scalar arm (RemoteValue / text) withscalar, set to that arm's primitive. A binding collapsing the union onto the object-only value union passes a non-object leaf through only when it matches that primitive — a wrong-typed scalar (a number where a string is expected) is still a wire error. The tolerance is derived in the projector, so bindings consume it rather than re-detecting the shape.🤖 AI assistance
💡 Additional Considerations
objectOnly/preserveExtras/scalarare inert until each binding opts in). Follow-up is to consume those signals in the other bindings — includingscalar, so theirobjectOnlyadoption keepsMapping*Valueround-trips working. All four are derived in the projector, so it's a read per binding, not a re-derivation.🔄 Types of changes