Skip to content

Commit

Permalink
[Fetch API] Allow used body replacement in Request constructor
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=183703
<rdar://problem/49425609>

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebaseline WPT test now that one more check is passing.

* web-platform-tests/fetch/api/request/request-disturbed-expected.txt:

Source/WebCore:

Allow used body replacement in Request constructor as per:
- whatwg/fetch#675

No new tests, rebaseline existing test.

* Modules/fetch/FetchRequest.cpp:
(WebCore::FetchRequest::initializeWith):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@243757 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez@apple.com committed Apr 2, 2019
1 parent 1702b14 commit 30cd8e0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
12 changes: 12 additions & 0 deletions LayoutTests/imported/w3c/ChangeLog
@@ -1,3 +1,15 @@
2019-04-02 Chris Dumez <cdumez@apple.com>

[Fetch API] Allow used body replacement in Request constructor
https://bugs.webkit.org/show_bug.cgi?id=183703
<rdar://problem/49425609>

Reviewed by Youenn Fablet.

Rebaseline WPT test now that one more check is passing.

* web-platform-tests/fetch/api/request/request-disturbed-expected.txt:

2019-04-02 Chris Dumez <cdumez@apple.com>

Unreviewed, rolling out r243551.
Expand Down
Expand Up @@ -3,7 +3,7 @@ PASS Request's body: initial state
PASS Request without body cannot be disturbed
PASS Check cloning a disturbed request
PASS Check creating a new request from a disturbed request
FAIL Check creating a new request with a new body from a disturbed request Request input is disturbed or locked.
PASS Check creating a new request with a new body from a disturbed request
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]"
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
PASS Check consuming a disturbed request
Expand Down
16 changes: 16 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,19 @@
2019-04-02 Chris Dumez <cdumez@apple.com>

[Fetch API] Allow used body replacement in Request constructor
https://bugs.webkit.org/show_bug.cgi?id=183703
<rdar://problem/49425609>

Reviewed by Youenn Fablet.

Allow used body replacement in Request constructor as per:
- https://github.com/whatwg/fetch/pull/675

No new tests, rebaseline existing test.

* Modules/fetch/FetchRequest.cpp:
(WebCore::FetchRequest::initializeWith):

2019-04-02 Chris Dumez <cdumez@apple.com>

Unreviewed, rolling out r243551.
Expand Down
6 changes: 3 additions & 3 deletions Source/WebCore/Modules/fetch/FetchRequest.cpp
Expand Up @@ -203,9 +203,6 @@ ExceptionOr<void> FetchRequest::initializeWith(const String& url, Init&& init)

ExceptionOr<void> FetchRequest::initializeWith(FetchRequest& input, Init&& init)
{
if (input.isDisturbedOrLocked())
return Exception {TypeError, "Request input is disturbed or locked."_s };

m_request = input.m_request;
m_options = input.m_options;
m_referrer = input.m_referrer;
Expand Down Expand Up @@ -240,6 +237,9 @@ ExceptionOr<void> FetchRequest::initializeWith(FetchRequest& input, Init&& init)
if (setBodyResult.hasException())
return setBodyResult.releaseException();
} else {
if (input.isDisturbedOrLocked())
return Exception { TypeError, "Request input is disturbed or locked."_s };

auto setBodyResult = setBody(input);
if (setBodyResult.hasException())
return setBodyResult.releaseException();
Expand Down

0 comments on commit 30cd8e0

Please sign in to comment.