Bug 1643722 [wpt PR 24011] - [Reland] [WebSocket] Test header + close frame in same...
[gecko.git] / testing / web-platform / tests / websockets / opening-handshake / 005.html
blobe7cec47eae17a0049b26f2d925be09fac00207e8
1 <!doctype html>
2 <title>WebSockets: response header and close frame in same packet</title>
3 <script src=/resources/testharness.js></script>
4 <script src=/resources/testharnessreport.js></script>
5 <script src=../constants.js?pipe=sub></script>
6 <meta name="variant" content="">
7 <meta name="variant" content="?wss">
8 <div id=log></div>
9 <script>
10 async_test(function(t) {
11 var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/simple_handshake');
12 ws.onmessage = t.unreached_func();
13 ws.onopen = t.step_func(function(e) {
14 ws.onclose = t.step_func(function(e) {
15 assert_equals(e.wasClean, true);
16 assert_equals(e.code, 1001);
17 assert_equals(e.reason, 'PASS');
18 ws.onclose = t.unreached_func('onclose should not be called twice');
19 t.step_timeout(() => t.done(), 50);
21 ws.close();
23 ws.onclose = t.unreached_func('onclose should not be called before onopen');
24 });
25 </script>