1<!DOCTYPE html> 2<html> 3<head> 4<title>test ws split packet</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 + '/close-with-split-packet'; 16 17// Do connection test. 18var ws = new WebSocket(url); 19 20ws.onopen = function() 21{ 22 // Close WebSocket connection once it is established. 23 ws.close(); 24} 25 26ws.onclose = function(event) 27{ 28 // Check wasClean, then set proper title. 29 if (event.wasClean) 30 document.title = 'PASS'; 31 else 32 document.title = 'FAIL'; 33} 34 35</script> 36</head> 37</html> 38