fune/testing/web-platform/tests/websockets/Create-non-absolute-url.any.js
Anne van Kesteren 04a3a0625f Bug 1832520 [wpt PR 39955] - WebSocket: allow HTTP(S) URLs, a=testonly
Automatic update from web-platform-tests
WebSocket: allow HTTP(S) URLs

This makes it possible for people to pass relative URLs. They are immediately translated to the ws: or wss: scheme.

This change also removes a number of redundant tests.
--

wpt-commits: 590d5d63ebbd2c29a8fd986e2101d766aa17df00
wpt-pr: 39955
2023-05-21 22:45:52 +00:00

14 lines
293 B
JavaScript

[
"test",
"?",
null,
123,
].forEach(input => {
test(() => {
const url = new URL(input, location);
url.protocol = "ws";
const ws = new WebSocket(input);
assert_equals(ws.url, url.href);
ws.close();
}, `Create WebSocket - Pass a non absolute URL: ${input}`);
});