6b67a09b0c830140e561782fb6862987ea4e022b
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / url-parsing.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../../js-test-resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <div id="description"></div>
8 <div id="console"></div>
9 <script type="text/javascript">
10 description("Test WebSocket URL parsing.");
11
12 if (window.testRunner)
13     testRunner.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
14
15 // Not enough arguments.
16 shouldThrow('new WebSocket()');
17
18 // Invalid url will fail to be parsed.
19 shouldThrow('new WebSocket("ws://javascript:a")');
20
21 // Can't use relative URLs - because spec says so, and because the scheme is different anyway.
22 shouldThrow('new WebSocket("/applet")');
23
24 // Non ws URL is not allowed.
25 shouldThrow('new WebSocket("javascript:a")');
26
27 // UA is allowed to block access to some ports, which we do.
28 shouldThrow('new WebSocket("ws://127.0.0.1:25/")');
29
30 // Resolve the url string using the resolve a Web address algorithm.
31 // Use 127.0.0.1:8880 and existing ws handler to make sure we don't receive unexpected response (so no console message appears)
32 shouldBe('(new WebSocket("ws://127.0.0.1:8880/a/../websocket/tests/hixie76/simple")).URL', '"ws://127.0.0.1:8880/websocket/tests/hixie76/simple"');
33 shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/simple?")).URL', '"ws://127.0.0.1:8880/websocket/tests/hixie76/simple?"');
34 shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/simple?k=v")).URL', '"ws://127.0.0.1:8880/websocket/tests/hixie76/simple?k=v"');
35
36 // draft-hixie-thewebsocketprotocol-60 says If /url/ has a <fragment>
37 // component, then fail the parsing Web Socket URLs, so throw a SYNTAX_ERR
38 // exception.
39 shouldThrow('new WebSocket("ws://127.0.0.1/path#")');
40 shouldThrow('new WebSocket("ws://127.0.0.1/path#fragment")');
41
42 </script>
43 <script src="../../../../js-test-resources/js-test-post.js"></script>
44 </body>
45 </html>