close-nested.html (769B)
1 <!doctype html> 2 <title>WebSockets: close() in close event handler</title> 3 <script src=/resources/testharness.js></script> 4 <script src=/resources/testharnessreport.js></script> 5 <script src=../../../constants.sub.js></script> 6 <meta name="variant" content="?default"> 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+'/'); 12 var i = 0; 13 ws.onclose = t.step_func(function(e) { 14 i++; 15 if (i == 1) { 16 assert_equals(ws.readyState, ws.CLOSED); 17 ws.close(); 18 assert_equals(ws.readyState, ws.CLOSED); 19 } 20 t.step_timeout(function() { 21 assert_equals(i, 1); 22 t.done(); 23 }, 50); 24 }); 25 ws.close(); 26 assert_equals(ws.readyState, ws.CLOSING); 27 }); 28 </script>