Support RTCDataChannel blob binaryType
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Apr 2019 21:51:10 +0000 (21:51 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Apr 2019 21:51:10 +0000 (21:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196821

Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

* web-platform-tests/webrtc/RTCDataChannel-send-expected.txt:

Source/WebCore:

Add support for receiving blobs.
Default value is still left to 'arraybuffer' which is not spec compliant.
Covered by rebased test.

* Modules/mediastream/RTCDataChannel.cpp:
(WebCore::RTCDataChannel::setBinaryType):
(WebCore::RTCDataChannel::didReceiveRawData):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244196 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannel-send-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/RTCDataChannel.cpp

index 0de1054..6e02707 100644 (file)
@@ -1,3 +1,12 @@
+2019-04-11  Youenn Fablet  <youenn@apple.com>
+
+        Support RTCDataChannel blob binaryType
+        https://bugs.webkit.org/show_bug.cgi?id=196821
+
+        Reviewed by Eric Carlson.
+
+        * web-platform-tests/webrtc/RTCDataChannel-send-expected.txt:
+
 2019-04-10  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         requestAnimationFrame should execute before the next frame
index 6fbefac..13732c5 100644 (file)
@@ -6,7 +6,7 @@ PASS Data channel should ignore binaryType and always receive string message as
 PASS Data channel should be able to send Uint8Array message and receive as ArrayBuffer 
 PASS Data channel should be able to send ArrayBuffer message and receive as ArrayBuffer 
 FAIL Data channel should be able to send Blob message and receive as ArrayBuffer promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
-FAIL Data channel should be able to send ArrayBuffer message and receive as Blob promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
+PASS Data channel should be able to send ArrayBuffer message and receive as Blob 
 FAIL Data channel binaryType should receive message as Blob by default assert_equals: Expect initial binaryType value to be blob expected "blob" but got "arraybuffer"
 FAIL Sending multiple messages with different types should succeed and be received assert_unreached: Unexpected promise rejection: NotSupportedError: The operation is not supported. Reached unreachable code
 
index 7c1a454..62e4a6b 100644 (file)
@@ -1,3 +1,18 @@
+2019-04-11  Youenn Fablet  <youenn@apple.com>
+
+        Support RTCDataChannel blob binaryType
+        https://bugs.webkit.org/show_bug.cgi?id=196821
+
+        Reviewed by Eric Carlson.
+
+        Add support for receiving blobs.
+        Default value is still left to 'arraybuffer' which is not spec compliant.
+        Covered by rebased test.
+
+        * Modules/mediastream/RTCDataChannel.cpp:
+        (WebCore::RTCDataChannel::setBinaryType):
+        (WebCore::RTCDataChannel::didReceiveRawData):
+
 2019-04-11  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Timelines: can't reliably stop/start a recording
index 95ebbe9..b62c44f 100644 (file)
@@ -34,6 +34,7 @@
 #include "MessageEvent.h"
 #include "RTCDataChannelHandler.h"
 #include "ScriptExecutionContext.h"
+#include "SharedBuffer.h"
 #include <JavaScriptCore/ArrayBuffer.h>
 #include <JavaScriptCore/ArrayBufferView.h>
 #include <wtf/IsoMallocInlines.h>
@@ -97,8 +98,10 @@ const AtomicString& RTCDataChannel::binaryType() const
 
 ExceptionOr<void> RTCDataChannel::setBinaryType(const AtomicString& binaryType)
 {
-    if (binaryType == blobKeyword())
-        return Exception { NotSupportedError };
+    if (binaryType == blobKeyword()) {
+        m_binaryType = BinaryType::Blob;
+        return { };
+    }
     if (binaryType == arraybufferKeyword()) {
         m_binaryType = BinaryType::ArrayBuffer;
         return { };
@@ -197,12 +200,11 @@ void RTCDataChannel::didReceiveRawData(const char* data, size_t dataLength)
     if (m_stopped)
         return;
 
-    if (m_binaryType == BinaryType::Blob) {
-        // FIXME: Implement.
+    switch (m_binaryType) {
+    case BinaryType::Blob:
+        scheduleDispatchEvent(MessageEvent::create(Blob::create(SharedBuffer::create(data, dataLength), emptyString()), { }));
         return;
-    }
-
-    if (m_binaryType == BinaryType::ArrayBuffer) {
+    case BinaryType::ArrayBuffer:
         scheduleDispatchEvent(MessageEvent::create(ArrayBuffer::create(data, dataLength)));
         return;
     }