5eb38e96d8350130ed763f142ac51e5d4c00dc56
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hybi / 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.layoutTestController)
13     layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 0);
14
15 // Invalid url will fail to be parsed.
16 shouldThrow('new WebSocket("ws://javascript:a")');
17
18 // Can't use relative URLs - because spec says so, and because the scheme is different anyway.
19 shouldThrow('new WebSocket("/applet")');
20
21 // Non ws URL is not allowed.
22 shouldThrow('new WebSocket("javascript:a")');
23
24 // UA is allowed to block access to some ports, which we do.
25 shouldThrow('new WebSocket("ws://127.0.0.1:25/")');
26
27 // Resolve the url string using the resolve a Web address algorithm.
28 // Use 127.0.0.1:8880 and existing ws handler to make sure we don't receive unexpected response (so no console message appears)
29 shouldBe('(new WebSocket("ws://127.0.0.1:8880/a/../websocket/tests/hybi/simple")).URL', '"ws://127.0.0.1:8880/websocket/tests/hybi/simple"');
30 shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple?")).URL', '"ws://127.0.0.1:8880/websocket/tests/hybi/simple?"');
31 shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple?k=v")).URL', '"ws://127.0.0.1:8880/websocket/tests/hybi/simple?k=v"');
32
33 // draft-hixie-thewebsocketprotocol-60 says If /url/ has a <fragment>
34 // component, then fail the parsing Web Socket URLs, so throw a SYNTAX_ERR
35 // exception.
36 shouldThrow('new WebSocket("ws://127.0.0.1/path#")');
37 shouldThrow('new WebSocket("ws://127.0.0.1/path#fragment")');
38
39 </script>
40 <script src="../../../../js-test-resources/js-test-post.js"></script>
41 </body>
42 </html>