Title: [218677] trunk
Revision
218677
Author
[email protected]
Date
2017-06-21 21:31:12 -0700 (Wed, 21 Jun 2017)

Log Message

[Fetch API] TypeError when called with body === {}
https://bugs.webkit.org/show_bug.cgi?id=173295
<rdar://problem/32746733>

Patch by Youenn Fablet <[email protected]> on 2017-06-21
Reviewed by Sam Weinig.

Source/WebCore:

Test: fetch/body-init.html

Handling body of Request and Response using binding generator to correctly handle unions.
The biggest change is that any value that is not a specific type in the union will match a String.
This is matching WebIDL spec and Firefox behavior.

Handling of ReadableStream bodies remains in JS builtin for Response.
This allows easier handling cloning and consumption of body.
Adding setBodyAsReadableStream since this is no longer handled by extractBody.

* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::extract): Using Variant instead of JSC::JSValue.
(WebCore::FetchBody::readableStreamBody): Introduced to handle the
case of readable stream bodies.
* Modules/fetch/FetchBody.h:
* Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::extractBody):
* Modules/fetch/FetchBodyOwner.h:
(WebCore::FetchBodyOwner::setBody):
* Modules/fetch/FetchRequest.cpp:
(WebCore::FetchRequest::setBody): Splitting setBody for ease of readability.
(WebCore::FetchRequest::setBodyFromInputRequest):
* Modules/fetch/FetchRequest.h:
* Modules/fetch/FetchRequest.idl:
* Modules/fetch/FetchRequest.js:
(initializeFetchRequest):
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::initializeWith):
(WebCore::FetchResponse::setBodyAsReadableStream):
* Modules/fetch/FetchResponse.h:
* Modules/fetch/FetchResponse.idl:
* Modules/fetch/FetchResponse.js:
(initializeFetchResponse):
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/WebCoreBuiltinNames.h:

LayoutTests:

* fetch/body-init-expected.txt: Added.
* fetch/body-init.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (218676 => 218677)


--- trunk/LayoutTests/ChangeLog	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/LayoutTests/ChangeLog	2017-06-22 04:31:12 UTC (rev 218677)
@@ -1,3 +1,14 @@
+2017-06-21  Youenn Fablet  <[email protected]>
+
+        [Fetch API] TypeError when called with body === {}
+        https://bugs.webkit.org/show_bug.cgi?id=173295
+        <rdar://problem/32746733>
+
+        Reviewed by Sam Weinig.
+
+        * fetch/body-init-expected.txt: Added.
+        * fetch/body-init.html: Added.
+
 2017-06-21  Antoine Quint  <[email protected]>
 
         CSS text properties affect <video> shadow root

Added: trunk/LayoutTests/fetch/body-init-expected.txt (0 => 218677)


--- trunk/LayoutTests/fetch/body-init-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fetch/body-init-expected.txt	2017-06-22 04:31:12 UTC (rev 218677)
@@ -0,0 +1,6 @@
+
+PASS Testing integer body passed to response 
+PASS Testing object body passed to response 
+PASS Testing integer body passed to request 
+PASS Testing object body passed to request 
+

Added: trunk/LayoutTests/fetch/body-init.html (0 => 218677)


--- trunk/LayoutTests/fetch/body-init.html	                        (rev 0)
+++ trunk/LayoutTests/fetch/body-init.html	2017-06-22 04:31:12 UTC (rev 218677)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<script src=''></script>
+<script src=''></script>
+<script>
+
+promise_test(() => {
+    return new Response(1).text().then((text) => {
+        assert_equals(text, "1");
+    });
+}, "Testing integer body passed to response");
+
+promise_test(() => {
+    return new Response({}).text().then((text) => {
+        assert_equals(text, "[object Object]");
+    });
+}, "Testing object body passed to response");
+
+promise_test(() => {
+    return new Request("", {method: "POST", body: 1}).text().then((text) => {
+        assert_equals(text, "1");
+    });
+}, "Testing integer body passed to request");
+
+promise_test(() => {
+    return new Request("", {method: "POST", body: {}}).text().then((text) => {
+        assert_equals(text, "[object Object]");
+    });
+}, "Testing object body passed to request");
+
+</script>

Modified: trunk/Source/WebCore/ChangeLog (218676 => 218677)


--- trunk/Source/WebCore/ChangeLog	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/ChangeLog	2017-06-22 04:31:12 UTC (rev 218677)
@@ -1,3 +1,47 @@
+2017-06-21  Youenn Fablet  <[email protected]>
+
+        [Fetch API] TypeError when called with body === {}
+        https://bugs.webkit.org/show_bug.cgi?id=173295
+        <rdar://problem/32746733>
+
+        Reviewed by Sam Weinig.
+
+        Test: fetch/body-init.html
+
+        Handling body of Request and Response using binding generator to correctly handle unions.
+        The biggest change is that any value that is not a specific type in the union will match a String.
+        This is matching WebIDL spec and Firefox behavior.
+
+        Handling of ReadableStream bodies remains in JS builtin for Response.
+        This allows easier handling cloning and consumption of body.
+        Adding setBodyAsReadableStream since this is no longer handled by extractBody.
+
+        * Modules/fetch/FetchBody.cpp:
+        (WebCore::FetchBody::extract): Using Variant instead of JSC::JSValue.
+        (WebCore::FetchBody::readableStreamBody): Introduced to handle the
+        case of readable stream bodies.
+        * Modules/fetch/FetchBody.h:
+        * Modules/fetch/FetchBodyOwner.cpp:
+        (WebCore::FetchBodyOwner::extractBody):
+        * Modules/fetch/FetchBodyOwner.h:
+        (WebCore::FetchBodyOwner::setBody):
+        * Modules/fetch/FetchRequest.cpp:
+        (WebCore::FetchRequest::setBody): Splitting setBody for ease of readability.
+        (WebCore::FetchRequest::setBodyFromInputRequest):
+        * Modules/fetch/FetchRequest.h:
+        * Modules/fetch/FetchRequest.idl:
+        * Modules/fetch/FetchRequest.js:
+        (initializeFetchRequest):
+        * Modules/fetch/FetchResponse.cpp:
+        (WebCore::FetchResponse::initializeWith):
+        (WebCore::FetchResponse::setBodyAsReadableStream):
+        * Modules/fetch/FetchResponse.h:
+        * Modules/fetch/FetchResponse.idl:
+        * Modules/fetch/FetchResponse.js:
+        (initializeFetchResponse):
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/WebCoreBuiltinNames.h:
+
 2017-06-21  Simon Fraser  <[email protected]>
 
         Add z-index to compositing logging output

Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (218676 => 218677)


--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2017-06-22 04:31:12 UTC (rev 218677)
@@ -37,54 +37,52 @@
 #include "FetchResponseSource.h"
 #include "HTTPHeaderValues.h"
 #include "HTTPParsers.h"
-#include "JSBlob.h"
-#include "JSDOMFormData.h"
-#include "JSReadableStream.h"
-#include "JSURLSearchParams.h"
 #include "ReadableStreamSource.h"
 #include <runtime/ArrayBufferView.h>
 
 namespace WebCore {
 
-std::optional<FetchBody> FetchBody::extract(ScriptExecutionContext& context, JSC::ExecState& state, JSC::JSValue value, String& contentType)
+FetchBody FetchBody::extract(ScriptExecutionContext& context, BindingDataType&& value, String& contentType)
 {
-    JSC::VM& vm = state.vm();
-    if (value.inherits(vm, JSBlob::info())) {
-        auto& blob = *JSBlob::toWrapped(vm, value);
-        contentType = blob.type();
-        return FetchBody(blob);
+    if (WTF::holds_alternative<RefPtr<Blob>>(value)) {
+        Ref<const Blob> blob = WTF::get<RefPtr<Blob>>(value).releaseNonNull();
+        contentType = blob->type();
+        return FetchBody(WTFMove(blob));
     }
-    if (value.inherits(vm, JSDOMFormData::info())) {
-        ASSERT(!context.isWorkerGlobalScope());
-        auto& domFormData = *JSDOMFormData::toWrapped(vm, value);
-        auto formData = FormData::createMultiPart(domFormData, domFormData.encoding(), &static_cast<Document&>(context));
+    if (WTF::holds_alternative<RefPtr<DOMFormData>>(value)) {
+        Ref<DOMFormData> domFormData = WTF::get<RefPtr<DOMFormData>>(value).releaseNonNull();
+        auto formData = FormData::createMultiPart(domFormData.get(), domFormData->encoding(), &static_cast<Document&>(context));
         contentType = makeString("multipart/form-data; boundary=", formData->boundary().data());
         return FetchBody(WTFMove(formData));
     }
-    if (value.isString()) {
-        contentType = HTTPHeaderValues::textPlainContentType();
-        return FetchBody(String { asString(value)->value(&state) });
-    }
-    if (value.inherits(vm, JSURLSearchParams::info())) {
+
+    if (WTF::holds_alternative<RefPtr<URLSearchParams>>(value)) {
+        Ref<const URLSearchParams> params = WTF::get<RefPtr<URLSearchParams>>(value).releaseNonNull();
         contentType = HTTPHeaderValues::formURLEncodedContentType();
-        return FetchBody(*JSURLSearchParams::toWrapped(vm, value));
+        return FetchBody(WTFMove(params));
     }
-    if (value.inherits(vm, JSReadableStream::info())) {
-        FetchBody body;
-        body.m_isReadableStream = true;
-        return WTFMove(body);
+
+    if (WTF::holds_alternative<RefPtr<ArrayBuffer>>(value)) {
+        Ref<const ArrayBuffer> buffer = WTF::get<RefPtr<ArrayBuffer>>(value).releaseNonNull();
+        return FetchBody(WTFMove(buffer));
     }
-    if (value.inherits(vm, JSC::JSArrayBuffer::info())) {
-        ArrayBuffer* data = "" value);
-        ASSERT(data);
-        return FetchBody(*data);
+    if (WTF::holds_alternative<RefPtr<ArrayBufferView>>(value)) {
+        Ref<const ArrayBufferView> buffer = WTF::get<RefPtr<ArrayBufferView>>(value).releaseNonNull();
+        return FetchBody(WTFMove(buffer));
     }
-    if (value.inherits(vm, JSC::JSArrayBufferView::info()))
-        return FetchBody(toUnsharedArrayBufferView(vm, value).releaseConstNonNull());
 
-    return std::nullopt;
+    ASSERT(WTF::holds_alternative<String>(value));
+    contentType = HTTPHeaderValues::textPlainContentType();
+    return FetchBody(WTFMove(WTF::get<String>(value)));
 }
 
+FetchBody FetchBody::readableStreamBody()
+{
+    FetchBody body;
+    body.m_isReadableStream = true;
+    return body;
+}
+
 void FetchBody::arrayBuffer(FetchBodyOwner& owner, Ref<DeferredPromise>&& promise)
 {
     m_consumer.setType(FetchBodyConsumer::Type::ArrayBuffer);

Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.h (218676 => 218677)


--- trunk/Source/WebCore/Modules/fetch/FetchBody.h	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.h	2017-06-22 04:31:12 UTC (rev 218677)
@@ -31,6 +31,7 @@
 #if ENABLE(FETCH_API)
 
 #include "Blob.h"
+#include "DOMFormData.h"
 #include "FetchBodyConsumer.h"
 #include "FetchLoader.h"
 #include "FormData.h"
@@ -39,11 +40,6 @@
 #include <wtf/Optional.h>
 #include <wtf/Variant.h>
 
-namespace JSC {
-class ExecState;
-class JSValue;
-};
-
 namespace WebCore {
 
 class FetchBodyOwner;
@@ -70,8 +66,10 @@
     bool isText() const { return WTF::holds_alternative<String>(m_data); }
     bool isReadableStream() const { return m_isReadableStream; }
 
-    static std::optional<FetchBody> extract(ScriptExecutionContext&, JSC::ExecState&, JSC::JSValue, String&);
+    using BindingDataType = Variant<RefPtr<Blob>, RefPtr<ArrayBufferView>, RefPtr<ArrayBuffer>, RefPtr<DOMFormData>, RefPtr<URLSearchParams>, String>;
+    static FetchBody extract(ScriptExecutionContext&, BindingDataType&&, String&);
     static FetchBody loadingBody() { return { }; }
+    static FetchBody readableStreamBody();
 
     void loadingFailed();
     void loadingSucceeded();
@@ -111,7 +109,8 @@
     const String& textBody() const { return WTF::get<String>(m_data); }
     const URLSearchParams& urlSearchParamsBody() const { return WTF::get<Ref<const URLSearchParams>>(m_data).get(); }
 
-    Variant<std::nullptr_t, Ref<const Blob>, Ref<FormData>, Ref<const ArrayBuffer>, Ref<const ArrayBufferView>, Ref<const URLSearchParams>, String> m_data { nullptr };
+    using Data = "" Ref<const Blob>, Ref<FormData>, Ref<const ArrayBuffer>, Ref<const ArrayBufferView>, Ref<const URLSearchParams>, String>;
+    Data m_data { nullptr };
 
     FetchBodyConsumer m_consumer { FetchBodyConsumer::Type::None };
     RefPtr<DeferredPromise> m_consumePromise;

Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp (218676 => 218677)


--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp	2017-06-22 04:31:12 UTC (rev 218677)
@@ -109,9 +109,9 @@
     m_body = owner.m_body->clone();
 }
 
-void FetchBodyOwner::extractBody(ScriptExecutionContext& context, JSC::ExecState& state, JSC::JSValue value)
+void FetchBodyOwner::extractBody(ScriptExecutionContext& context, FetchBody::BindingDataType&& value)
 {
-    m_body = FetchBody::extract(context, state, value, m_contentType);
+    m_body = FetchBody::extract(context, WTFMove(value), m_contentType);
 }
 
 void FetchBodyOwner::updateContentType()

Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h (218676 => 218677)


--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h	2017-06-22 04:31:12 UTC (rev 218677)
@@ -65,10 +65,12 @@
     bool isBodyNull() const { return !m_body; }
     void cloneBody(const FetchBodyOwner&);
 
-    void extractBody(ScriptExecutionContext&, JSC::ExecState&, JSC::JSValue);
+    void extractBody(ScriptExecutionContext&, FetchBody::BindingDataType&&);
     void updateContentType();
     void consumeOnceLoadingFinished(FetchBodyConsumer::Type, Ref<DeferredPromise>&&);
 
+    void setBody(FetchBody&& body) { m_body = WTFMove(body); }
+
     // ActiveDOMObject API
     void stop() override;
 

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp (218676 => 218677)


--- trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp	2017-06-22 04:31:12 UTC (rev 218677)
@@ -167,18 +167,22 @@
     return initializeOptions(init);
 }
 
-ExceptionOr<void> FetchRequest::setBody(JSC::ExecState& execState, JSC::JSValue body, FetchRequest* request)
+ExceptionOr<void> FetchRequest::setBody(FetchBody::BindingDataType&& body)
 {
-    if (!body.isNull()) {
+    if (!methodCanHaveBody(m_internalRequest))
+        return Exception { TypeError };
+
+    ASSERT(scriptExecutionContext());
+    extractBody(*scriptExecutionContext(), WTFMove(body));
+    updateContentType();
+    return { };
+}
+
+ExceptionOr<void> FetchRequest::setBodyFromInputRequest(FetchRequest* request)
+{
+    if (request && !request->isBodyNull()) {
         if (!methodCanHaveBody(m_internalRequest))
             return Exception { TypeError };
-        ASSERT(scriptExecutionContext());
-        extractBody(*scriptExecutionContext(), execState, body);
-        if (isBodyNull())
-            return Exception { TypeError };
-    } else if (request && !request->isBodyNull()) {
-        if (!methodCanHaveBody(m_internalRequest))
-            return Exception { TypeError };
         m_body = WTFMove(request->m_body);
         request->setDisturbed();
     }

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.h (218676 => 218677)


--- trunk/Source/WebCore/Modules/fetch/FetchRequest.h	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.h	2017-06-22 04:31:12 UTC (rev 218677)
@@ -68,7 +68,8 @@
 
     ExceptionOr<FetchHeaders&> initializeWith(FetchRequest&, const Init&);
     ExceptionOr<FetchHeaders&> initializeWith(const String&, const Init&);
-    ExceptionOr<void> setBody(JSC::ExecState&, JSC::JSValue, FetchRequest*);
+    ExceptionOr<void> setBody(FetchBody::BindingDataType&&);
+    ExceptionOr<void> setBodyFromInputRequest(FetchRequest*);
 
     const String& method() const { return m_internalRequest.request.httpMethod(); }
     const String& url() const;

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.idl (218676 => 218677)


--- trunk/Source/WebCore/Modules/fetch/FetchRequest.idl	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.idl	2017-06-22 04:31:12 UTC (rev 218677)
@@ -34,6 +34,9 @@
 enum RequestRedirect { "follow", "error", "manual" };
 enum ReferrerPolicy { "", "no-referrer",  "no-referrer-when-downgrade", "origin", "origin-when-cross-origin", "unsafe-url" };
 
+typedef (ArrayBufferView or ArrayBuffer) BufferSource;
+typedef (Blob or BufferSource or DOMFormData or URLSearchParams or USVString) BodyInit;
+
 dictionary RequestInit {
     ByteString method;
     // FIXME: Should add: HeadersInit headers;
@@ -78,7 +81,8 @@
 
     [MayThrowException, NewObject, PrivateIdentifier] FetchHeaders initializeWith(FetchRequest input, RequestInit init);
     [MayThrowException, NewObject, PrivateIdentifier] FetchHeaders initializeWith(DOMString input, RequestInit init);
-    [CallWith=ScriptState, MayThrowException, PrivateIdentifier] void setBody(any body, FetchRequest? request);
+    [MayThrowException, PrivateIdentifier] void setBody(BodyInit body);
+    [MayThrowException, PrivateIdentifier] void setBodyFromInputRequest(FetchRequest? request);
 };
 
 FetchRequest implements FetchBody;

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.js (218676 => 218677)


--- trunk/Source/WebCore/Modules/fetch/FetchRequest.js	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.js	2017-06-22 04:31:12 UTC (rev 218677)
@@ -34,17 +34,20 @@
     else if (!@isObject(init))
         @throwTypeError("Request init must be an object");
 
-    let headers = this.@initializeWith(input, init);
+    const headers = this.@initializeWith(input, init);
     @assert(headers instanceof @Headers);
 
-    let inputIsRequest = input instanceof @Request;
+    const inputIsRequest = input instanceof @Request;
     if ("headers" in init)
         @fillFetchHeaders(headers, init.headers)
     else if (inputIsRequest)
         @fillFetchHeaders(headers, input.headers)
 
-    let hasInitBody = init.body !== @undefined && init.body !== null;
-    this.@setBody(hasInitBody ? init.body : null, inputIsRequest ? input : null);
+    const hasInitBody = init.body !== @undefined && init.body !== null;
+    if (hasInitBody)
+        this.@setBody(init.body)
+    else
+        this.@setBodyFromInputRequest(inputIsRequest ? input : null);
 
     return this;
 }

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (218676 => 218677)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp	2017-06-22 04:31:12 UTC (rev 218677)
@@ -75,13 +75,20 @@
     return { };
 }
 
-void FetchResponse::initializeWith(JSC::ExecState& execState, JSC::JSValue body)
+void FetchResponse::initializeWith(FetchBody::BindingDataType&& body)
 {
     ASSERT(scriptExecutionContext());
-    extractBody(*scriptExecutionContext(), execState, body);
+    extractBody(*scriptExecutionContext(), WTFMove(body));
     updateContentType();
 }
 
+void FetchResponse::setBodyAsReadableStream()
+{
+    ASSERT(isBodyNull());
+    setBody(FetchBody::readableStreamBody());
+    updateContentType();
+}
+
 FetchResponse::FetchResponse(ScriptExecutionContext& context, std::optional<FetchBody>&& body, Ref<FetchHeaders>&& headers, ResourceResponse&& response)
     : FetchBodyOwner(context, WTFMove(body), WTFMove(headers))
     , m_response(WTFMove(response))

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.h (218676 => 218677)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.h	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.h	2017-06-22 04:31:12 UTC (rev 218677)
@@ -63,7 +63,8 @@
 #endif
 
     ExceptionOr<void> setStatus(int status, const String& statusText);
-    void initializeWith(JSC::ExecState&, JSC::JSValue);
+    void initializeWith(FetchBody::BindingDataType&&);
+    void setBodyAsReadableStream();
 
     Type type() const { return m_response.type(); }
     const String& url() const;

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.idl (218676 => 218677)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.idl	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.idl	2017-06-22 04:31:12 UTC (rev 218677)
@@ -28,6 +28,9 @@
 
 enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredirect" };
 
+typedef (ArrayBufferView or ArrayBuffer) BufferSource;
+typedef (Blob or BufferSource or DOMFormData or URLSearchParams or USVString) BodyInit;
+
 [
     ActiveDOMObject,
     Conditional=FETCH_API,
@@ -71,7 +74,8 @@
     [PrivateIdentifier] Promise<any> consume(unsigned short type);
     [PrivateIdentifier] boolean isLoading();
     [MayThrowException, PrivateIdentifier] void setStatus(unsigned short status, DOMString statusText);
-    [CallWith=ScriptState, PrivateIdentifier] void initializeWith(any body);
+    [PrivateIdentifier] void initializeWith(BodyInit body);
     [NewObject, PrivateIdentifier] ReadableStreamSource createReadableStreamSource();
     [PrivateIdentifier] boolean isDisturbed();
+    [PrivateIdentifier] void setBodyAsReadableStream();
 };

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.js (218676 => 218677)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.js	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.js	2017-06-22 04:31:12 UTC (rev 218677)
@@ -51,10 +51,11 @@
 
         // FIXME: Use @isReadableStream once it is no longer guarded by STREAMS_API compilation guard.
         let isBodyReadableStream = (@isObject(body) && !!body.@readableStreamController);
-        if (isBodyReadableStream)
-          this.@body = body;
-
-        this.@initializeWith(body);
+        if (isBodyReadableStream) {
+            this.@body = body;
+            this.@setBodyAsReadableStream();
+        } else
+            this.@initializeWith(body);
     }
 
     return this;

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (218676 => 218677)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-06-22 04:31:12 UTC (rev 218677)
@@ -1701,6 +1701,9 @@
 		41103AAE1E39791000769F03 /* RealtimeIncomingAudioSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41103AAA1E39790A00769F03 /* RealtimeIncomingAudioSource.cpp */; };
 		4123081B138C429700BCCFCA /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F19B1A08245E5A001E9ABC /* WebCore.framework */; };
 		41230913138C42FF00BCCFCA /* _javascript_Core.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8216299029F4FB501000131 /* _javascript_Core.framework */; };
+		412455341EF442C500F11809 /* FetchRequest.js in Resources */ = {isa = PBXBuildFile; fileRef = 412455331EF442C400F11809 /* FetchRequest.js */; };
+		412455361EF442D000F11809 /* DOMWindowFetch.js in Resources */ = {isa = PBXBuildFile; fileRef = 412455351EF442CE00F11809 /* DOMWindowFetch.js */; };
+		412455381EF442DB00F11809 /* WorkerGlobalScopeFetch.js in Resources */ = {isa = PBXBuildFile; fileRef = 412455371EF442DA00F11809 /* WorkerGlobalScopeFetch.js */; };
 		4127D5370F8AAB1D00E424F5 /* ScriptState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */; };
 		4129DF851BB5B80700322A16 /* JSReadableStreamPrivateConstructors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4129DF831BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.cpp */; };
 		4129DF861BB5B80C00322A16 /* JSReadableStreamPrivateConstructors.h in Headers */ = {isa = PBXBuildFile; fileRef = 4129DF841BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9374,6 +9377,9 @@
 		41189EF71AD8232800B90A0D /* ReadableStreamDefaultController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamDefaultController.idl; sourceTree = "<group>"; };
 		41189EF71AD8232800B93F64 /* ReadableByteStreamController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableByteStreamController.idl; sourceTree = "<group>"; };
 		41189EF71AD8232800B95672 /* ReadableStreamBYOBRequest.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamBYOBRequest.idl; sourceTree = "<group>"; };
+		412455331EF442C400F11809 /* FetchRequest.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = FetchRequest.js; sourceTree = "<group>"; };
+		412455351EF442CE00F11809 /* DOMWindowFetch.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = DOMWindowFetch.js; sourceTree = "<group>"; };
+		412455371EF442DA00F11809 /* WorkerGlobalScopeFetch.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = WorkerGlobalScopeFetch.js; sourceTree = "<group>"; };
 		4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptState.cpp; sourceTree = "<group>"; };
 		4129DF831BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamPrivateConstructors.cpp; sourceTree = "<group>"; };
 		4129DF841BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamPrivateConstructors.h; sourceTree = "<group>"; };
@@ -17886,6 +17892,7 @@
 				418C39521C8DAC7B0051C8A3 /* DOMWindowFetch.cpp */,
 				418C39531C8DAC7B0051C8A3 /* DOMWindowFetch.h */,
 				418C39541C8DAC7B0051C8A3 /* DOMWindowFetch.idl */,
+				412455351EF442CE00F11809 /* DOMWindowFetch.js */,
 				41F54F7D1C50C4F600338488 /* FetchBody.cpp */,
 				41F54F7E1C50C4F600338488 /* FetchBody.h */,
 				41F54F7F1C50C4F600338488 /* FetchBody.idl */,
@@ -17904,6 +17911,7 @@
 				41F54F871C50C4F600338488 /* FetchRequest.cpp */,
 				41F54F881C50C4F600338488 /* FetchRequest.h */,
 				41F54F891C50C4F600338488 /* FetchRequest.idl */,
+				412455331EF442C400F11809 /* FetchRequest.js */,
 				413015D51C7B570400091C6E /* FetchResponse.cpp */,
 				413015D61C7B570400091C6E /* FetchResponse.h */,
 				413015D71C7B570400091C6E /* FetchResponse.idl */,
@@ -17913,6 +17921,7 @@
 				418C39571C8DD6960051C8A3 /* WorkerGlobalScopeFetch.cpp */,
 				418C39581C8DD6960051C8A3 /* WorkerGlobalScopeFetch.h */,
 				418C39591C8DD6960051C8A3 /* WorkerGlobalScopeFetch.idl */,
+				412455371EF442DA00F11809 /* WorkerGlobalScopeFetch.js */,
 			);
 			path = fetch;
 			sourceTree = "<group>";
@@ -30493,6 +30502,7 @@
 				A1AA9AB91D23911500FEADB3 /* ContentFilterBlockedPage.html in Resources */,
 				A11E8C051B1E28F40003A7C7 /* copyCursor.png in Resources */,
 				D02B64B214089E56006EFA21 /* DictationPhraseWithAlternativesDot.png in Resources */,
+				412455341EF442C500F11809 /* FetchRequest.js in Resources */,
 				D02B64B314089E56006EFA21 /* [email protected] in Resources */,
 				7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */,
 				2D9F0E1314FF1CBF00BA0FF7 /* linearSRGB.icc in Resources */,
@@ -30506,10 +30516,12 @@
 				E4E243831DAB953E00C26E4B /* meterElementShadow.css in Resources */,
 				93153BE214195A5700FCF5BE /* missingImage.png in Resources */,
 				93153BDA14181F7A00FCF5BE /* [email protected] in Resources */,
+				412455381EF442DB00F11809 /* WorkerGlobalScopeFetch.js in Resources */,
 				318891611AB7EEA100EA627B /* [email protected] in Resources */,
 				71A1B6081DEE5AD70073BCFB /* modern-media-controls-localized-strings.js in Resources */,
 				A11E8C061B1E28FA0003A7C7 /* moveCursor.png in Resources */,
 				A11E8C071B1E28FE0003A7C7 /* northEastSouthWestResizeCursor.png in Resources */,
+				412455361EF442D000F11809 /* DOMWindowFetch.js in Resources */,
 				A11E8C081B1E29020003A7C7 /* northSouthResizeCursor.png in Resources */,
 				A11E8C091B1E29070003A7C7 /* northWestSouthEastResizeCursor.png in Resources */,
 				BE8C753110681324001E93F5 /* SpellingDot.png in Resources */,

Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (218676 => 218677)


--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2017-06-22 02:44:13 UTC (rev 218676)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2017-06-22 04:31:12 UTC (rev 218677)
@@ -88,6 +88,8 @@
     macro(retrieveResponse) \
     macro(response) \
     macro(setBody) \
+    macro(setBodyAsReadableStream) \
+    macro(setBodyFromInputRequest) \
     macro(setStatus) \
     macro(state) \
     macro(startConsumingStream) \
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to