Intent to Prototype: Add options bag to WebSocket constructor

11 views
Skip to first unread message

Chromestatus

unread,
1:57 PM (1 hour ago) 1:57 PM
to blin...@chromium.org, cth...@chromium.org
Contact emails
cth...@chromium.org

Explainer
https://github.com/whatwg/websockets/issues/42
https://github.com/whatwg/websockets/pull/76

Specification
https://github.com/whatwg/websockets/pull/76

Summary
Add support for passing an option bag (WebSocketInit dictionary) as the second argument to the WebSocket constructor. The option bag will initially support a "protocols" option, allowing developers to specify subprotocols (mirroring the existing protocols argument), and also serves as an extension point for future options. Before, this would be written `const socket = new WebSocket("wss://example.com:8080", "soap")`. After, this could also be written `const socket = new WebSocket("wss://example.com:8080", { protocols: "soap" })`. See https://github.com/whatwg/websockets/issues/42 and spec PR https://github.com/whatwg/websockets/pull/76 for this change.

Blink component
Blink>Network>WebSockets

Web Feature ID
websockets

Motivation
There is a demand for extensibility of options on the WebSocket constructor, to mirror the "option bag" approach that the Fetch API has. https://github.com/whatwg/websockets/issues/42 is requested by a number of implementors and users, and Chromium wants this as a means to add a `targetAddressSpace` option matching the one added to Fetch for Local Network Access (https://wicg.github.io/local-network-access/#fetch-api).

Initial public proposal
https://github.com/whatwg/websockets/issues/42

Goals for experimentation
None

Requires code in //chrome?
False

Tracking bug
https://crbug.com/542670554

Estimated milestones

No milestones specified



Link to entry on the Chrome Platform Status
https://chromestatus.com/feature/5080055102439424?gate=5087234207383552

This intent message was generated by Chrome Platform Status.
Reply all
Reply to author
Forward
0 new messages