WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-156911-20160422164251.patch (text/plain), 7.21 KB, created by
youenn fablet
on 2016-04-22 07:42:29 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2016-04-22 07:42:29 PDT
Size:
7.21 KB
patch
obsolete
>Subversion Revision: 199871 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 10acf4e06310139e4680f6f4b81ed2bf9917aff6..f200a5061c22c99b28ea8f3998cb7f7193a58887 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,21 @@ >+2016-04-22 Youenn Fablet <youenn.fablet@crf.canon.fr> >+ >+ FetchResponse should return a ReadableStream even if disturbed >+ https://bugs.webkit.org/show_bug.cgi?id=156911 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Covered by rebased test. >+ >+ * Modules/fetch/FetchResponse.cpp: >+ (WebCore::FetchResponse::createReadableStreamSource): Asserting in case response is disturbed. >+ * bindings/js/JSFetchResponseCustom.cpp: >+ (WebCore::JSFetchResponse::body): Creating a locked empty readable stream if response is disturbed. >+ * bindings/js/ReadableStreamController.cpp: >+ (WebCore::createReadableStream): Constructing a readable stream even if source is null. >+ (WebCore::getReadableStreamReader): Retrieving the reader from a readable stream. Stream must not be locked. >+ * bindings/js/ReadableStreamController.h: >+ > 2016-04-21 Chris Dumez <cdumez@apple.com> > > Drop [UsePointersEvenForNonNullableObjectArguments] from Document >diff --git a/Source/WebCore/Modules/fetch/FetchResponse.cpp b/Source/WebCore/Modules/fetch/FetchResponse.cpp >index f75553a32bcdddd12282b989c1845ba6fde2fc3e..1ce3d1dfd151a2a35b6d63c9444709d261828399 100644 >--- a/Source/WebCore/Modules/fetch/FetchResponse.cpp >+++ b/Source/WebCore/Modules/fetch/FetchResponse.cpp >@@ -293,7 +293,9 @@ void FetchResponse::consumeBodyAsStream() > ReadableStreamSource* FetchResponse::createReadableStreamSource() > { > ASSERT(!m_readableStreamSource); >- if (body().isEmpty() || isDisturbed()) >+ ASSERT(!FetchBodyOwner::isDisturbed()); >+ >+ if (body().isEmpty()) > return nullptr; > > m_readableStreamSource = adoptRef(*new FetchResponseSource(*this)); >diff --git a/Source/WebCore/bindings/js/JSFetchResponseCustom.cpp b/Source/WebCore/bindings/js/JSFetchResponseCustom.cpp >index cdb06e4e7fae4bb1ce08087eb7a6bb09c4daa3e1..efedd1861ce4aa119ea56381ba4ab4c64d1672d5 100644 >--- a/Source/WebCore/bindings/js/JSFetchResponseCustom.cpp >+++ b/Source/WebCore/bindings/js/JSFetchResponseCustom.cpp >@@ -38,8 +38,18 @@ namespace WebCore { > JSC::JSValue JSFetchResponse::body(JSC::ExecState& state) const > { > #if ENABLE(STREAMS_API) >- if (!m_body) >- m_body.set(state.vm(), this, createReadableStream(state, globalObject(), wrapped().createReadableStreamSource())); >+ if (!m_body) { >+ JSC::JSValue readableStream; >+ if (wrapped().isDisturbed()) { >+ readableStream = createReadableStream(state, globalObject(), nullptr); >+ // Let's get the reader to lock it. >+ getReadableStreamReader(state, readableStream); >+ } else { >+ ReadableStreamSource* source = wrapped().createReadableStreamSource(); >+ readableStream = source ? createReadableStream(state, globalObject(), source) : JSC::jsNull(); >+ } >+ m_body.set(state.vm(), this, readableStream); >+ } > return m_body.get(); > #else > UNUSED_PARAM(state); >diff --git a/Source/WebCore/bindings/js/ReadableStreamController.cpp b/Source/WebCore/bindings/js/ReadableStreamController.cpp >index 577c6471bff8c0e69b46d89395d54a79772cf71f..7afad52dd98f17e1a2c9b8e796e11dc81896285c 100644 >--- a/Source/WebCore/bindings/js/ReadableStreamController.cpp >+++ b/Source/WebCore/bindings/js/ReadableStreamController.cpp >@@ -86,12 +86,9 @@ bool ReadableStreamController::isControlledReadableStreamLocked() const > > JSC::JSValue createReadableStream(JSC::ExecState& state, JSDOMGlobalObject* globalObject, ReadableStreamSource* source) > { >- if (!source) >- return JSC::jsNull(); >- > JSC::JSLockHolder lock(&state); > >- JSC::JSValue jsSource = toJS(&state, globalObject, source); >+ JSC::JSValue jsSource = source ? toJS(&state, globalObject, source) : JSC::jsUndefined(); > JSC::Strong<JSC::Unknown> protect(state.vm(), jsSource); > > JSC::MarkedArgumentBuffer arguments; >@@ -106,6 +103,19 @@ JSC::JSValue createReadableStream(JSC::ExecState& state, JSDOMGlobalObject* glob > return JSC::construct(&state, constructor, constructType, constructData, arguments); > } > >+JSC::JSValue getReadableStreamReader(JSC::ExecState& state, JSC::JSValue readableStream) >+{ >+ ASSERT(readableStream.isObject()); >+ >+ JSC::JSValue getReader = readableStream.getObject()->get(&state, JSC::Identifier::fromString(&state, "getReader")); >+ ASSERT(!state.hadException()); >+ >+ JSC::JSValue reader = callFunction(state, getReader, readableStream, JSC::MarkedArgumentBuffer()); >+ ASSERT(!state.hadException()); >+ >+ return reader; >+} >+ > } // namespace WebCore > > #endif // ENABLE(STREAMS_API) >diff --git a/Source/WebCore/bindings/js/ReadableStreamController.h b/Source/WebCore/bindings/js/ReadableStreamController.h >index 5bc31e67f918ce280a0eb4476437a9485c5b56b9..ecfe1b03e349f6d2e8f3099eec434b09e7066f77 100644 >--- a/Source/WebCore/bindings/js/ReadableStreamController.h >+++ b/Source/WebCore/bindings/js/ReadableStreamController.h >@@ -67,6 +67,7 @@ private: > }; > > JSC::JSValue createReadableStream(JSC::ExecState&, JSDOMGlobalObject*, ReadableStreamSource*); >+JSC::JSValue getReadableStreamReader(JSC::ExecState&, JSC::JSValue); > > inline JSDOMGlobalObject* ReadableStreamController::globalObject() const > { >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index ff256944d481abe80968c07497eda7790f2fa069..4bf69a74455aee86b6a5ba871ef3685a33e3b544 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,12 @@ >+2016-04-22 Youenn Fablet <youenn.fablet@crf.canon.fr> >+ >+ FetchResponse should return a ReadableStream even if disturbed >+ https://bugs.webkit.org/show_bug.cgi?id=156911 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt: Rebasing test. >+ > 2016-04-21 Chris Dumez <cdumez@apple.com> > > Drop [UsePointersEvenForNonNullableObjectArguments] from Document >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt >index 1302fa415a3a159a83363f7b034bb802b99fab52..e158f7099b0de034b27c3dbb92ab82b9943e192a 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt >@@ -1,6 +1,6 @@ > >-FAIL Getting a body reader after consuming as blob assert_not_equals: got disallowed value null >-FAIL Getting a body reader after consuming as text assert_not_equals: got disallowed value null >-FAIL Getting a body reader after consuming as json assert_not_equals: got disallowed value null >-FAIL Getting a body reader after consuming as arrayBuffer assert_not_equals: got disallowed value null >+PASS Getting a body reader after consuming as blob >+PASS Getting a body reader after consuming as text >+PASS Getting a body reader after consuming as json >+PASS Getting a body reader after consuming as arrayBuffer >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 156911
:
277060
|
277677