1<!DOCTYPE html> 2<html> 3<head> 4<title>test ws connection</title> 5<script type="text/javascript"> 6 7var href = window.location.href; 8var hostBegin = href.indexOf('/') + 2; 9var hostEnd = href.lastIndexOf(':'); 10var host = href.slice(hostBegin, hostEnd); 11var portBegin = hostEnd + 1; 12var portEnd = href.lastIndexOf('/'); 13var port = href.slice(portBegin, portEnd); 14var scheme = href.indexOf('https') >= 0 ? 'wss' : 'ws'; 15var url = scheme + '://' + host + ':' + port + '/echo-with-no-extension'; 16 17// Do connection test. 18var ws = new WebSocket(url); 19 20ws.onopen = function() 21{ 22 // Set document title to 'PASS'. The test observer catches this title changes 23 // to know the result. 24 document.title = 'PASS'; 25} 26 27ws.onclose = function() 28{ 29 // Set document title to 'FAIL'. 30 document.title = 'FAIL'; 31} 32 33</script> 34</head> 35</html> 36