aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/websockets/basic-auth.any.js
blob: 45e4dadb3b9ce5fbead88dc85d68832b6dd04b5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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();