1<html> 2<body> 3<div id=result></div> 4<script> 5function log(message) 6{ 7 document.getElementById("result").innerHTML += message + "<br>"; 8} 9var worker = new SharedWorker("websocket_worker_simple.js"); 10var href = window.location.href; 11var hostBegin = href.indexOf("/") + 2; 12var hostEnd = href.lastIndexOf(":"); 13var host = href.slice(hostBegin, hostEnd); 14var portBegin = hostEnd + 1; 15var portEnd = href.lastIndexOf("/"); 16var port = href.slice(portBegin, portEnd); 17var url = "ws://" + host + ":" + port + "/echo-with-no-extension"; 18worker.port.onmessage = function (evt) { 19 log(evt.data); 20 if (evt.data == "DONE") { 21 document.title = "OK"; 22 } else { 23 document.title = "FAIL"; 24 } 25}; 26worker.port.postMessage(url); 27 28</script> 29</body> 30</html> 31 32