Changeset 198482 in webkit


Ignore:
Timestamp:
Mar 20, 2016 10:28:21 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

The setter of binaryType attribute in WebSocket should raise the exception.
https://bugs.webkit.org/show_bug.cgi?id=135874

Patch by Jinwoo Jeong <jw00.jeong@samsung.com> on 2016-03-20
Reviewed by Antonio Gomes.

Source/WebCore:

According to W3C WebSocket Specification, <https://www.w3.org/TR/2012/CR-websockets-20120920/>
when an invalid value is set on binaryType of WebSocket, a SyntaxError should be raised.

  • Modules/websockets/WebSocket.cpp:

(WebCore::WebSocket::setBinaryType): Add a parameter to set an exception.

  • Modules/websockets/WebSocket.h: Ditto.
  • Modules/websockets/WebSocket.idl: Update that setter of binaryType could raise an exception.

LayoutTests:

According to W3C WebSocket Specification, <https://www.w3.org/TR/2012/CR-websockets-20120920/>,
when an invalid value is set on binaryType of WebSocket, a SyntaxError should be raised.

  • http/tests/websocket/tests/hybi/binary-type.html: Catch a syntax exception when binary type is set with invalid values.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r198474 r198482  
     12016-03-20  Jinwoo Jeong  <jw00.jeong@samsung.com>
     2
     3        The setter of binaryType attribute in WebSocket should raise the exception.
     4        https://bugs.webkit.org/show_bug.cgi?id=135874
     5
     6        Reviewed by Antonio Gomes.
     7
     8        According to W3C WebSocket Specification, <https://www.w3.org/TR/2012/CR-websockets-20120920/>,
     9        when an invalid value is set on binaryType of WebSocket, a SyntaxError should be raised.
     10
     11        * http/tests/websocket/tests/hybi/binary-type.html: Catch a syntax exception when binary type is set with invalid values.
     12
    1132016-03-20  Chris Fleizach  <cfleizach@apple.com>
    214
  • trunk/LayoutTests/http/tests/websocket/tests/hybi/binary-type-expected.txt

    r178527 r198482  
    1 CONSOLE MESSAGE: line 23: 'Blob' is not a valid value for binaryType; binaryType remains unchanged.
    2 CONSOLE MESSAGE: line 26: 'ArrayBuffer' is not a valid value for binaryType; binaryType remains unchanged.
    3 CONSOLE MESSAGE: line 29: '' is not a valid value for binaryType; binaryType remains unchanged.
     1CONSOLE MESSAGE: line 600: 'Blob' is not a valid value for binaryType; binaryType remains unchanged.
     2CONSOLE MESSAGE: line 600: 'ArrayBuffer' is not a valid value for binaryType; binaryType remains unchanged.
     3CONSOLE MESSAGE: line 600: '' is not a valid value for binaryType; binaryType remains unchanged.
    44Test WebSocket.binaryType attribute.
    55
     
    99PASS ws.binaryType is "arraybuffer"
    1010PASS ws.binaryType is "blob"
    11 Set invalid values to binaryType. They should be ignored. No exception should be thrown.
     11PASS ws.binaryType = 'Blob' threw exception Error: SyntaxError: DOM Exception 12.
    1212PASS ws.binaryType is "blob"
     13PASS ws.binaryType = 'ArrayBuffer' threw exception Error: SyntaxError: DOM Exception 12.
    1314PASS ws.binaryType is "blob"
     15PASS ws.binaryType = '' threw exception Error: SyntaxError: DOM Exception 12.
    1416PASS ws.binaryType is "blob"
    1517PASS successfullyParsed is true
  • trunk/LayoutTests/http/tests/websocket/tests/hybi/binary-type.html

    r130019 r198482  
    1919shouldBeEqualToString("ws.binaryType", "blob");
    2020
    21 debug("Set invalid values to binaryType. They should be ignored. No exception should be thrown.");
    22 
    23 ws.binaryType = "Blob";
     21shouldThrow("ws.binaryType = 'Blob'", "'Error: SyntaxError: DOM Exception 12'");
    2422shouldBeEqualToString("ws.binaryType", "blob");
    2523
    26 ws.binaryType = "ArrayBuffer"
     24shouldThrow("ws.binaryType = 'ArrayBuffer'", "'Error: SyntaxError: DOM Exception 12'");
    2725shouldBeEqualToString("ws.binaryType", "blob");
    2826
    29 ws.binaryType = "";
     27shouldThrow("ws.binaryType = ''", "'Error: SyntaxError: DOM Exception 12'");
    3028shouldBeEqualToString("ws.binaryType", "blob");
    3129
  • trunk/Source/WebCore/ChangeLog

    r198481 r198482  
     12016-03-20  Jinwoo Jeong  <jw00.jeong@samsung.com>
     2
     3        The setter of binaryType attribute in WebSocket should raise the exception.
     4        https://bugs.webkit.org/show_bug.cgi?id=135874
     5
     6        Reviewed by Antonio Gomes.
     7
     8        According to W3C WebSocket Specification, <https://www.w3.org/TR/2012/CR-websockets-20120920/>
     9        when an invalid value is set on binaryType of WebSocket, a SyntaxError should be raised.
     10
     11        * Modules/websockets/WebSocket.cpp:
     12        (WebCore::WebSocket::setBinaryType): Add a parameter to set an exception.
     13        * Modules/websockets/WebSocket.h: Ditto.
     14        * Modules/websockets/WebSocket.idl: Update that setter of binaryType could raise an exception.
     15
    1162016-03-20  Dan Bernstein  <mitz@apple.com>
    217
  • trunk/Source/WebCore/Modules/websockets/WebSocket.cpp

    r196242 r198482  
    444444}
    445445
    446 void WebSocket::setBinaryType(const String& binaryType)
     446void WebSocket::setBinaryType(const String& binaryType, ExceptionCode& ec)
    447447{
    448448    if (binaryType == "blob") {
     
    454454        return;
    455455    }
     456    ec = SYNTAX_ERR;
    456457    scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, "'" + binaryType + "' is not a valid value for binaryType; binaryType remains unchanged.");
    457458}
  • trunk/Source/WebCore/Modules/websockets/WebSocket.h

    r197563 r198482  
    8989
    9090    String binaryType() const;
    91     void setBinaryType(const String&);
     91    void setBinaryType(const String&, ExceptionCode&);
    9292
    9393    // EventTarget functions.
  • trunk/Source/WebCore/Modules/websockets/WebSocket.idl

    r197060 r198482  
    6161    readonly attribute DOMString? extensions;
    6262
    63     attribute DOMString binaryType;
     63    [SetterRaisesException] attribute DOMString binaryType;
    6464
    6565    [RaisesException] void send(ArrayBuffer data);
Note: See TracChangeset for help on using the changeset viewer.