OLD | NEW |
---|---|
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
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> | 9 <script> |
10 description('Connection should fail immediately, rather than succeeding or stayi ng in limbo until timeout, if handshake is longer than 1024 bytes.'); | 10 description('Connection should fail immediately, rather than succeeding or stayi ng in limbo until timeout, if handshake is longer than 1024 bytes.'); |
11 | 11 |
12 window.jsTestIsAsync = true; | 12 window.jsTestIsAsync = true; |
13 | 13 |
14 var timedOut = false; | 14 var timedOut = false; |
15 var connected = false; | 15 var connected = false; |
16 var origin; | 16 var wsOrigin; |
Mike West
2017/02/21 14:20:06
Can you add the new bug number to the `BUG=` line
andypaicu
2017/02/21 14:25:57
Done
| |
17 | 17 |
18 function endTest() { | 18 function endTest() { |
19 shouldBeFalse('timedOut'); | 19 shouldBeFalse('timedOut'); |
20 shouldBeFalse('connected'); | 20 shouldBeFalse('connected'); |
21 shouldBeUndefined('origin'); | 21 shouldBeUndefined('wsOrigin'); |
22 clearTimeout(timeoutID); | 22 clearTimeout(timeoutID); |
23 finishJSTest(); | 23 finishJSTest(); |
24 } | 24 } |
25 | 25 |
26 var url = 'ws://localhost:8880/handshake-fail-by-maxlength'; | 26 var url = 'ws://localhost:8880/handshake-fail-by-maxlength'; |
27 var ws = new WebSocket(url); | 27 var ws = new WebSocket(url); |
28 | 28 |
29 ws.onopen = function() | 29 ws.onopen = function() |
30 { | 30 { |
31 debug('Connected'); | 31 debug('Connected'); |
32 connected = true; | 32 connected = true; |
33 } | 33 } |
34 | 34 |
35 ws.onmessage = function(messageEvent) | 35 ws.onmessage = function(messageEvent) |
36 { | 36 { |
37 origin = messageEvent.data; | 37 wsOrigin = messageEvent.data; |
38 debug('origin = ' + origin); | 38 debug('origin = ' + wsOrigin); |
39 ws.close(); | 39 ws.close(); |
40 } | 40 } |
41 | 41 |
42 ws.onclose = function() | 42 ws.onclose = function() |
43 { | 43 { |
44 endTest(); | 44 endTest(); |
45 } | 45 } |
46 | 46 |
47 ws.onerror = function(errorEvent) | 47 ws.onerror = function(errorEvent) |
48 { | 48 { |
49 testPassed("onerror() was called"); | 49 testPassed("onerror() was called"); |
50 } | 50 } |
51 | 51 |
52 function timeoutCallback() | 52 function timeoutCallback() |
53 { | 53 { |
54 debug('Timed out (state = ' + ws.readyState + ')'); | 54 debug('Timed out (state = ' + ws.readyState + ')'); |
55 timedOut = true; | 55 timedOut = true; |
56 endTest(); | 56 endTest(); |
57 } | 57 } |
58 | 58 |
59 var timeoutID = setTimeout(timeoutCallback, 3000); | 59 var timeoutID = setTimeout(timeoutCallback, 3000); |
60 | 60 |
61 </script> | 61 </script> |
62 </body> | 62 </body> |
63 </html> | 63 </html> |
OLD | NEW |