2009-12-21 Fumitoshi Ukai <ukai@chromium.org>
[WebKit-https.git] / LayoutTests / websocket / tests / script-tests / url-parsing.js
1 description("Test WebSocket URL parsing.");
2
3 // Invalid url will fail to be parsed.
4 shouldThrow('new WebSocket("ws://javascript:a")');
5
6 // Can't use relative URLs - because spec says so, and because the scheme is different anyway.
7 shouldThrow('new WebSocket("/applet")');
8
9 // Non ws URL is not allowed.
10 shouldThrow('new WebSocket("javascript:a")');
11
12 // UA is allowed to block access to some ports, which we do.
13 shouldThrow('new WebSocket("ws://127.0.0.1:25/")');
14
15 // Resolve the url string using the resolve a Web address algorithm.
16 // Use 127.0.0.1:8880 and existing ws handler to make sure we don't receive unexpected response (so no console message appears)
17 shouldBe('(new WebSocket("ws://127.0.0.1:8880/a/../websocket/tests/simple")).URL', '"ws://127.0.0.1:8880/websocket/tests/simple"');
18 shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/simple?")).URL', '"ws://127.0.0.1:8880/websocket/tests/simple?"');
19 shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/simple?k=v")).URL', '"ws://127.0.0.1:8880/websocket/tests/simple?k=v"');
20
21 // draft-hixie-thewebsocketprotocol-60 says If /url/ has a <fragment>
22 // component, then fail the parsing Web Socket URLs, so throw a SYNTAX_ERR
23 // exception.
24 shouldThrow('new WebSocket("ws://127.0.0.1/path#")');
25 shouldThrow('new WebSocket("ws://127.0.0.1/path#fragment")');
26
27 var successfullyParsed = true;
28 isSuccessfullyParsed();