[Readable Streams API] Implement cloneArrayBuffer in WebCore
https://bugs.webkit.org/show_bug.cgi?id=170008

Patch by Romain Bellessort <romain.bellessort@crf.canon.fr> on 2017-04-13
Reviewed by Youenn Fablet.

Source/WebCore:

Implemented cloneArrayBuffer based on existing structuredCloneArrayBuffer
implementation. The code has been factorized so that both cloneArrayBuffer
and structuredCloneArrayBuffer rely on the same code (which is basically
the previous implementation of structuredCloneArrayBuffer + the ability
to clone only a part of considered buffer).

Test: streams/clone-array-buffer.html

* Modules/streams/ReadableByteStreamInternals.js: Deleted cloneArrayBuffer JS implementation.
* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::addBuiltinGlobals): Add cloneArrayBuffer private declaration.
* bindings/js/StructuredClone.cpp:
(WebCore::cloneArrayBufferImpl): Added (mostly based on previous structuredCloneArrayBuffer).
(WebCore::cloneArrayBuffer): Added.
(WebCore::structuredCloneArrayBuffer): Updated.
* bindings/js/StructuredClone.h: Added cloneArrayBuffer declaration.
* bindings/js/WebCoreBuiltinNames.h: Added cloneArrayBuffer declaration.
* testing/Internals.cpp: Added support for testing cloneArrayBuffer.
* testing/Internals.h: Added support for testing cloneArrayBuffer.
* testing/Internals.idl: Added support for testing cloneArrayBuffer.

LayoutTests:

Added test to check cloneArrayBuffer behaviour.

* streams/clone-array-buffer-expected.txt: Added.
* streams/clone-array-buffer.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@215322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
index 25d2e47..39baa47 100644
--- a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
+++ b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
@@ -39,6 +39,7 @@
     macro(body) \
     macro(byobRequest) \
     macro(cancel) \
+    macro(cloneArrayBuffer) \
     macro(cloneForJS) \
     macro(closeRequested) \
     macro(closedPromiseCapability) \