Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>test wss connection</title> | 4 <title>test ws connection</title> |
|
cbentzel
2012/08/22 20:19:43
Are there other tests which use ws.html?
bashi
2012/08/23 09:54:15
No tests use ws.html at this time.
| |
| 5 <script type="text/javascript"> | 5 <script type="text/javascript"> |
| 6 | 6 |
| 7 var href = window.location.href; | 7 var href = window.location.href; |
| 8 var portBegin = href.lastIndexOf(':') + 1; | 8 var portBegin = href.lastIndexOf(':') + 1; |
| 9 var portEnd = href.lastIndexOf('/'); | 9 var portEnd = href.lastIndexOf('/'); |
| 10 var port = href.slice(portBegin, portEnd); | 10 var port = href.slice(portBegin, portEnd); |
| 11 var url = 'wss://localhost:' + port + '/websocket/tests/echo'; | 11 var url = 'ws://localhost:' + port + '/websocket/tests/echo'; |
| 12 | 12 |
| 13 // Do connection test. | 13 // Do connection test. |
| 14 var ws = new WebSocket(url); | 14 var ws = new WebSocket(url); |
| 15 | 15 |
| 16 ws.onopen = function() | 16 ws.onopen = function() |
| 17 { | 17 { |
| 18 // Set document title to 'PASS'. The test observer catches this title changes | 18 // Set document title to 'PASS'. The test observer catches this title changes |
| 19 // to know the result. | 19 // to know the result. |
| 20 document.title = 'PASS'; | 20 document.title = 'PASS'; |
| 21 } | 21 } |
| 22 | 22 |
| 23 ws.onclose = function() | 23 ws.onclose = function() |
| 24 { | 24 { |
| 25 // Set document title to 'FAIL'. | 25 // Set document title to 'FAIL'. |
| 26 document.title = 'FAIL'; | 26 document.title = 'FAIL'; |
| 27 } | 27 } |
| 28 | 28 |
| 29 function timeOutCallback() | 29 function timeOutCallback() |
| 30 { | 30 { |
| 31 // Set document title to 'FAIL'. | 31 // Set document title to 'FAIL'. |
| 32 document.title = 'FAIL'; | 32 document.title = 'FAIL'; |
| 33 } | 33 } |
| 34 | 34 |
| 35 setTimeout(timeOutCallback, 3000); | 35 setTimeout(timeOutCallback, 3000); |
|
cbentzel
2012/08/22 20:19:43
Why is this needed? Let's say the ws access is ver
bashi
2012/08/23 09:54:15
I copied this test from wss.html and wss.html has
Takashi Toyoshima
2012/08/23 11:27:26
Yes. Originally, I intended to realize timeout for
bashi
2012/08/23 11:53:24
Thank you. Removed.
cbentzel
2012/08/23 14:56:59
I realized that your approach would fail faster th
| |
| 36 | 36 |
| 37 </script> | 37 </script> |
| 38 </head> | 38 </head> |
| 39 </html> | 39 </html> |
| OLD | NEW |