| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>W3C WebSocket API - Create WebSocket with a valid url and protocol string</title> |
| Ms2ger | b26c70f | 2016-03-01 14:53:11 | [diff] [blame] | 5 | <script type="text/javascript" src="websocket.sub.js"></script> |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 6 | <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 | |
| plehegar | 09d95c5 | 2015-01-16 22:27:44 | [diff] [blame] | 32 | </script> |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 33 | </body> |
| 34 | </html> |