OLD | NEW |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="/js-test-resources/js-test.js"></script> | 4 <script src="/js-test-resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <div id="description"></div> | 7 <div id="description"></div> |
8 <div id="console"></div> | 8 <div id="console"></div> |
9 <script type="text/javascript"> | 9 <script type="text/javascript"> |
10 description("Simple WebSocket test"); | 10 description("Simple WebSocket test"); |
11 | 11 |
12 window.jsTestIsAsync = true; | 12 window.jsTestIsAsync = true; |
13 | 13 |
14 function endTest() | 14 function endTest() |
15 { | 15 { |
16 clearTimeout(timeoutID); | 16 clearTimeout(timeoutID); |
17 finishJSTest(); | 17 finishJSTest(); |
18 } | 18 } |
19 | 19 |
20 var ws = new WebSocket("ws://127.0.0.1:8880/simple"); | 20 var ws = new WebSocket("ws://127.0.0.1:8880/simple"); |
21 debug("Created a socket to '" + ws.URL + "'; readyState " + ws.readyState + ".")
; | 21 debug("Created a socket to '" + ws.url + "'; readyState " + ws.readyState + ".")
; |
22 | 22 |
23 ws.onopen = function() | 23 ws.onopen = function() |
24 { | 24 { |
25 debug("Connected; readyState " + ws.readyState); | 25 debug("Connected; readyState " + ws.readyState); |
26 }; | 26 }; |
27 | 27 |
28 ws.onmessage = function(messageEvent) | 28 ws.onmessage = function(messageEvent) |
29 { | 29 { |
30 debug("Received: '" + messageEvent.data + "'; readyState " + ws.readyState); | 30 debug("Received: '" + messageEvent.data + "'; readyState " + ws.readyState); |
31 }; | 31 }; |
32 | 32 |
33 ws.onclose = function() | 33 ws.onclose = function() |
34 { | 34 { |
35 debug("Closed; readyState " + ws.readyState + "."); | 35 debug("Closed; readyState " + ws.readyState + "."); |
36 endTest(); | 36 endTest(); |
37 }; | 37 }; |
38 | 38 |
39 function timeOutCallback() | 39 function timeOutCallback() |
40 { | 40 { |
41 debug("Timed out in state: " + ws.readyState); | 41 debug("Timed out in state: " + ws.readyState); |
42 endTest(); | 42 endTest(); |
43 } | 43 } |
44 | 44 |
45 var timeoutID = setTimeout(timeOutCallback, 3000); | 45 var timeoutID = setTimeout(timeOutCallback, 3000); |
46 | 46 |
47 </script> | 47 </script> |
48 </body> | 48 </body> |
49 </html> | 49 </html> |
OLD | NEW |