MCPcopy Create free account
hub / github.com/angular/dev-infra / send

Method send

github-actions/browserstack/set-browserstack-env.js:18387–18420  ·  view source on GitHub ↗

* @see https://websockets.spec.whatwg.org/#dom-websocket-send * @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data

(data)

Source from the content-addressed store, hash-verified

18385 const prefix = "WebSocket constructor";
18386 webidl.argumentLengthCheck(arguments, 1, prefix);
18387 const options = webidl.converters["DOMString or sequence<DOMString> or WebSocketInit"](protocols, prefix, "options");
18388 url = webidl.converters.USVString(url, prefix, "url");
18389 protocols = options.protocols;
18390 const baseURL = environmentSettingsObject.settingsObject.baseUrl;
18391 let urlRecord;
18392 try {
18393 urlRecord = new URL(url, baseURL);
18394 } catch (e) {
18395 throw new DOMException(e, "SyntaxError");
18396 }
18397 if (urlRecord.protocol === "http:") {
18398 urlRecord.protocol = "ws:";
18399 } else if (urlRecord.protocol === "https:") {
18400 urlRecord.protocol = "wss:";
18401 }
18402 if (urlRecord.protocol !== "ws:" && urlRecord.protocol !== "wss:") {
18403 throw new DOMException(
18404 `Expected a ws: or wss: protocol, got ${urlRecord.protocol}`,
18405 "SyntaxError"
18406 );
18407 }
18408 if (urlRecord.hash || urlRecord.href.endsWith("#")) {
18409 throw new DOMException("Got fragment", "SyntaxError");
18410 }
18411 if (typeof protocols === "string") {
18412 protocols = [protocols];
18413 }
18414 if (protocols.length !== new Set(protocols.map((p) => p.toLowerCase())).size) {
18415 throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError");
18416 }
18417 if (protocols.length > 0 && !protocols.every((p) => isValidSubprotocol(p))) {
18418 throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError");
18419 }
18420 this[kWebSocketURL] = new URL(urlRecord.href);
18421 const client = environmentSettingsObject.settingsObject;
18422 this[kController] = establishWebSocketConnection(
18423 urlRecord,

Callers

nothing calls this directly

Calls 7

isConnectingFunction · 0.70
isEstablishedFunction · 0.70
isClosingFunction · 0.70
__privateSetFunction · 0.70
__privateGetFunction · 0.70
isBlobLikeFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected