1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>test ws connection</title> 5 <script type="text/javascript"> 6 var protocol = location.protocol.replace('http', 'ws'); 7 var url = protocol + '//' + location.host + '/echo-with-no-extension'; 8 // Do connection test. 9 var ws = new WebSocket(url); 10 11 ws.onopen = function() 12 { 13 // Set document title to 'PASS'. The test observer catches this title changes 14 // to know the result. 15 document.title = 'PASS'; 16 } 17 18 ws.onclose = function() 19 { 20 // Set document title to 'FAIL'. 21 document.title = 'FAIL'; 22 } 23 24 </script> 25 </head> 26 </html> 27