| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="/js-test-resources/js-test.js"></script> |
| </head> |
| <body> |
| <div id="description"></div> |
| <div id="console"></div> |
| <script type="text/javascript"> |
| description("Checks whether SyntaxError is thrown when attempting to send too long reason."); |
| |
| window.jsTestIsAsync = true; |
| |
| var ws = new WebSocket("ws://localhost:8880/echo"); |
| var message; |
| var longReason = ''; |
| for (var i = 0; i < 124; ++i) |
| longReason += 'a'; |
| |
| ws.onopen = function() |
| { |
| debug("Connected."); |
| try { |
| ws.close(1000, longReason); |
| testFailed('SyntaxError should be thrown.'); |
| } catch (e) { |
| if (e.name == 'SyntaxError') |
| testPassed('SyntaxError was thrown: ' + e); |
| else |
| testFailed('Unexpected exception: ' + e); |
| } |
| ws.close(); |
| }; |
| |
| ws.onmessage = function (event) |
| { |
| message = event.data; |
| testFailed("onmessage() was called. (message = \"" + message + "\")"); |
| }; |
| |
| ws.onclose = function() |
| { |
| finishJSTest(); |
| }; |
| |
| </script> |
| </body> |
| </html> |