Title: [198482] trunk
Revision
198482
Author
[email protected]
Date
2016-03-20 22:28:21 -0700 (Sun, 20 Mar 2016)

Log 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 <[email protected]> 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.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (198481 => 198482)


--- trunk/LayoutTests/ChangeLog	2016-03-21 05:11:38 UTC (rev 198481)
+++ trunk/LayoutTests/ChangeLog	2016-03-21 05:28:21 UTC (rev 198482)
@@ -1,3 +1,15 @@
+2016-03-20  Jinwoo Jeong  <[email protected]>
+
+        The setter of binaryType attribute in WebSocket should raise the exception.
+        https://bugs.webkit.org/show_bug.cgi?id=135874
+
+        Reviewed by Antonio Gomes.
+
+        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.
+
 2016-03-20  Chris Fleizach  <[email protected]>
 
         AX: Radio button members are not identified together in all cases

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/binary-type-expected.txt (198481 => 198482)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/binary-type-expected.txt	2016-03-21 05:11:38 UTC (rev 198481)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/binary-type-expected.txt	2016-03-21 05:28:21 UTC (rev 198482)
@@ -1,6 +1,6 @@
-CONSOLE MESSAGE: line 23: 'Blob' is not a valid value for binaryType; binaryType remains unchanged.
-CONSOLE MESSAGE: line 26: 'ArrayBuffer' is not a valid value for binaryType; binaryType remains unchanged.
-CONSOLE MESSAGE: line 29: '' is not a valid value for binaryType; binaryType remains unchanged.
+CONSOLE MESSAGE: line 600: 'Blob' is not a valid value for binaryType; binaryType remains unchanged.
+CONSOLE MESSAGE: line 600: 'ArrayBuffer' is not a valid value for binaryType; binaryType remains unchanged.
+CONSOLE MESSAGE: line 600: '' is not a valid value for binaryType; binaryType remains unchanged.
 Test WebSocket.binaryType attribute.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -8,9 +8,11 @@
 PASS ws.binaryType is "blob"
 PASS ws.binaryType is "arraybuffer"
 PASS ws.binaryType is "blob"
-Set invalid values to binaryType. They should be ignored. No exception should be thrown.
+PASS ws.binaryType = 'Blob' threw exception Error: SyntaxError: DOM Exception 12.
 PASS ws.binaryType is "blob"
+PASS ws.binaryType = 'ArrayBuffer' threw exception Error: SyntaxError: DOM Exception 12.
 PASS ws.binaryType is "blob"
+PASS ws.binaryType = '' threw exception Error: SyntaxError: DOM Exception 12.
 PASS ws.binaryType is "blob"
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/binary-type.html (198481 => 198482)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/binary-type.html	2016-03-21 05:11:38 UTC (rev 198481)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/binary-type.html	2016-03-21 05:28:21 UTC (rev 198482)
@@ -18,15 +18,13 @@
 ws.binaryType = "blob";
 shouldBeEqualToString("ws.binaryType", "blob");
 
-debug("Set invalid values to binaryType. They should be ignored. No exception should be thrown.");
-
-ws.binaryType = "Blob";
+shouldThrow("ws.binaryType = 'Blob'", "'Error: SyntaxError: DOM Exception 12'");
 shouldBeEqualToString("ws.binaryType", "blob");
 
-ws.binaryType = "ArrayBuffer"
+shouldThrow("ws.binaryType = 'ArrayBuffer'", "'Error: SyntaxError: DOM Exception 12'");
 shouldBeEqualToString("ws.binaryType", "blob");
 
-ws.binaryType = "";
+shouldThrow("ws.binaryType = ''", "'Error: SyntaxError: DOM Exception 12'");
 shouldBeEqualToString("ws.binaryType", "blob");
 
 </script>

Modified: trunk/Source/WebCore/ChangeLog (198481 => 198482)


--- trunk/Source/WebCore/ChangeLog	2016-03-21 05:11:38 UTC (rev 198481)
+++ trunk/Source/WebCore/ChangeLog	2016-03-21 05:28:21 UTC (rev 198482)
@@ -1,3 +1,18 @@
+2016-03-20  Jinwoo Jeong  <[email protected]>
+
+        The setter of binaryType attribute in WebSocket should raise the exception.
+        https://bugs.webkit.org/show_bug.cgi?id=135874
+
+        Reviewed by Antonio Gomes.
+
+        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.
+
 2016-03-20  Dan Bernstein  <[email protected]>
 
         [Mac] Determine TARGET_MAC_OS_X_VERSION_MAJOR from MACOSX_DEPLOYMENT_TARGET rather than from MAC_OS_X_VERSION_MAJOR

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (198481 => 198482)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2016-03-21 05:11:38 UTC (rev 198481)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2016-03-21 05:28:21 UTC (rev 198482)
@@ -443,7 +443,7 @@
     return String();
 }
 
-void WebSocket::setBinaryType(const String& binaryType)
+void WebSocket::setBinaryType(const String& binaryType, ExceptionCode& ec)
 {
     if (binaryType == "blob") {
         m_binaryType = BinaryTypeBlob;
@@ -453,6 +453,7 @@
         m_binaryType = BinaryTypeArrayBuffer;
         return;
     }
+    ec = SYNTAX_ERR;
     scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, "'" + binaryType + "' is not a valid value for binaryType; binaryType remains unchanged.");
 }
 

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.h (198481 => 198482)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.h	2016-03-21 05:11:38 UTC (rev 198481)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.h	2016-03-21 05:28:21 UTC (rev 198482)
@@ -88,7 +88,7 @@
     String extensions() const;
 
     String binaryType() const;
-    void setBinaryType(const String&);
+    void setBinaryType(const String&, ExceptionCode&);
 
     // EventTarget functions.
     EventTargetInterface eventTargetInterface() const override;

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.idl (198481 => 198482)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.idl	2016-03-21 05:11:38 UTC (rev 198481)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.idl	2016-03-21 05:28:21 UTC (rev 198482)
@@ -60,7 +60,7 @@
     readonly attribute DOMString? protocol;
     readonly attribute DOMString? extensions;
 
-    attribute DOMString binaryType;
+    [SetterRaisesException] attribute DOMString binaryType;
 
     [RaisesException] void send(ArrayBuffer data);
     [RaisesException] void send(ArrayBufferView data);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to