You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[js][bidi] Add vendor specific class generation - #18125
• Generate vendor-specific BiDi subclasses from schema extensions without adding vendor APIs to
shared classes.
• Wire vendor schema inputs into generation and preserve namespaced command and parameter wire keys.
• Test Mozilla WebExtension inheritance, optional fields, and command serialization.
The following are alternative approaches to this PR:
1. Generate from the existing schema artifact
➕ Uses the already-projected vendor section as a single authoritative input.
➕ Avoids repeating schema projection in the TypeScript generator.
➖ Changes the generator's input contract and Bazel dependency chain.
➖ Broadens this PR beyond vendor class generation.
Recommendation: Keep the PR's focused approach: it reuses the existing projection logic and preserves browser-neutral classes. Consider consuming the existing schema artifact later if maintaining two projection invocations becomes a burden.
Files changed (4) +224 / -18
Enhancement (1) +145 / -15
generate_bidi.mjsGenerate vendor subclasses and their schema-derived types+145/-15
Generate vendor subclasses and their schema-derived types
• Accepts a vendor model and uses projected vendor schema content to emit subclasses of shared BiDi domains. Generates vendor parameter overrides, commands, reachable types, enum constants, and documentation while retaining namespaced wire keys.
vendor_test.jsTest Mozilla vendor class behavior and wire serialization+70/-0
Test Mozilla vendor class behavior and wire serialization
• Verifies that MozWebExtension inherits from the shared class without exposing its commands there. Checks optional vendor fields, namespaced parameter wire keys, and the vendor command wire method.
generate_bidi.bzlPass vendor schema inputs to TypeScript generation+8/-3
Pass vendor schema inputs to TypeScript generation
• Changes the Bazel TypeScript generation step to use the vendor-augmented AST and, when present, the vendor model. This lets generated JavaScript classes consume the same vendor extensions as schema projection.
buildVendorModules adds a vendor-specific browsingContext.getTree override, but the new
vendor_test.js only exercises web-extension commands. The schema gives getTree a moz:scope
parameter, and neither that test nor the existing non-vendor getTree tests check that the override
sends it under its namespaced wire key.
The schema declares moz:scope on the command's parameter type, and the changed generator creates
an override for matching command parameters. The new vendor tests cover only the web-extension
class; the existing generated browsing-context tests call the ordinary class.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The new vendor-specific browsing-context command has no test for its `moz:scope` wire parameter.
## Fix Focus Areas
- javascript/selenium-webdriver/test/bidi/vendor_test.js[36-70]
## Recommended Fix
Add a focused test that calls the generated Firefox browsing-context class's `getTree` method with `scope` and asserts that the sent parameters contain `moz:scope`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
2. Standard commands send unchecked fields✗ Dismissed
Description
generateTypeScript marks every vendor-extended shared record as extensible, which also disables
unknown-property rejection when that record is constructed for an outbound command. A caller using
the standard WebExtension.install can now send misspelled parameters or raw Firefox fields without
validation, even though webExtension.InstallParameters declares neither.
+ if (schema.types[typeName]) schema.types[typeName] = { ...schema.types[typeName], extensible: true }
Evidence
The schema places Firefox install fields in vendor.moz.extends, while the shared install
parameters declare only extensionData. The changed flag is passed to the shared record's
defineRecord call. In that record's constructor, extensible permits any undeclared property, and
toJSON sends it under its original key.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
Marking shared vendor-extended records as extensible preserves inbound vendor fields but also lets standard commands send undeclared parameters without validation.
## Fix Focus Areas
- javascript/selenium-webdriver/generate_bidi.mjs[276-282]
- javascript/selenium-webdriver/bidi/serialization/record.js[245-288]
## Recommended Fix
Represent inbound retention separately from outbound extensibility. Preserve unknown wire fields when parsing vendor-extended shared records, but keep outbound construction of otherwise closed standard records strict; add tests for both directions.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
3. Firefox context details disappear✓ Resolved
Description
buildVendorModules processes an extended record only when it is a command's direct parameter type,
leaving the Firefox extension of browsingContext.Info out of the generated records. When the new
Firefox variant returns a context tree, inbound record parsing drops its moz:name and moz:scope
fields; context events containing the same record are affected too.
+ for (const [typeName, entry] of Object.entries(section.extends ?? {})) {+ const cmd = schema.commands.find((c) => c.params?.ref === typeName)+ if (!cmd || cmd.domain !== domain) continue+ const base = schema.types[typeName]+ const taken = new Set(base.fields.map((f) => f.name))
Evidence
The vendor schema extends browsingContext.Info, while getTree returns an InfoList nested
inside its result rather than taking Info as parameters. The generated result is parsed through
registered records, whose non-extensible inbound parser warns and omits undeclared fields.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
Firefox-specific fields on context information records are discarded during inbound parsing, including on the newly generated vendor variant.
## Fix Focus Areas
- javascript/selenium-webdriver/generate_bidi.mjs[665-674]
- javascript/selenium-webdriver/generate_bidi.mjs[1034-1049]
## Recommended Fix
Generate and use vendor-aware types for extended inbound records, including records nested in command results and event payloads. Ensure parsing retains the namespaced fields as typed JavaScript properties and add a context-tree and event test.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
4. Firefox debugging commands are absent 🐞 Bug≡ Correctness
Description
generateTypeScript calls buildVendorModules only while iterating the fixed list of standard
domains, so vendor-only domains never receive an output file. The schema includes Firefox debugging
and profiler commands and debugging events, none of which appear in the generated JavaScript API.
The generator loops over standard DOMAIN_FILES and builds vendor modules only for each matching
standard domain; the schema's moz:debugging and moz:profiler domains cannot match that loop.
Bazel likewise declares only the fixed domain output files.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
Vendor-only domains in the projected schema have no generated output, leaving their commands and events unavailable.
## Fix Focus Areas
- javascript/selenium-webdriver/generate_bidi.mjs[280-305]
- javascript/selenium-webdriver/private/generate_bidi.bzl[314-331]
## Recommended Fix
Add generated modules and declared build outputs for supported vendor-only domains. Generate their types, commands and events from the vendor schema, and test that consumers can call them.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
buildVendorModules matches extensions only against a command's direct params.ref, so it skips
the Firefox extension of session.CapabilityRequest nested beneath session.NewParameters. Callers
of session.new receive no vendor-typed argument for Firefox options, although JavaScript callers
can still pass a raw namespaced key through the extensible standard record.
+ for (const [typeName, entry] of Object.entries(section.extends ?? {})) {+ const cmd = schema.commands.find((c) => c.params?.ref === typeName)+ if (!cmd || cmd.domain !== domain) continue
Evidence
The schema declares moz:firefoxOptions on session.CapabilityRequest, but session.new directly
takes session.NewParameters, which references that capability record through
session.CapabilitiesRequest. The direct equality test therefore never builds a vendor session
override; the standard capability record is extensible, explaining why raw wire-key access remains
possible.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The generator ignores the Firefox capability-request extension because the extended record is nested inside session creation parameters.
## Fix Focus Areas
- javascript/selenium-webdriver/generate_bidi.mjs[665-674]
- javascript/selenium-webdriver/generate_bidi.mjs[693-699]
## Recommended Fix
Follow command-parameter type references when identifying vendor extensions. Generate the necessary nested vendor types and session variant, mapping the typed Firefox option to its namespaced wire key; add a session-creation serialization test.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Review mode: Auto: ⚖️ Balanced: Downgraded extended -> standard: change is below the extended eligibility bar (hunks 16/18, lines 282/200; both must reach the floor). Router rationale: Substantial generator, build, and vendor-path logic has multiple subtle defect opportunities.
Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR
buildVendorModules adds a vendor-specific browsingContext.getTree override, but the new
vendor_test.js only exercises web-extension commands. The schema gives getTree a moz:scope
parameter, and neither that test nor the existing non-vendor getTree tests check that the override
sends it under its namespaced wire key.
The schema declares moz:scope on the command's parameter type, and the changed generator creates
an override for matching command parameters. The new vendor tests cover only the web-extension
class; the existing generated browsing-context tests call the ordinary class.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The new vendor-specific browsing-context command has no test for its `moz:scope` wire parameter.
## Fix Focus Areas
- javascript/selenium-webdriver/test/bidi/vendor_test.js[36-70]
## Recommended Fix
Add a focused test that calls the generated Firefox browsing-context class's `getTree` method with `scope` and asserts that the sent parameters contain `moz:scope`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
2. Firefox debugging commands are absent 🐞 Bug≡ Correctness
Description
generateTypeScript calls buildVendorModules only while iterating the fixed list of standard
domains, so vendor-only domains never receive an output file. The schema includes Firefox debugging
and profiler commands and debugging events, none of which appear in the generated JavaScript API.
The generator loops over standard DOMAIN_FILES and builds vendor modules only for each matching
standard domain; the schema's moz:debugging and moz:profiler domains cannot match that loop.
Bazel likewise declares only the fixed domain output files.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
Vendor-only domains in the projected schema have no generated output, leaving their commands and events unavailable.
## Fix Focus Areas
- javascript/selenium-webdriver/generate_bidi.mjs[280-305]
- javascript/selenium-webdriver/private/generate_bidi.bzl[314-331]
## Recommended Fix
Add generated modules and declared build outputs for supported vendor-only domains. Generate their types, commands and events from the vendor schema, and test that consumers can call them.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
buildVendorModules matches extensions only against a command's direct params.ref, so it skips
the Firefox extension of session.CapabilityRequest nested beneath session.NewParameters. Callers
of session.new receive no vendor-typed argument for Firefox options, although JavaScript callers
can still pass a raw namespaced key through the extensible standard record.
+ for (const [typeName, entry] of Object.entries(section.extends ?? {})) {+ const cmd = schema.commands.find((c) => c.params?.ref === typeName)+ if (!cmd || cmd.domain !== domain) continue
Evidence
The schema declares moz:firefoxOptions on session.CapabilityRequest, but session.new directly
takes session.NewParameters, which references that capability record through
session.CapabilitiesRequest. The direct equality test therefore never builds a vendor session
override; the standard capability record is extensible, explaining why raw wire-key access remains
possible.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The generator ignores the Firefox capability-request extension because the extended record is nested inside session creation parameters.
## Fix Focus Areas
- javascript/selenium-webdriver/generate_bidi.mjs[665-674]
- javascript/selenium-webdriver/generate_bidi.mjs[693-699]
## Recommended Fix
Follow command-parameter type references when identifying vendor extensions. Generate the necessary nested vendor types and session variant, mapping the typed Firefox option to its namespaced wire key; add a session-creation serialization test.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
buildVendorModules processes an extended record only when it is a command's direct parameter type,
leaving the Firefox extension of browsingContext.Info out of the generated records. When the new
Firefox variant returns a context tree, inbound record parsing drops its moz:name and moz:scope
fields; context events containing the same record are affected too.
+ for (const [typeName, entry] of Object.entries(section.extends ?? {})) {+ const cmd = schema.commands.find((c) => c.params?.ref === typeName)+ if (!cmd || cmd.domain !== domain) continue+ const base = schema.types[typeName]+ const taken = new Set(base.fields.map((f) => f.name))
Evidence
The vendor schema extends browsingContext.Info, while getTree returns an InfoList nested
inside its result rather than taking Info as parameters. The generated result is parsed through
registered records, whose non-extensible inbound parser warns and omits undeclared fields.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
Firefox-specific fields on context information records are discarded during inbound parsing, including on the newly generated vendor variant.
## Fix Focus Areas
- javascript/selenium-webdriver/generate_bidi.mjs[665-674]
- javascript/selenium-webdriver/generate_bidi.mjs[1034-1049]
## Recommended Fix
Generate and use vendor-aware types for extended inbound records, including records nested in command results and event payloads. Ensure parsing retains the namespaced fields as typed JavaScript properties and add a context-tree and event test.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
B-buildIncludes scripting, bazel and CI integrationsB-devtoolsIncludes everything BiDi or Chrome DevTools relatedC-nodejsJavaScript Bindings
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Related Issues
💥 What does this PR do?
Reads the schema to add vendors specific classes, to do so, the generator is modified in the PR.
🔧 Implementation Notes
🤖 AI assistance
💡 Additional Considerations
🔄 Types of changes