Chromium Code Reviews| 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("Test that WebSocket handshake fails if Upgrade header field isn't r eflected by the server."); | 10 description("Test that WebSocket handshake fails if Upgrade header field isn't r eflected by the server."); |
| 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 url = "ws://localhost:8880/handshake-fail-by-no-upgrade-header"; | 20 var url = "ws://localhost:8880/handshake-fail-by-no-upgrade-header"; |
| 21 var ws = new WebSocket(url); | 21 var ws = new WebSocket(url); |
| 22 | 22 |
| 23 ws.onopen = function() | 23 ws.onopen = function() |
| 24 { | 24 { |
| 25 debug("FAIL: Connected"); | 25 debug("FAIL: Connected"); |
|
tyoshino (SeeGerritForStatus)
2015/01/13 05:31:52
testFailed("Unexpectedly Connected.");
Paritosh Kumar
2015/01/13 10:20:28
Done.
| |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 ws.onmessage = function(messageEvent) | 28 ws.onmessage = function(messageEvent) |
| 29 { | 29 { |
| 30 protocol = messageEvent.data; | 30 protocol = messageEvent.data; |
| 31 ws.close(); | 31 ws.close(); |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 ws.onclose = function() | 34 ws.onclose = function() |
| 35 { | 35 { |
| 36 endTest(); | 36 endTest(); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 ws.onerror = function(errorEvent) | |
| 40 { | |
| 41 debug("PASS: onerror called"); | |
|
tyoshino (SeeGerritForStatus)
2015/01/13 05:31:52
testPassed("onerror() was called");
Paritosh Kumar
2015/01/13 10:20:28
Done.
| |
| 42 }; | |
| 43 | |
| 39 function timeOutCallback() | 44 function timeOutCallback() |
| 40 { | 45 { |
| 41 debug("Timed out in state: " + ws.readyState); | 46 debug("Timed out in state: " + ws.readyState); |
| 42 endTest(); | 47 endTest(); |
| 43 } | 48 } |
| 44 | 49 |
| 45 var timeoutID = setTimeout(timeOutCallback, 3000); | 50 var timeoutID = setTimeout(timeOutCallback, 3000); |
| 46 | 51 |
| 47 </script> | 52 </script> |
| 48 </body> | 53 </body> |
| 49 </html> | 54 </html> |
| OLD | NEW |