RESOLVED FIXED 65248
WebSocket: Implement "protocol" attribute
https://bugs.webkit.org/show_bug.cgi?id=65248
Summary WebSocket: Implement "protocol" attribute
Yuta Kitamura
Reported 2011-07-27 05:05:28 PDT
Current WebSocket API defines "protocol" attribute which, after the WebSocket connection is established, returns the value of Sec-WebSocket-Protocol header in server's response. <http://dev.w3.org/html5/websockets/> interface WebSocket { ... readonly attribute DOMString protocol; ... };
Attachments
Patch (24.02 KB, patch)
2011-08-11 00:02 PDT, Yuta Kitamura
no flags
Patch v2 (31.63 KB, patch)
2011-08-11 06:09 PDT, Yuta Kitamura
no flags
Patch for landing (31.59 KB, patch)
2011-08-11 22:26 PDT, Yuta Kitamura
no flags
Yuta Kitamura
Comment 1 2011-08-11 00:02:17 PDT
Kent Tamura
Comment 2 2011-08-11 00:33:16 PDT
Comment on attachment 103587 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=103587&action=review > Source/WebCore/ChangeLog:16 > + Tests: http/tests/websocket/tests/hybi/no-subprotocol.html (added) > + http/tests/websocket/tests/hybi/workers/no-subprotocol.html (added) > + http/tests/websocket/tests/hixie76/undefined-attributes.html (updated) > + http/tests/websocket/tests/hybi/multiple-subprotocols.html (updated) > + http/tests/websocket/tests/hybi/workers/multiple-subprotocols.html (updated) > + We need a test to try updating .protocol by a script. > Source/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp:231 > -static void workerContextDidConnect(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper) > +static void workerContextDidConnect(ScriptExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, const String& subprotocol) Why did you change the RefPtr<> to PassRefPtr<>?
Yuta Kitamura
Comment 3 2011-08-11 01:48:22 PDT
Comment on attachment 103587 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=103587&action=review >> Source/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp:231 >> +static void workerContextDidConnect(ScriptExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, const String& subprotocol) > > Why did you change the RefPtr<> to PassRefPtr<>? I updated this line because I was bugged by check-webkit-style about using RefPtr<> as an argument. Using PassRefPtr<> should be safe, because CrossThreadTask and CrossThreadCopier know how to pass a RefPtr across threads. I think I should update other occurrences of RefPtr<> arguments in this file. I'm not sure if it's fine to do in this patch, though.
Kent Tamura
Comment 4 2011-08-11 02:14:44 PDT
Comment on attachment 103587 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=103587&action=review >>> Source/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp:231 >>> +static void workerContextDidConnect(ScriptExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, const String& subprotocol) >> >> Why did you change the RefPtr<> to PassRefPtr<>? > > I updated this line because I was bugged by check-webkit-style about using RefPtr<> as an argument. Using PassRefPtr<> should be safe, because CrossThreadTask and CrossThreadCopier know how to pass a RefPtr across threads. > > I think I should update other occurrences of RefPtr<> arguments in this file. I'm not sure if it's fine to do in this patch, though. This change is unrelated to this bug, and the behavior will change a little. We had better handle it in a separated patch.
Yuta Kitamura
Comment 5 2011-08-11 06:09:54 PDT
Created attachment 103608 [details] Patch v2
Yuta Kitamura
Comment 6 2011-08-11 06:13:36 PDT
Patch v1 has a bug that assertion fails if "protocol" attribute is accessed after m_channel is released. Patch v2 fixes this problem, and the tests in the patch are modified to check this case.
WebKit Review Bot
Comment 7 2011-08-11 06:13:54 PDT
Attachment 103608 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/http..." exit_code: 1 Source/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp:231: The parameter type should use PassRefPtr instead of RefPtr. [readability/pass_ptr] [5] Total errors found: 1 in 25 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yuta Kitamura
Comment 8 2011-08-11 06:14:27 PDT
Comment on attachment 103587 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=103587&action=review >> Source/WebCore/ChangeLog:16 >> + > > We need a test to try updating .protocol by a script. Patch v2 contains a new test for this.
Yuta Kitamura
Comment 9 2011-08-11 06:15:20 PDT
(In reply to comment #7) > Source/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp:231: The parameter type should use PassRefPtr instead of RefPtr. [readability/pass_ptr] [5] This should be fixed in bug 66047.
Kent Tamura
Comment 10 2011-08-11 21:55:31 PDT
Comment on attachment 103608 [details] Patch v2 ok
Yuta Kitamura
Comment 11 2011-08-11 22:26:04 PDT
Created attachment 103735 [details] Patch for landing
WebKit Review Bot
Comment 12 2011-08-11 23:45:09 PDT
Comment on attachment 103735 [details] Patch for landing Clearing flags on attachment: 103735 Committed r92946: <http://trac.webkit.org/changeset/92946>
WebKit Review Bot
Comment 13 2011-08-11 23:45:14 PDT
All reviewed patches have been landed. Closing bug.
David Levin
Comment 14 2011-09-11 14:58:27 PDT
Note for future reviews: Check for additions of non-threadsafe objects (like String whose destructor is not threadsafe) into ThreadSafeRefCounted classes. Filed https://bugs.webkit.org/show_bug.cgi?id=67908
Note You need to log in before you can comment on or make changes to this bug.