a0c4908c095d650a57532ffb82372d7c5cf21e47
[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 <link rel="stylesheet" href="../../../../js-test-resources/js-test-style.css">
5 <script src="../../../../js-test-resources/js-test-pre.js"></script>
6 </head>
7 <body>
8 <div id="description"></div>
9 <div id="console"></div>
10 <script type="text/javascript">
11 description("Test WebSocket URL parsing.");
12
13 if (window.layoutTestController)
14     layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 0);
15
16 // Invalid url will fail to be parsed.
17 shouldThrow('new WebSocket("ws://javascript:a")');
18
19 // Can't use relative URLs - because spec says so, and because the scheme is different anyway.
20 shouldThrow('new WebSocket("/applet")');
21
22 // Non ws URL is not allowed.
23 shouldThrow('new WebSocket("javascript:a")');
24
25 // UA is allowed to block access to some ports, which we do.
26 shouldThrow('new WebSocket("ws://127.0.0.1:25/")');
27
28 // Resolve the url string using the resolve a Web address algorithm.
29 // Use 127.0.0.1:8880 and existing ws handler to make sure we don't receive unexpected response (so no console message appears)
30 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"');
31 shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple?")).URL', '"ws://127.0.0.1:8880/websocket/tests/hybi/simple?"');
32 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"');
33
34 // draft-hixie-thewebsocketprotocol-60 says If /url/ has a <fragment>
35 // component, then fail the parsing Web Socket URLs, so throw a SYNTAX_ERR
36 // exception.
37 shouldThrow('new WebSocket("ws://127.0.0.1/path#")');
38 shouldThrow('new WebSocket("ws://127.0.0.1/path#fragment")');
39
40 var successfullyParsed = true;
41 </script>
42 <script src="../../../../js-test-resources/js-test-post.js"></script>
43 </body>
44 </html>