Andrew Top | 61a8495 | 2019-04-30 15:07:33 -0700 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>W3C WebSocket API - Close Secure 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> |
| 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(reason with unpaired surrogates) - connection should get opened"); |
| 14 | var testClose = async_test("W3C WebSocket API - Create Secure WebSocket - Close the Connection - close(reason with unpaired surrogates) - connection should get closed"); |
| 15 | |
| 16 | var wsocket = CreateWebSocket(true, false, false); |
| 17 | var isOpenCalled = false; |
| 18 | var replacementChar = "\uFFFD"; |
| 19 | 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"); |
| 29 | assert_equals(evt.reason, replacementChar, "reason replaced with replacement character"); |
| 30 | testClose.done(); |
| 31 | }), true); |
| 32 | |
| 33 | </script> |
| 34 | |
| 35 | </body> |
| 36 | </html> |
| 37 | |