| <!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("Test WebSocket URL parsing."); |
| |
| // Not enough arguments. |
| shouldThrow('new WebSocket()'); |
| |
| // Null URL |
| shouldThrow('new WebSocket(null)'); |
| |
| // Invalid url will fail to be parsed. |
| shouldThrow('new WebSocket("ws://javascript:a")'); |
| |
| // Can't use relative URLs - because spec says so, and because the scheme is different anyway. |
| shouldThrow('new WebSocket("/applet")'); |
| |
| // Non ws URL is not allowed. |
| shouldThrow('new WebSocket("javascript:a")'); |
| |
| // Resolve the url string using the resolve a Web address algorithm. |
| // Use 127.0.0.1:8880 and existing ws handler to make sure we don't receive unexpected response (so no console message appears) |
| shouldBe('(new WebSocket("ws://127.0.0.1:8880/a/../simple")).url', '"ws://127.0.0.1:8880/simple"'); |
| shouldBe('(new WebSocket("ws://127.0.0.1:8880/simple?")).url', '"ws://127.0.0.1:8880/simple?"'); |
| shouldBe('(new WebSocket("ws://127.0.0.1:8880/simple?k=v")).url', '"ws://127.0.0.1:8880/simple?k=v"'); |
| |
| // The WebSocket API specification says If /url/ has a <fragment> |
| // component, then fail the parsing WebSocket URLs, so throw a SYNTAX_ERR |
| // exception. |
| shouldThrow('new WebSocket("ws://127.0.0.1/path#")'); |
| shouldThrow('new WebSocket("ws://127.0.0.1/path#fragment")'); |
| |
| shouldThrow('new WebSocket("ws:://127.0.0.1/")'); |
| |
| </script> |
| </body> |
| </html> |