Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add protocols option to WebSocket constructor #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ enum BinaryType { "blob", "arraybuffer" };

[Exposed=(Window,Worker)]
interface WebSocket : EventTarget {
constructor(USVString url, optional (DOMString or sequence<DOMString>) protocols = []);
constructor(USVString url, optional (DOMString or sequence<DOMString> or WebSocketInitDict) protocols = []);
readonly attribute USVString url;

// ready state
Expand All @@ -233,6 +233,10 @@ interface WebSocket : EventTarget {
attribute BinaryType binaryType;
undefined send((BufferSource or Blob or USVString) data);
};

dictionary WebSocketInitDict {
sequence<DOMString> protocols = [];
};
</xmp>

Each {{WebSocket}} object has an associated <dfn for="WebSocket" lt="internal-url">url</dfn>, which
Expand Down Expand Up @@ -330,6 +334,8 @@ It can have the following values:
"{{SyntaxError}}" {{DOMException}}.
1. If |urlRecord|'s [=fragment=] is non-null, then throw a "{{SyntaxError}}" {{DOMException}}.
1. If |protocols| is a string, set |protocols| to a sequence consisting of just that string.
1. Otherwise, if |protocols| is a dictionary, set |protocols| to
|protocols|["{{WebSocketInitDict/protocols}}"]
1. If any of the values in |protocols| occur more than once or otherwise fail to match the
requirements for elements that comprise the value of
\`<a http-header>`Sec-WebSocket-Protocol`</a>\` fields as defined by The WebSocket protocol,
Expand Down
Loading