Changeset 52399 in webkit
- Timestamp:
- Dec 19, 2009 7:30:14 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r52394 r52399 1 2009-12-19 Fumitoshi Ukai <ukai@chromium.org> 2 3 Reviewed by Alexey Proskuryakov. 4 5 Invalid url should raise SYNTAX_ERR exception. 6 https://bugs.wbekit.org/show_bug.cgi?id=32700 7 8 * websocket/tests/bad-sub-protocol-expected.txt: add CONSOLE MESSAGEs 9 * websocket/tests/script-tests/url-parsing.js: add invalid url tests. 10 Also changed url from ws://127.0.0.1/ to ws://127.0.0.1:8880/websocket/tests/simple to make it sure no errors on console message for these tests by not receiving unexpected response from 127.0.0.1:80. 11 * websocket/tests/url-parsing-expected.txt: 12 1 13 2009-12-19 Dirk Schulze <krit@webkit.org> 2 14 -
trunk/LayoutTests/websocket/tests/bad-sub-protocol-expected.txt
r51886 r52399 1 CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket 2 CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket 3 CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket 4 CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket 5 CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket 6 CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket 7 CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket あ 8 CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket 9 CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket 10 CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket 11 CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket 𠀋 1 12 Test WebSocket bad sub-protocol names. 2 13 -
trunk/LayoutTests/websocket/tests/script-tests/url-parsing.js
r51830 r52399 1 1 description("Test WebSocket URL parsing."); 2 3 // Invalid url will fail to be parsed. 4 shouldThrow('new WebSocket("ws://javascript:a")'); 2 5 3 6 // Can't use relative URLs - because spec says so, and because the scheme is different anyway. 4 7 shouldThrow('new WebSocket("/applet")'); 5 8 9 // Non ws URL is not allowed. 10 shouldThrow('new WebSocket("javascript:a")'); 11 6 12 // UA is allowed to block access to some ports, which we do. 7 13 shouldThrow('new WebSocket("ws://127.0.0.1:25/")'); 8 14 9 // This is what we currently do, but not what the spec says (as of Editor's Draft 1 December 2009).10 shouldBe('(new WebSocket("ws://127.0.0.1/a/../")).URL', '"ws://127.0.0.1/"'); 11 12 shouldBe('(new WebSocket("ws://127.0.0.1 /path?")).URL', '"ws://127.0.0.1/path?"');13 shouldBe('(new WebSocket("ws://127.0.0.1 /path?k=v")).URL', '"ws://127.0.0.1/path?k=v"');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"'); 14 20 15 21 // draft-hixie-thewebsocketprotocol-60 says If /url/ has a <fragment> -
trunk/LayoutTests/websocket/tests/url-parsing-expected.txt
r51830 r52399 1 CONSOLE MESSAGE: line 0: Invalid url for WebSocket ws://javascript:a 2 CONSOLE MESSAGE: line 0: Wrong url scheme for WebSocket http://127.0.0.1:8880/applet 3 CONSOLE MESSAGE: line 0: Wrong url scheme for WebSocket javascript:a 4 CONSOLE MESSAGE: line 0: WebSocket port 25 blocked 5 CONSOLE MESSAGE: line 0: URL has fragment component ws://127.0.0.1/path# 6 CONSOLE MESSAGE: line 0: URL has fragment component ws://127.0.0.1/path#fragment 1 7 Test WebSocket URL parsing. 2 8 3 9 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 4 10 11 PASS new WebSocket("ws://javascript:a") threw exception Error: SYNTAX_ERR: DOM Exception 12. 5 12 PASS new WebSocket("/applet") threw exception Error: SYNTAX_ERR: DOM Exception 12. 13 PASS new WebSocket("javascript:a") threw exception Error: SYNTAX_ERR: DOM Exception 12. 6 14 PASS new WebSocket("ws://127.0.0.1:25/") threw exception Error: SECURITY_ERR: DOM Exception 18. 7 PASS (new WebSocket("ws://127.0.0.1 /a/../")).URL is "ws://127.0.0.1/"8 PASS (new WebSocket("ws://127.0.0.1 /path?")).URL is "ws://127.0.0.1/path?"9 PASS (new WebSocket("ws://127.0.0.1 /path?k=v")).URL is "ws://127.0.0.1/path?k=v"15 PASS (new WebSocket("ws://127.0.0.1:8880/a/../websocket/tests/simple")).URL is "ws://127.0.0.1:8880/websocket/tests/simple" 16 PASS (new WebSocket("ws://127.0.0.1:8880/websocket/tests/simple?")).URL is "ws://127.0.0.1:8880/websocket/tests/simple?" 17 PASS (new WebSocket("ws://127.0.0.1:8880/websocket/tests/simple?k=v")).URL is "ws://127.0.0.1:8880/websocket/tests/simple?k=v" 10 18 PASS new WebSocket("ws://127.0.0.1/path#") threw exception Error: SYNTAX_ERR: DOM Exception 12. 11 19 PASS new WebSocket("ws://127.0.0.1/path#fragment") threw exception Error: SYNTAX_ERR: DOM Exception 12. -
trunk/WebCore/ChangeLog
r52397 r52399 1 2009-12-19 Fumitoshi Ukai <ukai@chromium.org> 2 3 Reviewed by Alexey Proskuryakov. 4 5 Invalid url should raise SYNTAX_ERR exception. 6 https://bugs.webkit.org/show_bug.cgi?id=32700 7 8 Check url is valid in WebSocket::connect. 9 Also log the detailed reason of websocket failures to console. 10 11 * websockets/WebSocket.cpp: 12 (WebCore::WebSocket::connect): 13 1 14 2009-12-19 Dan Bernstein <mitz@apple.com> 2 15 -
trunk/WebCore/websockets/WebSocket.cpp
r51935 r52399 102 102 m_protocol = protocol; 103 103 104 if (!m_url.isValid()) { 105 scriptExecutionContext()->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid url for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString()); 106 m_state = CLOSED; 107 ec = SYNTAX_ERR; 108 return; 109 } 110 104 111 if (!m_url.protocolIs("ws") && !m_url.protocolIs("wss")) { 105 LOG(Network, "Wrong url scheme for WebSocket %s", url.string().utf8().data());112 scriptExecutionContext()->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong url scheme for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString()); 106 113 m_state = CLOSED; 107 114 ec = SYNTAX_ERR; … … 109 116 } 110 117 if (m_url.hasFragmentIdentifier()) { 111 LOG(Network, "URL has fragment component %s", url.string().utf8().data());118 scriptExecutionContext()->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, "URL has fragment component " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString()); 112 119 m_state = CLOSED; 113 120 ec = SYNTAX_ERR; … … 115 122 } 116 123 if (!isValidProtocolString(m_protocol)) { 117 LOG(Network, "Wrong protocol for WebSocket %s", m_protocol.utf8().data());124 scriptExecutionContext()->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong protocol for WebSocket " + m_protocol, 0, scriptExecutionContext()->securityOrigin()->toString()); 118 125 m_state = CLOSED; 119 126 ec = SYNTAX_ERR; … … 121 128 } 122 129 if (!portAllowed(url)) { 123 LOG(Network, "WebSocket port %d blocked", url.port());130 scriptExecutionContext()->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, String::format("WebSocket port %d blocked", url.port()), 0, scriptExecutionContext()->securityOrigin()->toString()); 124 131 m_state = CLOSED; 125 132 ec = SECURITY_ERR;
Note: See TracChangeset
for help on using the changeset viewer.