Changeset 221329 in webkit
- Timestamp:
- Aug 29, 2017, 5:39:26 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r221214 r221329 1 2017-08-29 Youenn Fablet <youenn@apple.com> 2 3 Add support for FetchRequest.body 4 https://bugs.webkit.org/show_bug.cgi?id=176066 5 6 Reviewed by Alex Christensen. 7 8 * web-platform-tests/fetch/api/request/request-disturbed-expected.txt: 9 * web-platform-tests/fetch/api/request/request-idl-expected.txt: 10 1 11 2017-08-25 Youenn Fablet <youenn@apple.com> 2 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-disturbed-expected.txt
r212202 r221329 1 1 2 FAIL Request's body: initial state assert_equals: body's default value is null expected (object) null but got (undefined) undefined 2 PASS Request's body: initial state 3 3 PASS Request without body cannot be disturbed 4 4 PASS Check cloning a disturbed request 5 5 PASS Check creating a new request from a disturbed request 6 FAIL Input request used for creating new request became disturbed assert_ not_equals: body should not be undefined got disallowed value undefined6 FAIL Input request used for creating new request became disturbed assert_equals: body should not change expected object "[object ReadableStream]" but got object "[object ReadableStream]" 7 7 FAIL Input request used for creating new request became disturbed even if body is not used assert_true: bodyUsed is true when request is disturbed expected true got false 8 8 PASS Check consuming a disturbed request -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-idl-expected.txt
r220244 r221329 19 19 PASS Request interface: attribute keepalive 20 20 PASS Request interface: operation clone() 21 FAIL Request interface: attribute body assert_true: The prototype object must have a property "body" expected true got false 21 PASS Request interface: attribute body 22 22 PASS Request interface: attribute bodyUsed 23 23 PASS Request interface: operation arrayBuffer() … … 40 40 PASS Request interface: new Request("") must inherit property "keepalive" with the proper type (12) 41 41 PASS Request interface: new Request("") must inherit property "clone" with the proper type (13) 42 FAIL Request interface: new Request("") must inherit property "body" with the proper type (14) assert_inherits: property "body" not found in prototype chain 42 PASS Request interface: new Request("") must inherit property "body" with the proper type (14) 43 43 PASS Request interface: new Request("") must inherit property "bodyUsed" with the proper type (15) 44 44 PASS Request interface: new Request("") must inherit property "arrayBuffer" with the proper type (16) -
trunk/Source/WebCore/CMakeLists.txt
r221309 r221329 1286 1286 bindings/js/JSXPathNSResolverCustom.cpp 1287 1287 bindings/js/JSXPathResultCustom.cpp 1288 bindings/js/ReadableStream.cpp 1288 1289 bindings/js/ReadableStreamDefaultController.cpp 1289 1290 bindings/js/ScheduledAction.cpp -
trunk/Source/WebCore/ChangeLog
r221327 r221329 1 2017-08-29 Youenn Fablet <youenn@apple.com> 2 3 Add support for FetchRequest.body 4 https://bugs.webkit.org/show_bug.cgi?id=176066 5 6 Reviewed by Alex Christensen. 7 8 Covered by existing tests. 9 10 Adding support for body attribute getter for FetchRequest. 11 To do so, FetchRequest will need to create a ReadableStream. 12 Adding support for DOM based creation of ReadableStream and conversion to JS values. 13 Small refactoring to make names more consistent. 14 15 * CMakeLists.txt: 16 * Modules/beacon/NavigatorBeacon.cpp: 17 (WebCore::NavigatorBeacon::sendBeacon): 18 * Modules/cache/Cache.cpp: 19 (WebCore::Cache::put): 20 * Modules/fetch/FetchBody.cpp: 21 (WebCore::FetchBody::extract): 22 * Modules/fetch/FetchBody.h: 23 (WebCore::FetchBody::hasReadableStream const): 24 (WebCore::FetchBody::readableStream): 25 (WebCore::FetchBody::setReadableStream): 26 (WebCore::FetchBody::FetchBody): 27 (WebCore::FetchBody::isReadableStream const): Deleted. 28 (WebCore::FetchBody::setAsReadableStream): Deleted. 29 * Modules/fetch/FetchBody.idl: 30 * Modules/fetch/FetchBodyOwner.cpp: 31 (WebCore::FetchBodyOwner::readableStream): 32 * Modules/fetch/FetchBodyOwner.h: 33 (WebCore::FetchBodyOwner::hasReadableStreamBody const): 34 (WebCore::FetchBodyOwner::isReadableStreamBody const): Deleted. 35 * Modules/fetch/FetchRequest.cpp: 36 (WebCore::FetchRequest::setBody): 37 * Modules/fetch/FetchRequest.h: 38 * Modules/fetch/FetchResponse.cpp: 39 (WebCore::FetchResponse::setBodyAsReadableStream): 40 (WebCore::FetchResponse::fetch): 41 * Modules/fetch/FetchResponse.h: 42 * WebCore.xcodeproj/project.pbxproj: 43 * bindings/js/ReadableStream.h: 44 (WebCore::JSConverter<IDLInterface<ReadableStream>>::convert): 45 1 46 2017-08-29 Yusuke Suzuki <utatane.tea@gmail.com> 2 47 -
trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp
r221201 r221329 131 131 auto fetchBody = FetchBody::extract(document, WTFMove(body.value()), mimeType); 132 132 133 if (fetchBody. isReadableStream())133 if (fetchBody.hasReadableStream()) 134 134 return Exception { TypeError, ASCIILiteral("Beacons cannot send ReadableStream body") }; 135 135 -
trunk/Source/WebCore/Modules/cache/Cache.cpp
r221112 r221329 297 297 298 298 // FIXME: Add support for ReadableStream. 299 if (response-> isReadableStreamBody()) {299 if (response->hasReadableStreamBody()) { 300 300 promise.reject(Exception { NotSupportedError, ASCIILiteral("Caching a Response with data stored in a ReadableStream is not yet supported") }); 301 301 return; -
trunk/Source/WebCore/Modules/fetch/FetchBody.cpp
r221201 r221329 62 62 Ref<const ArrayBufferView> buffer = value.releaseNonNull(); 63 63 return FetchBody(WTFMove(buffer)); 64 }, [&](RefPtr<ReadableStream>&) mutable { 65 FetchBody body; 66 body.m_isReadableStream = true; 67 return body; 64 }, [&](RefPtr<ReadableStream>& stream) mutable { 65 return FetchBody(stream.releaseNonNull()); 68 66 }, [&](String& value) { 69 67 contentType = HTTPHeaderValues::textPlainContentType(); -
trunk/Source/WebCore/Modules/fetch/FetchBody.h
r221201 r221329 61 61 bool isURLSearchParams() const { return WTF::holds_alternative<Ref<const URLSearchParams>>(m_data); } 62 62 bool isText() const { return WTF::holds_alternative<String>(m_data); } 63 bool isReadableStream() const { return m_isReadableStream; }63 bool hasReadableStream() const { return !!m_readableStream; } 64 64 65 65 using Init = Variant<RefPtr<Blob>, RefPtr<ArrayBufferView>, RefPtr<ArrayBuffer>, RefPtr<DOMFormData>, RefPtr<URLSearchParams>, RefPtr<ReadableStream>, String>; … … 67 67 static FetchBody loadingBody() { return { }; } 68 68 69 void setAsReadableStream() { m_isReadableStream = true; }70 69 void loadingFailed(); 71 70 void loadingSucceeded(); … … 83 82 84 83 FetchBody clone() const; 84 ReadableStream* readableStream() { return m_readableStream.get(); } 85 void setReadableStream(Ref<ReadableStream>&& stream) 86 { 87 ASSERT(!m_readableStream); 88 m_readableStream = WTFMove(stream); 89 } 85 90 86 91 private: … … 92 97 explicit FetchBody(Ref<const URLSearchParams>&& data) : m_data(WTFMove(data)) { } 93 98 explicit FetchBody(const FetchBodyConsumer& consumer) : m_consumer(consumer) { } 99 explicit FetchBody(Ref<ReadableStream>&& stream) : m_readableStream(WTFMove(stream)) { } 94 100 FetchBody() = default; 95 101 … … 115 121 FetchBodyConsumer m_consumer { FetchBodyConsumer::Type::None }; 116 122 RefPtr<DeferredPromise> m_consumePromise; 117 118 // FIXME: We probably want to keep the stream as a specific field in m_data when we will support stream data upload. 119 bool m_isReadableStream { false }; 123 RefPtr<ReadableStream> m_readableStream; 120 124 }; 121 125 -
trunk/Source/WebCore/Modules/fetch/FetchBody.idl
r220241 r221329 34 34 ] interface FetchBody { 35 35 // FIMXE: Add missing body attribute. 36 //readonly attribute ReadableStream? body;36 [ImplementedAs=readableStream, CallWith=ScriptState] readonly attribute ReadableStream? body; 37 37 readonly attribute boolean bodyUsed; 38 38 [NewObject] Promise<ArrayBuffer> arrayBuffer(); -
trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp
r220751 r221329 289 289 } 290 290 291 ReadableStream* FetchBodyOwner::readableStream(JSC::ExecState& state) 292 { 293 if (isBodyNull()) 294 return nullptr; 295 296 if (!m_body->hasReadableStream()) 297 m_body->setReadableStream(ReadableStream::create(state, m_readableStreamSource)); 298 299 return m_body->readableStream(); 300 } 301 291 302 } // namespace WebCore -
trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h
r220758 r221329 58 58 bool isActive() const { return !!m_blobLoader; } 59 59 60 bool isReadableStreamBody() const { return m_body && m_body->isReadableStream(); } 60 ReadableStream* readableStream(JSC::ExecState&); 61 virtual bool hasReadableStreamBody() const { return m_body && m_body->hasReadableStream(); } 61 62 62 63 protected: -
trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp
r220928 r221329 226 226 if (!methodCanHaveBody(m_internalRequest)) 227 227 return Exception { TypeError }; 228 // FIXME: If body has a readable stream, we should pipe it to this new body stream. 228 229 m_body = WTFMove(request.m_body); 229 230 request.setDisturbed(); -
trunk/Source/WebCore/Modules/fetch/FetchRequest.h
r220758 r221329 86 86 const String& internalRequestReferrer() const { return m_internalRequest.referrer; } 87 87 const URL& url() const { return m_internalRequest.request.url(); } 88 bool isBodyReadableStream() const { return !isBodyNull() && body().isReadableStream(); }89 88 90 89 ResourceRequest resourceRequest() const; -
trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp
r221152 r221329 84 84 if (isBodyNull()) 85 85 setBody(FetchBody::loadingBody()); 86 body().setAsReadableStream();86 m_isReadableStream = true; 87 87 updateContentType(); 88 88 } … … 106 106 void FetchResponse::fetch(ScriptExecutionContext& context, FetchRequest& request, NotificationCallback&& responseCallback) 107 107 { 108 if (request. isBodyReadableStream()) {108 if (request.hasReadableStreamBody()) { 109 109 if (responseCallback) 110 110 responseCallback(Exception { NotSupportedError, "ReadableStream uploading is not supported" }); -
trunk/Source/WebCore/Modules/fetch/FetchResponse.h
r220948 r221329 103 103 const ResourceResponse& resourceResponse() const { return m_response; } 104 104 105 // FIXME: Remove this method and use FetchBodyOwner one once we have full support in DOM ReadableStream. 106 bool hasReadableStreamBody() const final { return m_isReadableStream; } 107 105 108 private: 106 109 FetchResponse(ScriptExecutionContext&, std::optional<FetchBody>&&, Ref<FetchHeaders>&&, ResourceResponse&&); … … 145 148 mutable String m_responseURL; 146 149 bool m_shouldExposeBody { true }; 150 // FIXME: Remove that flag once we have full support in DOM ReadableStream. 151 bool m_isReadableStream { false }; 147 152 148 153 FetchBodyConsumer m_consumer { FetchBodyConsumer::Type::ArrayBuffer }; -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r221302 r221329 1763 1763 41AD753A1CEF6BD100A31486 /* FetchOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 41AD75391CEF6BCE00A31486 /* FetchOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1764 1764 41B2A6261EF1BF6D002B9D7A /* WebAudioSourceProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 41B2A6251EF1BF60002B9D7A /* WebAudioSourceProvider.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1765 41B459EF1F55EBD10000F6FD /* ReadableStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41B459ED1F55EBC70000F6FD /* ReadableStream.cpp */; }; 1765 1766 41BF700C0FE86F49005E8DEC /* MessagePortChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1766 1767 41BF700F0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41BF700D0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp */; }; … … 9486 9487 41B2A6251EF1BF60002B9D7A /* WebAudioSourceProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebAudioSourceProvider.h; sourceTree = "<group>"; }; 9487 9488 41B459DA1F4CADB90000F6FD /* ReadableStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStream.h; sourceTree = "<group>"; }; 9489 41B459ED1F55EBC70000F6FD /* ReadableStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReadableStream.cpp; sourceTree = "<group>"; }; 9488 9490 41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessagePortChannel.h; sourceTree = "<group>"; }; 9489 9491 41BF700D0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PlatformMessagePortChannel.cpp; path = default/PlatformMessagePortChannel.cpp; sourceTree = "<group>"; }; … … 23878 23880 E1C36D330EB0A094007410BC /* JSWorkerGlobalScopeBase.h */, 23879 23881 709A01FD1E3D0BCC006B0D4C /* ModuleFetchFailureKind.h */, 23882 41B459ED1F55EBC70000F6FD /* ReadableStream.cpp */, 23880 23883 41B459DA1F4CADB90000F6FD /* ReadableStream.h */, 23881 23884 418C395E1C8F0AAB0051C8A3 /* ReadableStreamDefaultController.cpp */, … … 33294 33297 F55B3DCD1251F12D003EF269 /* RangeInputType.cpp in Sources */, 33295 33298 6E84E9E017668BEE00815B68 /* RasterShape.cpp in Sources */, 33299 41B459EF1F55EBD10000F6FD /* ReadableStream.cpp in Sources */, 33296 33300 418C39611C8F0AB10051C8A3 /* ReadableStreamDefaultController.cpp in Sources */, 33297 33301 FD31603B12B0267600C1A359 /* RealtimeAnalyser.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/ReadableStream.h
r221201 r221329 33 33 namespace WebCore { 34 34 35 class ReadableStreamSource; 36 35 37 class ReadableStream final : public DOMGuarded<JSReadableStream> { 36 38 public: 37 39 static Ref<ReadableStream> create(JSDOMGlobalObject& globalObject, JSReadableStream& readableStream) { return adoptRef(*new ReadableStream(globalObject, readableStream)); } 40 41 static Ref<ReadableStream> create(JSC::ExecState&, RefPtr<ReadableStreamSource>&&); 38 42 39 43 JSReadableStream* readableStream() { return guarded(); } … … 65 69 }; 66 70 71 template<> struct JSConverter<IDLInterface<ReadableStream>> { 72 static constexpr bool needsState = false; 73 static constexpr bool needsGlobalObject = false; 74 75 static JSC::JSValue convert(ReadableStream* value) 76 { 77 if (!value) 78 return JSC::jsNull(); 79 return value->readableStream(); 80 } 81 }; 82 67 83 }
Note:
See TracChangeset
for help on using the changeset viewer.