| <!DOCTYPE HTML> |
| <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("Tests whether WebSocket ignores frames with reserved opcode."); |
| |
| window.jsTestIsAsync = true; |
| |
| var closeEvent; |
| |
| function doTest(opcode) |
| { |
| if (opcode >= 0x10) { |
| finishJSTest(); |
| return; |
| } |
| if (opcode == 0x0 || opcode == 0x1 || opcode == 0x2 || opcode == 0x8 || opcode == 0x9 || opcode == 0xA) { |
| doTest(opcode + 1); |
| return; |
| } |
| |
| debug("Opcode " + opcode + ": Test started."); |
| |
| var url = "ws://localhost:8880/reserved-opcodes?opcode=" + opcode; |
| var ws = new WebSocket(url); |
| |
| ws.onopen = function() |
| { |
| debug("onopen() was called."); |
| }; |
| |
| ws.onmessage = function(event) |
| { |
| var message = event.data; |
| testFailed("onmessage() was called. (message = \"" + message + "\")"); |
| }; |
| |
| ws.onclose = function(event) |
| { |
| debug("onclose() was called."); |
| closeEvent = event; |
| shouldBeFalse("closeEvent.wasClean"); |
| doTest(opcode + 1); |
| }; |
| |
| ws.onerror = function(errorEvent) |
| { |
| testPassed("onerror() was called"); |
| }; |
| } |
| |
| doTest(0); |
| |
| </script> |
| </body> |
| </html> |