blob: 750c43c5ae35a4ea2b0a70b6526fcd04398f7df4 [file] [log] [blame]
Andrew Top61a84952019-04-30 15:07:33 -07001<!DOCTYPE html>
2<html>
3<head>
4 <title>W3C WebSocket API - Close Secure WebSocket - Code is 1000 and reason</title>
5 <script type="text/javascript" src="/resources/testharness.js"></script>
6 <script type="text/javascript" src="/resources/testharnessreport.js"></script>
7 <script type="text/javascript" src="websocket.js?pipe=sub"></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 Secure WebSocket - Close the Connection - close(1000, reason) - Connection should be opened");
14 var testClose = async_test("W3C WebSocket API - Create Secure WebSocket - Close the Connection - close(1000, reason) - readyState should be in CLOSED state and wasClean is TRUE - Connection should be closed");
15
16 var wsocket = CreateWebSocket(true, false, false);
17 var isOpenCalled = false;
18
19 wsocket.addEventListener('open', testOpen.step_func(function (evt) {
20 wsocket.close(1000, "Clean Close");
21 isOpenCalled = true;
22 testOpen.done();
23 }), true);
24
25 wsocket.addEventListener('close', testClose.step_func(function (evt) {
26 assert_true(isOpenCalled, "WebSocket connection should be open");
27 assert_equals(wsocket.readyState, 3, "readyState should be 3(CLOSED)");
28 assert_equals(evt.wasClean, true, "wasClean should be TRUE");
29 testClose.done();
30 }), true);
31
32 </script>
33
34</body>
35</html>