[🐛 Bug]: [bidi] Vendor extensions should not make a spec type extensible

Open
#18,184 10 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Active
Domain
api

Research direction

Start with extensible_record? in rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb and the extensibility check in javascript/selenium-webdriver/generate_bidi.mjs, then read docs/decisions/17786-bidi-low-level-behavioral-contract.md. The issue asks for a design decision among four options, not a code patch, so a useful first step is a comment on which option the maintainers prefer. Done means that decision is recorded and the generators are changed to match.

Written by the indexing model from the issue text.

Description

A-needs decision B-devtools C-java C-nodejs C-py C-rb I-enhancement
Description

Problem

Firefox's CDDL adds two fields to browsingContext.Info: moz:name and moz:scope. The Ruby and JavaScript generators respond by making Info extensible, so it accepts and keeps any unknown field, not just these two.

The spec does not mark Info as extensible, and Firefox only adds two named fields. The generators add the extensibility themselves:

The same happens to browsingContext.GetTreeParameters and webExtension.InstallParameters, so callers can also send any extra field on them.

Why it matters

ADR 17786 says only types the spec marks extensible may carry or send extra fields, and an unknown field on any other type is logged and dropped (decisions 1, 6 and 9).

Proposal

In every option, a vendor extension no longer changes whether a spec type is extensible. The options differ in what happens to the vendor fields themselves.

Option 1: Add typed vendor fields to the shared type (what Python does today)

  • Info gets mozName / mozScope.
  • Pro: Firefox data is kept and typed.
  • Con: Firefox-only members appear on a shared type and are always empty for other browsers, which is confusing.

Option 2: Treat vendor fields as unknown (what Java does in its in-progress work)

  • Log a warning and drop them.
  • Pro: simplest; shared types stay browser-neutral.
  • Con: Firefox data is lost, and every Firefox response logs a warning.

Option 3: Vendor-specific types

  • For example, MozBrowsingContext.getTree() returns a MozInfo with the typed fields.
  • Pro: typed, and shared types stay browser-neutral.
  • Con: means copying whole result types; Info.children is itself a list of Info, so the entire getTree result tree would be duplicated.

Option 4: Keep the current Ruby and JavaScript behavior and update the ADR

  • A vendor-extended type becomes extensible, and the ADR is amended to allow it.
  • Pro: no change to Ruby or JavaScript, and Firefox data is kept.
  • Con: the vendor fields stay untyped, and these types accept and send any extra field, not just the vendor ones. Java, Python and .NET would need to adopt the same behavior.

With options 1 to 3, Ruby and JavaScript need to stop marking these types extensible. With option 4, the ADR and the other bindings change instead.

Open to any other solutions to this as well.

Reproducible Code
It's how the BiDi generators in different languages implement vendor part of the schema.
Dominant language
Java
Stars
34.6k
Forks
8.7k
Avg merge
1d 16h
Merged PRs (30d)
107

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SeleniumHQ/selenium

All issues in SeleniumHQ/selenium

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.