blob: 9ad8d618cad3a2c97e8460d6afbb1368ec7b93b5 [file] [log] [blame]
Philip Jägenstedtc053f402014-01-22 17:02:181<!DOCTYPE html>
2<html>
3<head>
4 <title>W3C WebSocket API - Close WebSocket - Reason with unpaired surrogates</title>
5 <script type="text/javascript" src="/resources/testharness.js"></script>
6 <script type="text/javascript" src="/resources/testharnessreport.js"></script>
Ms2gerb26c70f2016-03-01 14:53:117 <script type="text/javascript" src="websocket.sub.js"></script>
Philip Jägenstedtc053f402014-01-22 17:02:188</head>
9<body>
10 <div id="log"></div>
11 <script type="text/javascript">
12
13 var testOpen = async_test("W3C WebSocket API - Create WebSocket - Close the Connection - close(reason with unpaired surrogates) - connection should get opened");
14 var testClose = async_test("W3C WebSocket API - Create WebSocket - Close the Connection - close(reason with unpaired surrogates) - connection should get closed");
15
16 var wsocket = CreateWebSocket(false, false, false);
17 var isOpenCalled = false;
Simon Pieters3ca8c742014-11-04 20:16:0718 var replacementChar = "\uFFFD";
Philip Jägenstedtc053f402014-01-22 17:02:1819 var reason = "\uD807";
20
21 wsocket.addEventListener('open', testOpen.step_func(function (evt) {
22 wsocket.close(1000, reason);
23 isOpenCalled = true;
24 testOpen.done();
25 }), true);
26
27 wsocket.addEventListener('close', testClose.step_func(function (evt) {
28 assert_true(isOpenCalled, "WebSocket connection should be opened");
Simon Pieters3ca8c742014-11-04 20:16:0729 assert_equals(evt.reason, replacementChar, "reason replaced with replacement character");
Philip Jägenstedtc053f402014-01-22 17:02:1830 testClose.done();
31 }), true);
32
33 </script>
34
35</body>
36</html>