* @param {string} url * @param {string|string[]} protocols
(url, protocols = [])
| 15940 | * @param {string|string[]} protocols |
| 15941 | */ |
| 15942 | constructor(url, protocols = []) { |
| 15943 | super(); |
| 15944 | webidl.util.markAsUncloneable(this); |
| 15945 | const prefix = "WebSocket constructor"; |
| 15946 | webidl.argumentLengthCheck(arguments, 1, prefix); |
| 15947 | const options = webidl.converters["DOMString or sequence<DOMString> or WebSocketInit"](protocols, prefix, "options"); |
| 15948 | url = webidl.converters.USVString(url); |
| 15949 | protocols = options.protocols; |
| 15950 | const baseURL = environmentSettingsObject.settingsObject.baseUrl; |
| 15951 | const urlRecord = getURLRecord(url, baseURL); |
| 15952 | if (typeof protocols === "string") { |
| 15953 | protocols = [protocols]; |
| 15954 | } |
| 15955 | if (protocols.length !== new Set(protocols.map((p) => p.toLowerCase())).size) { |
| 15956 | throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError"); |
| 15957 | } |
| 15958 | if (protocols.length > 0 && !protocols.every((p) => isValidSubprotocol(p))) { |
| 15959 | throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError"); |
| 15960 | } |
| 15961 | this.#url = new URL(urlRecord.href); |
| 15962 | const client = environmentSettingsObject.settingsObject; |
| 15963 | this.#handler.controller = establishWebSocketConnection( |
| 15964 | urlRecord, |
| 15965 | protocols, |
| 15966 | client, |
| 15967 | this.#handler, |
| 15968 | options |
| 15969 | ); |
| 15970 | this.#handler.readyState = _WebSocket.CONNECTING; |
| 15971 | this.#binaryType = "blob"; |
| 15972 | } |
| 15973 | /** |
| 15974 | * @see https://websockets.spec.whatwg.org/#dom-websocket-close |
| 15975 | * @param {number|undefined} code |
nothing calls this directly
no test coverage detected