Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Unified Diff: LayoutTests/http/tests/websocket/tests/hybi/connect-error-by-no-websocket-server.html

Issue 14071008: WebSocket object should fire error event when WebSocket server can't be connected. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Add new layouttests into TestExceptions because it depends on chromium side patch Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..fdf21412bfd0ce532f6f14e7afbb449aef093b8c
--- /dev/null
+++ b/LayoutTests/http/tests/websocket/tests/hybi/connect-error-by-no-websocket-server.html
@@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="/js-test-resources/js-test-pre.js"></script>
+</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.
+
+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();
+ };
+ }
+}
+
+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>

Powered by Google App Engine
This is Rietveld 408576698