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