Bug 32144

Summary: Add test for WebSocket.url attribute
Product: WebKit Reporter: Fumitoshi Ukai <ukai>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Add test for WebSocket.URL attribute.
none
Fragments now make WebSocket URL parsing fail. ap: review+, ap: commit-queue-

Description Fumitoshi Ukai 2009-12-03 21:23:02 PST
Add test for WebSocket.url attribute to check it correctly set to resolved URL.
Comment 1 Fumitoshi Ukai 2009-12-03 21:59:34 PST
Created attachment 44293 [details]
Add test for WebSocket.URL attribute.
Comment 2 WebKit Review Bot 2009-12-03 22:04:36 PST
style-queue ran check-webkit-style on attachment 44293 [details] without any errors.
Comment 3 Darin Fisher (:fishd, Google) 2009-12-04 00:02:06 PST
Comment on attachment 44293 [details]
Add test for WebSocket.URL attribute.

> +++ b/LayoutTests/fast/websockets/script-tests/websocket-url.js
> @@ -0,0 +1,21 @@
> +description("Make sure WebSocket URL attribute is resolved URL.");
> +
> +var ws = new WebSocket("ws://localhost:8000");
> +shouldBe("ws.URL", '"ws://localhost:8000"');
> +
> +ws = new WebSocket("ws://localhost:8000/path?");
> +shouldBe("ws.URL", '"ws://localhost:8000/path?"');
> +
> +ws = new WebSocket("ws://localhost:8000/path?k=v");
> +shouldBe("ws.URL", '"ws://localhost:8000/path?k=v"');
> +
> +ws = new WebSocket("ws://localhost:8000/path#fragment");
> +shouldBe("ws.URL", '"ws://localhost:8000/path#fragment"');
> +
> +ws = new WebSocket("ws://localhost:8000/path/../");
> +shouldBe("ws.URL", '"ws://localhost:8000/"');
> +
> +ws = new WebSocket("ws://localhost:8000/relative/../path");
> +shouldBe("ws.URL", '"ws://localhost:8000/path"');

^^^ are these really the only interesting cases?  there are loads
of other interesting cases for http:// URLs, but perhaps ws:// is
simpler?
Comment 4 Alexey Proskuryakov 2009-12-04 14:35:17 PST
Comment on attachment 44293 [details]
Add test for WebSocket.URL attribute.

I suggest adding these cases to existing WebSocket url-parsing test.
Comment 5 Alexey Proskuryakov 2009-12-04 15:47:57 PST
Comment on attachment 44293 [details]
Add test for WebSocket.URL attribute.

> +ws = new WebSocket("ws://localhost:8000/path#fragment");
> +shouldBe("ws.URL", '"ws://localhost:8000/path#fragment"');

The spec changed, fragments now make WebSocket URL parsing fail.
Comment 6 Fumitoshi Ukai 2009-12-06 17:56:39 PST
Created attachment 44371 [details]
Fragments now make WebSocket URL parsing fail.
Comment 7 WebKit Review Bot 2009-12-06 17:57:21 PST
style-queue ran check-webkit-style on attachment 44371 [details] without any errors.
Comment 8 Alexey Proskuryakov 2009-12-07 10:32:12 PST
Comment on attachment 44371 [details]
Fragments now make WebSocket URL parsing fail.

 // The spec says that the string passed to WebScoket constructor should be returned unchanged.

This is no longer so; this comment should be removed.

+shouldThrow('new WebSocket("ws://127.0.0.1/path#fragment")');

Please test empty fragment, too.

r=me with these modifications.
Comment 9 Fumitoshi Ukai 2009-12-07 20:21:32 PST
Committed r51830: <http://trac.webkit.org/changeset/51830>