Andrew Top | 61a8495 | 2019-04-30 15:07:33 -0700 | [diff] [blame^] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>W3C WebSocket API - Send unicode data - Secure WebSocket</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 - Send unicode data on a Secure WebSocket - Connection should be opened"); |
| 14 | var testMessage = async_test("W3C WebSocket API - Send unicode data on a Secure WebSocket - Message should be received"); |
| 15 | var testClose = async_test("W3C WebSocket API - Send unicode data on a Secure WebSocket - Connection should be closed"); |
| 16 | |
| 17 | var data = "¥¥¥¥¥¥"; |
| 18 | var wsocket = CreateWebSocket(true, false, false); |
| 19 | var isOpenCalled = false; |
| 20 | |
| 21 | wsocket.addEventListener('open', testOpen.step_func(function (evt) { |
| 22 | wsocket.send(data); |
| 23 | assert_equals(data.length * 2, wsocket.bufferedAmount); |
| 24 | isOpenCalled = true; |
| 25 | testOpen.done(); |
| 26 | }), true); |
| 27 | |
| 28 | wsocket.addEventListener('message', testMessage.step_func(function (evt) { |
| 29 | assert_equals(evt.data, data); |
| 30 | wsocket.close(); |
| 31 | testMessage.done(); |
| 32 | }), true); |
| 33 | |
| 34 | wsocket.addEventListener('close', testClose.step_func(function (evt) { |
| 35 | assert_true(isOpenCalled, "WebSocket connection should be open"); |
| 36 | assert_equals(evt.wasClean, true, "wasClean should be true"); |
| 37 | testClose.done(); |
| 38 | }), true); |
| 39 | </script> |
| 40 | </body> |
| 41 | </html> |