Chromium Code Reviews| Index: LayoutTests/http/tests/websocket/tests/hybi/connect-error-by-no-websocket-server.html |
| diff --git a/LayoutTests/http/tests/websocket/tests/hybi/connect-error-by-no-websocket-server.html b/LayoutTests/http/tests/websocket/tests/hybi/connect-error-by-no-websocket-server.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0684a8db4aa22fb58a1558c5bc47f59d9d9d4b9b |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/websocket/tests/hybi/connect-error-by-no-websocket-server.html |
| @@ -0,0 +1,89 @@ |
| +<!DOCTYPE HTML> |
|
tyoshino (SeeGerritForStatus)
2013/04/18 02:01:12
HTML -> html
|
| +<html> |
| +<head> |
| +<script src="../../../../js-test-resources/js-test-pre.js"></script> |
|
tyoshino (SeeGerritForStatus)
2013/04/15 14:16:43
please remove ../../../..
|
| +</head> |
| +<body> |
| +<div id="description"></div> |
| +<div id="console"></div> |
| +<script> |
| +description("Test that WebSocket fires error event if no WebSocket Server can be connected."); |
| + |
| +window.jsTestIsAsync = true; |
| + |
| +function endTest() |
| +{ |
| + clearTimeout(timeoutID); |
| + finishJSTest(); |
| +} |
| + |
| +var url = "ws://localhost:8888"; //here it should have no websocket server to listen. |
|
tyoshino (SeeGerritForStatus)
2013/04/18 02:01:12
follow the Google's js style guide.
"...; // Here
|
| + |
| +function doTest(index) |
| +{ |
| + debug("test" + index + " Start"); |
| + |
| + var ws = new WebSocket(url); |
| + |
| + ws.onopen = function() |
| + { |
| + testFailed("Connected"); |
| + endTest(); |
| + }; |
| + |
| + ws.onmessage = function(messageEvent) |
| + { |
| + testFailed("Received Message"); |
| + ws.close(); |
| + endTest(); |
| + }; |
| + |
| + if (index == 0) { |
| + ws.onclose = function() |
| + { |
| + testPassed("onclose was called"); |
| + doTest(index + 1); |
| + }; |
| + ws.onerror = function() |
| + { |
| + testPassed("onerror was called"); |
| + }; |
| + } else if (index == 1) { |
| + ws.onclose = function() |
| + { |
| + testPassed("onclose was called"); |
| + ws.close(); |
| + doTest(index + 1); |
| + }; |
| + ws.onerror = function() |
| + { |
| + testPassed("onerror was called"); |
| + }; |
| + } else { |
| + ws.onclose = function() |
| + { |
| + testPassed("onclose was called"); |
| + endTest(); |
| + }; |
| + ws.onerror = function() |
| + { |
| + testPassed("onerror was called"); |
| + ws.close(); |
| + }; |
| + } |
|
tyoshino (SeeGerritForStatus)
2013/04/18 02:01:12
nice test :)
|
| +} |
| + |
| +function timeOutCallback() |
| +{ |
| + debug("Timed out..."); |
| + endTest(); |
| +} |
| + |
| +var timeoutID = setTimeout(timeOutCallback, 3000); |
| + |
| +doTest(0); |
| + |
| +</script> |
| +<script src="../../../../js-test-resources/js-test-post.js"></script> |
| +</body> |
| +</html> |