Changeset 205117 in webkit
- Timestamp:
- Aug 29, 2016 3:52:42 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r205115 r205117 1 2016-08-29 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Response cloning should structureClone when teeing Response stream 4 https://bugs.webkit.org/show_bug.cgi?id=161147 5 6 Reviewed by Darin Adler. 7 8 * web-platform-tests/fetch/api/response/response-clone-expected.txt: 9 * web-platform-tests/fetch/api/response/response-clone.html: 10 1 11 2016-08-29 Youenn Fablet <youenn@apple.com> 2 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone-expected.txt
r205110 r205117 7 7 PASS Cloned responses should provide the same data 8 8 PASS Cancelling stream should not affect cloned one 9 PASS Check response clone use structureClone for teed ReadableStreams (Int8Arraychunk) 10 PASS Check response clone use structureClone for teed ReadableStreams (Int16Arraychunk) 11 PASS Check response clone use structureClone for teed ReadableStreams (Int32Arraychunk) 12 PASS Check response clone use structureClone for teed ReadableStreams (ArrayBufferchunk) 13 PASS Check response clone use structureClone for teed ReadableStreams (Uint8Arraychunk) 14 PASS Check response clone use structureClone for teed ReadableStreams (Uint8ClampedArraychunk) 15 PASS Check response clone use structureClone for teed ReadableStreams (Uint16Arraychunk) 16 PASS Check response clone use structureClone for teed ReadableStreams (Uint32Arraychunk) 17 PASS Check response clone use structureClone for teed ReadableStreams (Float32Arraychunk) 18 PASS Check response clone use structureClone for teed ReadableStreams (Float64Arraychunk) 19 PASS Check response clone use structureClone for teed ReadableStreams (DataViewchunk) 9 20 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.html
r205110 r205117 94 94 }, 'Cancelling stream should not affect cloned one'); 95 95 96 function testReadableStreamClone(initialBuffer, bufferType) 97 { 98 promise_test(function(test) { 99 var response = new Response(new ReadableStream({start : function(controller) { 100 controller.enqueue(initialBuffer); 101 controller.close(); 102 }})); 103 104 var clone = response.clone(); 105 var stream1 = response.body; 106 var stream2 = clone.body; 107 108 var buffer; 109 return stream1.getReader().read().then(function(data) { 110 assert_false(data.done); 111 assert_array_equals(data.value, initialBuffer, "Cloned buffer chunks have the same content"); 112 assert_equals(Object.getPrototypeOf(data.value), Object.getPrototypeOf(initialBuffer), "Cloned buffers have the same type"); 113 assert_true(data.value !== initialBuffer, "Cloned buffers are different objects"); 114 return stream2.getReader().read(); 115 }).then(function(data) { 116 assert_false(data.done); 117 assert_array_equals(data.value, initialBuffer, "Cloned buffer chunks have the same content"); 118 assert_equals(Object.getPrototypeOf(data.value), Object.getPrototypeOf(initialBuffer), "Cloned buffers have the same type"); 119 assert_true(data.value !== initialBuffer, "Cloned buffers are different objects"); 120 }); 121 }, "Check response clone use structureClone for teed ReadableStreams (" + bufferType + "chunk)"); 122 } 123 124 var arrayBuffer = new ArrayBuffer(16); 125 testReadableStreamClone(new Int8Array(arrayBuffer, 1), "Int8Array"); 126 testReadableStreamClone(new Int16Array(arrayBuffer, 2, 2), "Int16Array"); 127 testReadableStreamClone(new Int32Array(arrayBuffer), "Int32Array"); 128 testReadableStreamClone(arrayBuffer, "ArrayBuffer"); 129 testReadableStreamClone(new Uint8Array(arrayBuffer), "Uint8Array"); 130 testReadableStreamClone(new Uint8ClampedArray(arrayBuffer), "Uint8ClampedArray"); 131 testReadableStreamClone(new Uint16Array(arrayBuffer, 2), "Uint16Array"); 132 testReadableStreamClone(new Uint32Array(arrayBuffer), "Uint32Array"); 133 testReadableStreamClone(new Float32Array(arrayBuffer), "Float32Array"); 134 testReadableStreamClone(new Float64Array(arrayBuffer), "Float64Array"); 135 testReadableStreamClone(new DataView(arrayBuffer, 2, 8), "DataView"); 96 136 </script> 97 137 </body> -
trunk/Source/JavaScriptCore/ChangeLog
r205112 r205117 1 2016-08-29 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Response cloning should structureClone when teeing Response stream 4 https://bugs.webkit.org/show_bug.cgi?id=161147 5 6 Reviewed by Darin Adler. 7 8 * builtins/BuiltinNames.h: Adding ArrayBuffer and isView identifiers. 9 * runtime/JSArrayBufferConstructor.cpp: 10 (JSC::JSArrayBufferConstructor::finishCreation): Adding @isView as private method. 11 * runtime/JSDataView.h: Exporting create method. 12 1 13 2016-08-29 Benjamin Poulain <bpoulain@apple.com> 2 14 -
trunk/Source/JavaScriptCore/builtins/BuiltinNames.h
r204058 r205117 37 37 JSC_COMMON_BYTECODE_INTRINSIC_FUNCTIONS_EACH_NAME(macro) \ 38 38 JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_EACH_NAME(macro) \ 39 macro(iteratedObject) \40 39 macro(arrayIteratorNextIndex) \ 41 40 macro(arrayIterationKind) \ … … 44 43 macro(arrayIteratorKind) \ 45 44 macro(charCodeAt) \ 45 macro(isView) \ 46 macro(iteratedObject) \ 46 47 macro(iteratedString) \ 47 48 macro(stringIteratorNextIndex) \ … … 56 57 macro(Number) \ 57 58 macro(Array) \ 59 macro(ArrayBuffer) \ 58 60 macro(String) \ 59 61 macro(RegExp) \ -
trunk/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
r203320 r205117 27 27 #include "JSArrayBufferConstructor.h" 28 28 29 #include "BuiltinNames.h" 29 30 #include "Error.h" 30 31 #include "ExceptionHelpers.h" … … 58 59 JSGlobalObject* globalObject = this->globalObject(); 59 60 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->isView, arrayBufferFuncIsView, DontEnum, 1); 61 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().isViewPrivateName(), arrayBufferFuncIsView, DontEnum, 1); 60 62 } 61 63 -
trunk/Source/JavaScriptCore/runtime/JSDataView.h
r198023 r205117 41 41 42 42 public: 43 static JSDataView* create(43 JS_EXPORT_PRIVATE static JSDataView* create( 44 44 ExecState*, Structure*, PassRefPtr<ArrayBuffer>, unsigned byteOffset, 45 45 unsigned byteLength); -
trunk/Source/WebCore/CMakeLists.txt
r205103 r205117 1258 1258 bindings/js/ScriptGlobalObject.cpp 1259 1259 bindings/js/ScriptState.cpp 1260 bindings/js/StructuredClone.cpp 1260 1261 bindings/js/SerializedScriptValue.cpp 1261 1262 bindings/js/WebCoreTypedArrayController.cpp -
trunk/Source/WebCore/ChangeLog
r205116 r205117 1 2016-08-29 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Response cloning should structureClone when teeing Response stream 4 https://bugs.webkit.org/show_bug.cgi?id=161147 5 6 Reviewed by Darin Adler. 7 8 Covered by updated test. 9 10 Implementing structure cloning for ArrayBuffer and ArrayBufferView objects. 11 Using this structure cloning in ReadableStream to support structureClone in the case of Fetch API. 12 13 * CMakeLists.txt: Adding StructureClone.cpp 14 * Modules/fetch/FetchResponse.js: 15 (clone): Setting structureClone to true 16 * Modules/streams/ReadableStreamInternals.js: 17 (doStructuredClone): Added to clone ArrayBuffer/ArrayBufferView chunks. Throwing exception otherwise. 18 (teeReadableStreamPullFunction): Using @doStructuredClone 19 * WebCore.xcodeproj/project.pbxproj: Adding StructureClone.cpp/.h 20 * bindings/js/JSDOMGlobalObject.cpp: 21 (WebCore::JSDOMGlobalObject::addBuiltinGlobals): Adding @ArrayBuffer and structuredCloneArrayBuffer and structuredCloneArrayBufferView private properties. 22 * bindings/js/StructuredClone.cpp: Added. 23 (WebCore::structuredCloneArrayBuffer): Cloning of ArrayBuffer as per 24 http://w3c.github.io/html/infrastructure.html#section-structuredclone step 11. 25 (WebCore::structuredCloneArrayBufferView): Cloning of ArrayBufferView as 26 perhttp://w3c.github.io/html/infrastructure.html#section-structuredclone, step 12. 27 * bindings/js/StructuredClone.h: Added. 28 * bindings/js/WebCoreBuiltinNames.h: 29 1 30 2016-08-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 31 -
trunk/Source/WebCore/Modules/fetch/FetchResponse.js
r205110 r205117 97 97 98 98 if (this.@body) { 99 var teedReadableStreams = @teeReadableStream(this.@body, false);99 var teedReadableStreams = @teeReadableStream(this.@body, true); 100 100 this.@body = teedReadableStreams[0]; 101 101 cloned.@body = teedReadableStreams[1]; -
trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js
r205110 r205117 112 112 } 113 113 114 function doStructuredClone(object) 115 { 116 // FIXME: We should implement http://w3c.github.io/html/infrastructure.html#ref-for-structured-clone-4 117 // Implementation is currently limited to ArrayBuffer/ArrayBufferView to meet Fetch API needs. 118 119 if (object instanceof @ArrayBuffer) 120 return @structuredCloneArrayBuffer(object); 121 122 if (@ArrayBuffer.@isView(object)) 123 return @structuredCloneArrayBufferView(object); 124 125 throw new @TypeError("structuredClone not implemented for: " + object); 126 } 127 114 128 function teeReadableStreamPullFunction(teeState, reader, shouldClone) 115 129 { … … 127 141 if (teeState.closedOrErrored) 128 142 return; 129 if (!teeState.canceled1) { 130 // FIXME: Implement cloning if shouldClone is true 131 @enqueueInReadableStream(teeState.branch1, result.value); 132 } 133 if (!teeState.canceled2) { 134 // FIXME: Implement cloning if shouldClone is true 135 @enqueueInReadableStream(teeState.branch2, result.value); 136 } 143 if (!teeState.canceled1) 144 @enqueueInReadableStream(teeState.branch1, shouldClone ? @doStructuredClone(result.value) : result.value); 145 if (!teeState.canceled2) 146 @enqueueInReadableStream(teeState.branch2, shouldClone ? @doStructuredClone(result.value) : result.value); 137 147 }); 138 148 } -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r205103 r205117 1514 1514 4147E2B71C89912C00A7E715 /* FetchLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4147E2B41C89912600A7E715 /* FetchLoader.cpp */; }; 1515 1515 4147E2B81C89912F00A7E715 /* FetchBodyOwner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4147E2B31C89912600A7E715 /* FetchBodyOwner.cpp */; }; 1516 414B82041D6DF0DF0077EBE3 /* StructuredClone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 414B82021D6DF0D90077EBE3 /* StructuredClone.cpp */; }; 1517 414B82051D6DF0E50077EBE3 /* StructuredClone.h in Headers */ = {isa = PBXBuildFile; fileRef = 414B82031D6DF0D90077EBE3 /* StructuredClone.h */; }; 1516 1518 415071571685067300C3C7B3 /* SelectorFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 415071551685067300C3C7B3 /* SelectorFilter.cpp */; }; 1517 1519 415071581685067300C3C7B3 /* SelectorFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 415071561685067300C3C7B3 /* SelectorFilter.h */; }; … … 8405 8407 4147E2B51C89912600A7E715 /* FetchLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchLoader.h; sourceTree = "<group>"; }; 8406 8408 4147E2B61C89912600A7E715 /* FetchLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchLoaderClient.h; sourceTree = "<group>"; }; 8409 414B82021D6DF0D90077EBE3 /* StructuredClone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StructuredClone.cpp; sourceTree = "<group>"; }; 8410 414B82031D6DF0D90077EBE3 /* StructuredClone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructuredClone.h; sourceTree = "<group>"; }; 8407 8411 415071551685067300C3C7B3 /* SelectorFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectorFilter.cpp; sourceTree = "<group>"; }; 8408 8412 415071561685067300C3C7B3 /* SelectorFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectorFilter.h; sourceTree = "<group>"; }; … … 20971 20975 A75E497510752ACB00C9B896 /* SerializedScriptValue.cpp */, 20972 20976 A75E497410752ACB00C9B896 /* SerializedScriptValue.h */, 20977 414B82021D6DF0D90077EBE3 /* StructuredClone.cpp */, 20978 414B82031D6DF0D90077EBE3 /* StructuredClone.h */, 20973 20979 419BE7521BC7F3DB00E1C85B /* WebCoreBuiltinNames.h */, 20974 20980 BC53D910114310CC000D817E /* WebCoreJSClientData.h */, … … 26928 26934 494BD7950F55C8EE00747828 /* WebKitPoint.h in Headers */, 26929 26935 5709E8CF1D413D9A003244AC /* WebKitSubtleCrypto.h in Headers */, 26936 414B82051D6DF0E50077EBE3 /* StructuredClone.h in Headers */, 26930 26937 31C0FF250E4CEB6E007D6FE5 /* WebKitTransitionEvent.h in Headers */, 26931 26938 0FCF332F0F2B9A25004B6795 /* WebLayer.h in Headers */, … … 28669 28676 511EF2C517F0FD3500E4FA16 /* JSIDBIndex.cpp in Sources */, 28670 28677 5141299B1C6C16740059E714 /* JSIDBIndexCustom.cpp in Sources */, 28678 414B82041D6DF0DF0077EBE3 /* StructuredClone.cpp in Sources */, 28671 28679 511EF2C617F0FD3500E4FA16 /* JSIDBKeyRange.cpp in Sources */, 28672 28680 511EF2C717F0FD3500E4FA16 /* JSIDBObjectStore.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp
r203818 r205117 39 39 #include "JSWorkerGlobalScope.h" 40 40 #include "RuntimeEnabledFeatures.h" 41 #include "StructuredClone.h" 41 42 #include "WebCoreJSClientData.h" 42 43 #include "WorkerGlobalScope.h" 44 #include <builtins/BuiltinNames.h> 43 45 44 46 using namespace JSC; … … 106 108 JSDOMGlobalObject::GlobalPropertyInfo staticGlobals[] = { 107 109 JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().makeThisTypeErrorPrivateName(), 108 110 JSFunction::create(vm, this, 2, String(), makeThisTypeErrorForBuiltins), DontDelete | ReadOnly), 109 111 JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().makeGetterTypeErrorPrivateName(), 110 JSFunction::create(vm, this, 2, String(), makeGetterTypeErrorForBuiltins), DontDelete | ReadOnly), 112 JSFunction::create(vm, this, 2, String(), makeGetterTypeErrorForBuiltins), DontDelete | ReadOnly), 113 JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().structuredCloneArrayBufferPrivateName(), 114 JSFunction::create(vm, this, 1, String(), structuredCloneArrayBuffer), DontDelete | ReadOnly), 115 JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().structuredCloneArrayBufferViewPrivateName(), 116 JSFunction::create(vm, this, 1, String(), structuredCloneArrayBufferView), DontDelete | ReadOnly), 117 JSDOMGlobalObject::GlobalPropertyInfo(vm.propertyNames->builtinNames().ArrayBufferPrivateName(), getDirect(vm, vm.propertyNames->ArrayBuffer), DontDelete | ReadOnly), 111 118 #if ENABLE(STREAMS_API) 112 119 JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamClosedPrivateName(), jsNumber(1), DontDelete | ReadOnly), -
trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
r205110 r205117 91 91 macro(streamWaiting) \ 92 92 macro(streamWritable) \ 93 macro(structuredCloneArrayBuffer) \ 94 macro(structuredCloneArrayBufferView) \ 93 95 macro(underlyingSink) \ 94 96 macro(underlyingSource) \
Note: See TracChangeset
for help on using the changeset viewer.