summaryrefslogtreecommitdiff
path: root/chromium/net/data/websocket/connect_check.html
blob: 4a1ca8c5dfc0b7cb86b86f019a3a4038db867f35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<html>
<head>
<title>test ws connection</title>
<script type="text/javascript">

var href = window.location.href;
var hostBegin = href.indexOf('/') + 2;
var hostEnd = href.lastIndexOf(':');
var host = href.slice(hostBegin, hostEnd);
var portBegin = hostEnd + 1;
var portEnd = href.lastIndexOf('/');
var port = href.slice(portBegin, portEnd);
var scheme = href.indexOf('https') >= 0 ? 'wss' : 'ws';
var url = scheme + '://' + host + ':' + port + '/echo-with-no-extension';

// Do connection test.
var ws = new WebSocket(url);

ws.onopen = function()
{
  // Set document title to 'PASS'. The test observer catches this title changes
  // to know the result.
  document.title = 'PASS';
}

ws.onclose = function()
{
  // Set document title to 'FAIL'.
  document.title = 'FAIL';
}

</script>
</head>
</html>