blob: 0a6dd97f0dada353763c0480683be447a0fb3fa0 [file] [log] [blame]
Philip Jägenstedtc053f402014-01-22 17:02:181<!DOCTYPE html>
2<html>
3<head>
4 <title>W3C WebSocket API - Create WebSocket with a valid url and protocol string</title>
Ms2gerb26c70f2016-03-01 14:53:115 <script type="text/javascript" src="websocket.sub.js"></script>
Philip Jägenstedtc053f402014-01-22 17:02:186 <script type="text/javascript" src="/resources/testharness.js"></script>
7 <script type="text/javascript" src="/resources/testharnessreport.js"></script>
8</head>
9<body>
10 <div id="log"></div>
11 <script type="text/javascript">
12
13 var testOpen = async_test("W3C WebSocket API - Create WebSocket - Pass a valid URL and a protocol string - Connection should be opened");
14 var testClose = async_test("W3C WebSocket API - Create WebSocket - Pass a valid URL and a protocol string - Connection should be closed");
15
16 var wsocket = CreateWebSocket(false, true, false);
17 var isOpenCalled = false;
18
19 wsocket.addEventListener('open', testOpen.step_func(function (evt) {
20 assert_equals(wsocket.readyState, 1, "readyState should be 1(OPEN)");
21 wsocket.close();
22 isOpenCalled = true;
23 testOpen.done();
24 }), true);
25
26 wsocket.addEventListener('close', testClose.step_func(function (evt) {
27 assert_true(isOpenCalled, "WebSocket connection should be open");
28 assert_equals(evt.wasClean, true, "wasClean should be true");
29 testClose.done();
30 }), true);
31
plehegar09d95c52015-01-16 22:27:4432 </script>
Philip Jägenstedtc053f402014-01-22 17:02:1833</body>
34</html>