008.html (778B)
1 <!doctype html> 2 <title>WebSockets: send() in onclose</title> 3 4 <script src=/resources/testharness.js></script> 5 <script src=/resources/testharnessreport.js></script> 6 <script src=../../../constants.sub.js></script> 7 <meta name="variant" content="?default"> 8 <meta name="variant" content="?wss"> 9 <div id=log></div> 10 <script> 11 async_test(function(t) { 12 var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo'); 13 ws.onopen = t.step_func(function(e) { 14 ws.send('Goodbye'); 15 }) 16 ws.onclose = t.step_func(function(e) { 17 // test that nothing strange happens when send()ing in closed state 18 var sent = ws.send('test'); 19 assert_equals(sent, undefined); 20 ws.onclose = t.unreached_func(); 21 t.step_timeout(() => t.done(), 50); 22 }) 23 ws.onerror = t.unreached_func(); 24 }); 25 </script>