Title: [130019] trunk
Revision
130019
Author
ba...@chromium.org
Date
2012-10-01 02:29:31 -0700 (Mon, 01 Oct 2012)

Log Message

[WebSocket] Setting wrong value to binaryType should not raise exception
https://bugs.webkit.org/show_bug.cgi?id=97999

Reviewed by Yuta Kitamura.

Source/WebCore:

Don't raise exception when binaryType is the wrong value.
Instead, show an error message to console.

No new tests. Updated existing test.

* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::setBinaryType): See the description.
* Modules/websockets/WebSocket.h:
(WebSocket): Removed ExceptionCode argument of setBinaryType().
* Modules/websockets/WebSocket.idl:
Removed "setter raises(DOMException)" and "[TreatReturnedNullStringAs=Undefined]".
They are no longer needed.

LayoutTests:

Update binary-type.html.

* http/tests/websocket/tests/hybi/binary-type-expected.txt:
* http/tests/websocket/tests/hybi/binary-type.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (130018 => 130019)


--- trunk/LayoutTests/ChangeLog	2012-10-01 09:18:42 UTC (rev 130018)
+++ trunk/LayoutTests/ChangeLog	2012-10-01 09:29:31 UTC (rev 130019)
@@ -1,3 +1,15 @@
+2012-10-01  Kenichi Ishibashi  <ba...@chromium.org>
+
+        [WebSocket] Setting wrong value to binaryType should not raise exception
+        https://bugs.webkit.org/show_bug.cgi?id=97999
+
+        Reviewed by Yuta Kitamura.
+
+        Update binary-type.html.
+
+        * http/tests/websocket/tests/hybi/binary-type-expected.txt:
+        * http/tests/websocket/tests/hybi/binary-type.html:
+
 2012-10-01  Andrey Kosyakov  <ca...@chromium.org>
 
         Unreviewed gardening. Added expectations for 4 month-multiple-fields tests for chromium mac & win.

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


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/binary-type-expected.txt	2012-10-01 09:18:42 UTC (rev 130018)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/binary-type-expected.txt	2012-10-01 09:29:31 UTC (rev 130019)
@@ -1,3 +1,6 @@
+CONSOLE MESSAGE: 'Blob' is not a valid value for binaryType; binaryType remains unchanged.
+CONSOLE MESSAGE: 'ArrayBuffer' is not a valid value for binaryType; binaryType remains unchanged.
+CONSOLE MESSAGE: '' 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".
@@ -5,9 +8,10 @@
 PASS ws.binaryType is "blob"
 PASS ws.binaryType is "arraybuffer"
 PASS ws.binaryType is "blob"
-PASS ws.binaryType = 'Blob' threw exception Error: SYNTAX_ERR: DOM Exception 12.
-PASS ws.binaryType = 'ArrayBuffer' threw exception Error: SYNTAX_ERR: DOM Exception 12.
-PASS ws.binaryType = '' threw exception Error: SYNTAX_ERR: DOM Exception 12.
+Set invalid values to binaryType. They should be ignored. No exception should be thrown.
+PASS ws.binaryType is "blob"
+PASS ws.binaryType is "blob"
+PASS ws.binaryType is "blob"
 PASS successfullyParsed is true
 
 TEST COMPLETE

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


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/binary-type.html	2012-10-01 09:18:42 UTC (rev 130018)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/binary-type.html	2012-10-01 09:29:31 UTC (rev 130019)
@@ -18,10 +18,17 @@
 ws.binaryType = "blob";
 shouldBeEqualToString("ws.binaryType", "blob");
 
-shouldThrow("ws.binaryType = 'Blob'", "'Error: SYNTAX_ERR: DOM Exception 12'");
-shouldThrow("ws.binaryType = 'ArrayBuffer'", "'Error: SYNTAX_ERR: DOM Exception 12'");
-shouldThrow("ws.binaryType = ''", "'Error: SYNTAX_ERR: DOM Exception 12'");
+debug("Set invalid values to binaryType. They should be ignored. No exception should be thrown.");
 
+ws.binaryType = "Blob";
+shouldBeEqualToString("ws.binaryType", "blob");
+
+ws.binaryType = "ArrayBuffer"
+shouldBeEqualToString("ws.binaryType", "blob");
+
+ws.binaryType = "";
+shouldBeEqualToString("ws.binaryType", "blob");
+
 </script>
 <script src=""
 </body>

Modified: trunk/Source/WebCore/ChangeLog (130018 => 130019)


--- trunk/Source/WebCore/ChangeLog	2012-10-01 09:18:42 UTC (rev 130018)
+++ trunk/Source/WebCore/ChangeLog	2012-10-01 09:29:31 UTC (rev 130019)
@@ -1,3 +1,23 @@
+2012-10-01  Kenichi Ishibashi  <ba...@chromium.org>
+
+        [WebSocket] Setting wrong value to binaryType should not raise exception
+        https://bugs.webkit.org/show_bug.cgi?id=97999
+
+        Reviewed by Yuta Kitamura.
+
+        Don't raise exception when binaryType is the wrong value.
+        Instead, show an error message to console.
+
+        No new tests. Updated existing test.
+
+        * Modules/websockets/WebSocket.cpp:
+        (WebCore::WebSocket::setBinaryType): See the description.
+        * Modules/websockets/WebSocket.h:
+        (WebSocket): Removed ExceptionCode argument of setBinaryType().
+        * Modules/websockets/WebSocket.idl:
+        Removed "setter raises(DOMException)" and "[TreatReturnedNullStringAs=Undefined]".
+        They are no longer needed.
+
 2012-10-01  Yoshifumi Inoue  <yo...@chromium.org>
 
         [Forms] Adding DateTimeWeekFieldElement for multiple fields "week" input UI

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (130018 => 130019)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2012-10-01 09:18:42 UTC (rev 130018)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2012-10-01 09:29:31 UTC (rev 130019)
@@ -404,7 +404,7 @@
     return String();
 }
 
-void WebSocket::setBinaryType(const String& binaryType, ExceptionCode& ec)
+void WebSocket::setBinaryType(const String& binaryType)
 {
     if (binaryType == "blob") {
         m_binaryType = BinaryTypeBlob;
@@ -414,8 +414,7 @@
         m_binaryType = BinaryTypeArrayBuffer;
         return;
     }
-    ec = SYNTAX_ERR;
-    return;
+    scriptExecutionContext()->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "'" + binaryType + "' is not a valid value for binaryType; binaryType remains unchanged.");
 }
 
 const AtomicString& WebSocket::interfaceName() const

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.h (130018 => 130019)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.h	2012-10-01 09:18:42 UTC (rev 130018)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.h	2012-10-01 09:29:31 UTC (rev 130019)
@@ -86,7 +86,7 @@
     String extensions() const;
 
     String binaryType() const;
-    void setBinaryType(const String& binaryType, ExceptionCode&);
+    void setBinaryType(const String&);
 
     DEFINE_ATTRIBUTE_EVENT_LISTENER(open);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(message);

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.idl (130018 => 130019)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.idl	2012-10-01 09:18:42 UTC (rev 130018)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.idl	2012-10-01 09:29:31 UTC (rev 130019)
@@ -60,8 +60,7 @@
         readonly attribute [TreatReturnedNullStringAs=Undefined] DOMString protocol;
         readonly attribute [TreatReturnedNullStringAs=Undefined] DOMString extensions;
 
-        attribute [TreatReturnedNullStringAs=Undefined] DOMString binaryType
-            setter raises(DOMException);
+        attribute DOMString binaryType;
 
         // FIXME: Use overloading provided by our IDL code generator.
         // According to Web IDL specification, overloaded function with DOMString argument
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to