gecko-dev/testing/web-platform/tests/websockets/basic-auth.any.js
Adam Rice 976bc76518 Bug 1467894 [wpt PR 11433] - Add test for WebSocket HTTP Authentication, a=testonly
Automatic update from web-platform-testsAdd test for WebSocket HTTP Authentication (#11433)

User-agents should support HTTP authentication for WebSockets. Add a
test of basic authentication to verify this.
--

wpt-commits: f3bc9cfcbb9a0c5bbebc549ad37d93e2cf26167c
wpt-pr: 11433
2018-07-11 07:51:40 +01:00

18 lines
604 B
JavaScript

// META: script=websocket.sub.js
// META: global=sharedworker,serviceworker
async_test(t => {
const isSecure = new URL(location.href).scheme === 'https';
const scheme = isSecure ? 'wss' : 'ws';
const port = isSecure ? __SECURE__PORT : __PORT;
const url = scheme + '://' + 'foo:bar@' + __SERVER__NAME + ':' + port + '/basic_auth';
const ws = new WebSocket(url);
ws.onopen = () => {
ws.onclose = ws.onerror = null;
ws.close();
t.done();
};
ws.onerror = ws.onclose = t.unreached_func('open should succeed');
}, 'HTTP basic authentication should work with WebSockets');
done();