Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add support for FetchRequest.body
https://bugs.webkit.org/show_bug.cgi?id=176066 Patch by Youenn Fablet <youenn@apple.com> on 2017-08-29 Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/fetch/api/request/request-disturbed-expected.txt: * web-platform-tests/fetch/api/request/request-idl-expected.txt: Source/WebCore: Covered by existing tests. Adding support for body attribute getter for FetchRequest. To do so, FetchRequest will need to create a ReadableStream. Adding support for DOM based creation of ReadableStream and conversion to JS values. Small refactoring to make names more consistent. * CMakeLists.txt: * Modules/beacon/NavigatorBeacon.cpp: (WebCore::NavigatorBeacon::sendBeacon): * Modules/cache/Cache.cpp: (WebCore::Cache::put): * Modules/fetch/FetchBody.cpp: (WebCore::FetchBody::extract): * Modules/fetch/FetchBody.h: (WebCore::FetchBody::hasReadableStream const): (WebCore::FetchBody::readableStream): (WebCore::FetchBody::setReadableStream): (WebCore::FetchBody::FetchBody): (WebCore::FetchBody::isReadableStream const): Deleted. (WebCore::FetchBody::setAsReadableStream): Deleted. * Modules/fetch/FetchBody.idl: * Modules/fetch/FetchBodyOwner.cpp: (WebCore::FetchBodyOwner::readableStream): * Modules/fetch/FetchBodyOwner.h: (WebCore::FetchBodyOwner::hasReadableStreamBody const): (WebCore::FetchBodyOwner::isReadableStreamBody const): Deleted. * Modules/fetch/FetchRequest.cpp: (WebCore::FetchRequest::setBody): * Modules/fetch/FetchRequest.h: * Modules/fetch/FetchResponse.cpp: (WebCore::FetchResponse::setBodyAsReadableStream): (WebCore::FetchResponse::fetch): * Modules/fetch/FetchResponse.h: * WebCore.xcodeproj/project.pbxproj: * bindings/js/ReadableStream.h: (WebCore::JSConverter<IDLInterface<ReadableStream>>::convert): Canonical link: https://commits.webkit.org/192756@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221329 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
e255308
commit 67cb061
Showing
19 changed files
with
171 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-disturbed-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2017 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY CANON INC. ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CANON INC. OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "ReadableStream.h" | ||
|
||
#include "JSReadableStreamSource.h" | ||
#include "WebCoreJSClientData.h" | ||
|
||
using namespace JSC; | ||
|
||
namespace WebCore { | ||
|
||
Ref<ReadableStream> ReadableStream::create(JSC::ExecState& execState, RefPtr<ReadableStreamSource>&& source) | ||
{ | ||
VM& vm = execState.vm(); | ||
auto& clientData = *static_cast<JSVMClientData*>(vm.clientData); | ||
auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(execState.lexicalGlobalObject()); | ||
|
||
auto* constructor = JSC::asObject(globalObject.get(&execState, clientData.builtinNames().ReadableStreamPrivateName())); | ||
|
||
ConstructData constructData; | ||
ConstructType constructType = constructor->methodTable(vm)->getConstructData(constructor, constructData); | ||
ASSERT(constructType != ConstructType::None); | ||
|
||
MarkedArgumentBuffer args; | ||
args.append(source ? toJSNewlyCreated(&execState, &globalObject, source.releaseNonNull()) : JSC::jsUndefined()); | ||
|
||
auto newReadableStream = jsDynamicDowncast<JSReadableStream*>(vm, JSC::construct(&execState, constructor, constructType, constructData, args)); | ||
|
||
return create(globalObject, *newReadableStream); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters