Bug 97999 - [WebSocket] Setting wrong value to binaryType should not raise exception
Summary: [WebSocket] Setting wrong value to binaryType should not raise exception
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kenichi Ishibashi
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-01 00:34 PDT by Kenichi Ishibashi
Modified: 2012-10-01 19:46 PDT (History)
5 users (show)

See Also:


Attachments
Patch (4.83 KB, patch)
2012-10-01 00:42 PDT, Kenichi Ishibashi
no flags Details | Formatted Diff | Diff
Patch (5.13 KB, patch)
2012-10-01 01:03 PDT, Kenichi Ishibashi
no flags Details | Formatted Diff | Diff
Patch (5.30 KB, patch)
2012-10-01 01:08 PDT, Kenichi Ishibashi
no flags Details | Formatted Diff | Diff
Patch (6.98 KB, patch)
2012-10-01 01:47 PDT, Kenichi Ishibashi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 Kenichi Ishibashi 2012-10-01 00:42:28 PDT
Created attachment 166417 [details]
Patch
Comment 2 Build Bot 2012-10-01 00:44:45 PDT
Comment on attachment 166417 [details]
Patch

Attachment 166417 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/14074744
Comment 3 Yuta Kitamura 2012-10-01 00:59:16 PDT
Comment on attachment 166417 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=166417&action=review

r- for unused function argument.

> Source/WebCore/Modules/websockets/WebSocket.cpp:417
> +    scriptExecutionContext()->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "'" + binaryType + "' is the wrong binaryType");

- Error message sounds a bit strange and unhelpful; I would suggest:
    "'" + binaryType + "'" is not a valid value for binaryType; binaryType remains unchanged."

- You can now remove the argument |ec|. You need to touch WebSocket.idl to remove this.
Comment 4 Kenichi Ishibashi 2012-10-01 01:03:41 PDT
Created attachment 166419 [details]
Patch
Comment 5 Kenichi Ishibashi 2012-10-01 01:08:59 PDT
Created attachment 166420 [details]
Patch
Comment 6 Kenichi Ishibashi 2012-10-01 01:09:31 PDT
Comment on attachment 166417 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=166417&action=review

Thank you for review!

>> Source/WebCore/Modules/websockets/WebSocket.cpp:417
>> +    scriptExecutionContext()->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "'" + binaryType + "' is the wrong binaryType");
> 
> - Error message sounds a bit strange and unhelpful; I would suggest:
>     "'" + binaryType + "'" is not a valid value for binaryType; binaryType remains unchanged."
> 
> - You can now remove the argument |ec|. You need to touch WebSocket.idl to remove this.

Done.
Comment 7 Yuta Kitamura 2012-10-01 01:34:53 PDT
Comment on attachment 166420 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=166420&action=review

r- for unneeded |ExceptionCode&| argument.

> Source/WebCore/Modules/websockets/WebSocket.cpp:407
> +void WebSocket::setBinaryType(const String& binaryType, ExceptionCode&)

Well, what I meant was to update the following line in WebSocket.idl:

    attribute [TreatReturnedNullStringAs=Undefined] DOMString binaryType
        setter raises(DOMException);

If you remove "setter raises(DOMException)", you will not need the second argument
of setBinaryType().

(You can also remove [TreatReturnedNullStringAs=Undefined]. It was used to handle
 the old hixie76 protocol, which is no longer supported.)
Comment 8 Kenichi Ishibashi 2012-10-01 01:47:34 PDT
Created attachment 166426 [details]
Patch
Comment 9 Kenichi Ishibashi 2012-10-01 01:48:07 PDT
Comment on attachment 166420 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=166420&action=review

>> Source/WebCore/Modules/websockets/WebSocket.cpp:407
>> +void WebSocket::setBinaryType(const String& binaryType, ExceptionCode&)
> 
> Well, what I meant was to update the following line in WebSocket.idl:
> 
>     attribute [TreatReturnedNullStringAs=Undefined] DOMString binaryType
>         setter raises(DOMException);
> 
> If you remove "setter raises(DOMException)", you will not need the second argument
> of setBinaryType().
> 
> (You can also remove [TreatReturnedNullStringAs=Undefined]. It was used to handle
>  the old hixie76 protocol, which is no longer supported.)

Thanks. Removed.
Comment 10 Yuta Kitamura 2012-10-01 02:13:10 PDT
Comment on attachment 166426 [details]
Patch

Looks OK.
Comment 11 Kenichi Ishibashi 2012-10-01 02:20:25 PDT
Comment on attachment 166426 [details]
Patch

Thanks!
Comment 12 WebKit Review Bot 2012-10-01 02:29:18 PDT
Comment on attachment 166426 [details]
Patch

Clearing flags on attachment: 166426

Committed r130019: <http://trac.webkit.org/changeset/130019>
Comment 13 WebKit Review Bot 2012-10-01 02:29:22 PDT
All reviewed patches have been landed.  Closing bug.
Comment 14 Alexey Proskuryakov 2012-10-01 09:34:16 PDT
> See http://code.google.com/p/chromium/issues/detail?id=153240 and https://www.w3.org/Bugs/Public/show_bug.cgi?id=18749 for details.

Please always post relevant information into Bugzilla. It's not polite to make everyone reading a bug click through to 3rd party sites to research rationale. It's good to provide links for additional background, but rationale should be explained locally.
Comment 15 Kenichi Ishibashi 2012-10-01 09:59:55 PDT
(In reply to comment #14)
> Please always post relevant information into Bugzilla. It's not polite to make everyone reading a bug click through to 3rd party sites to research rationale. It's good to provide links for additional background, but rationale should be explained locally.

I see. I'll post enough information into Bugzilla next time.
Comment 16 Yuta Kitamura 2012-10-01 19:46:13 PDT
You just should have pasted my comment in the Chromium bug.

For the record, I'm pasting it here.

http://code.google.com/p/chromium/issues/detail?id=153240

========
Reported by project member yutak@chromium.org, Yesterday (19 hours ago)
Background: https://www.w3.org/Bugs/Public/show_bug.cgi?id=18749

Now WebSocket API defines an enum type BinaryType, and binaryType attribute has that type.
http://dev.w3.org/html5/websockets/

As defined in WebIDL spec, setting a wrong value to enum attribute should not throw
an exception:
http://dev.w3.org/2006/webapi/WebIDL/#es-attributes
> - If the type of the attribute is an enumeration, then:
>     1. Let S be the result of calling ToString(V).
>     2. If S is not of the enumeration’s values, then return undefined.
>     3. The value of idlValue is the enumeration value equal to S.

Current implementation raises a SYNTAX_ERR (based on the older WS spec), so we'll need to
fix this.

To help developers to find their mistakes, we would also add a console message when
a wrong value is being set to binaryType.

I don't have a compatibility concern because it doesn't really make sense to handle
the SYNTAX_ERR thrown for this.
========