Changeset 205251 in webkit
- Timestamp:
- Aug 31, 2016 9:36:57 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r205250 r205251 1 2016-08-31 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Response bodyUsed should check for its body disturbed state 4 https://bugs.webkit.org/show_bug.cgi?id=161429 5 6 Reviewed by Alex Christensen. 7 8 * http/tests/fetch/bodyUsed-expected.txt: Added. 9 * http/tests/fetch/bodyUsed-worker-expected.txt: Added. 10 * http/tests/fetch/bodyUsed-worker.html: Added. 11 * http/tests/fetch/bodyUsed.js: Added. 12 * http/tests/fetch/window/body-mixin-expected.txt: 13 1 14 2016-08-31 Youenn Fablet <youenn@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r205250 r205251 1 2016-08-31 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Response bodyUsed should check for its body disturbed state 4 https://bugs.webkit.org/show_bug.cgi?id=161429 5 6 Reviewed by Alex Christensen. 7 8 Test: http/tests/fetch/bodyUsed-worker.html 9 10 Implementing bodyUsed as a JS Builtin. 11 This allows using directly @isReadableStreamDisturbed if response has a body. 12 13 Renaming isDisturbed to isDisturbedOrLocked to better match fetch spec terminology. 14 15 * Modules/fetch/FetchBodyOwner.cpp: 16 (WebCore::FetchBodyOwner::isDisturbedOrLocked): Renaming isDisturbed to isDisturbedOrLocked. 17 (WebCore::FetchBodyOwner::arrayBuffer): Ditto. 18 (WebCore::FetchBodyOwner::blob): Ditto. 19 (WebCore::FetchBodyOwner::formData): Ditto. 20 (WebCore::FetchBodyOwner::json): Ditto. 21 (WebCore::FetchBodyOwner::text): Ditto. 22 (WebCore::FetchBodyOwner::isDisturbed): Ditto. 23 * Modules/fetch/FetchBodyOwner.h: 24 (WebCore::FetchBodyOwner::isDisturbed): Ditto. 25 * Modules/fetch/FetchRequest.cpp: 26 (WebCore::FetchRequest::initializeWith): Ditto. 27 (WebCore::FetchRequest::clone): Ditto. 28 * Modules/fetch/FetchResponse.cpp: 29 (WebCore::FetchResponse::cloneForJS): Ditto. 30 (WebCore::FetchResponse::createReadableStreamSource): Only asserting for isDisturbed. 31 * Modules/fetch/FetchResponse.idl: Marking bodyUsed as JS builtin. 32 * Modules/fetch/FetchResponse.js: Adding bodyUsed. 33 (bodyUsed): 34 (clone): 35 1 36 2016-08-31 Youenn Fablet <youenn@apple.com> 2 37 -
trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp
r205250 r205251 59 59 } 60 60 61 bool FetchBodyOwner::isDisturbed () const61 bool FetchBodyOwner::isDisturbedOrLocked() const 62 62 { 63 63 if (m_isDisturbed) … … 78 78 return; 79 79 } 80 if (isDisturbed ()) {80 if (isDisturbedOrLocked()) { 81 81 promise.reject(TypeError); 82 82 return; … … 92 92 return; 93 93 } 94 if (isDisturbed ()) {94 if (isDisturbedOrLocked()) { 95 95 promise.reject(TypeError); 96 96 return; … … 106 106 return; 107 107 } 108 if (isDisturbed ()) {108 if (isDisturbedOrLocked()) { 109 109 promise.reject(TypeError); 110 110 return; … … 120 120 return; 121 121 } 122 if (isDisturbed ()) {122 if (isDisturbedOrLocked()) { 123 123 promise.reject(TypeError); 124 124 return; … … 134 134 return; 135 135 } 136 if (isDisturbed ()) {136 if (isDisturbedOrLocked()) { 137 137 promise.reject(TypeError); 138 138 return; -
trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h
r204225 r205251 45 45 46 46 // Exposed Body API 47 bool isDisturbed() const ;47 bool isDisturbed() const { return m_isDisturbed; }; 48 48 49 49 void arrayBuffer(DeferredWrapper&&); … … 52 52 void json(DeferredWrapper&&); 53 53 void text(DeferredWrapper&&); 54 55 bool isDisturbedOrLocked() const; 54 56 55 57 void loadBlob(Blob&, FetchBodyConsumer*); -
trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp
r205115 r205251 244 244 FetchHeaders* FetchRequest::initializeWith(FetchRequest& input, const Dictionary& init, ExceptionCode& ec) 245 245 { 246 if (input.isDisturbed ()) {246 if (input.isDisturbedOrLocked()) { 247 247 ec = TypeError; 248 248 return nullptr; … … 309 309 RefPtr<FetchRequest> FetchRequest::clone(ScriptExecutionContext& context, ExceptionCode& ec) 310 310 { 311 if (isDisturbed ()) {311 if (isDisturbedOrLocked()) { 312 312 ec = TypeError; 313 313 return nullptr; -
trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp
r205115 r205251 98 98 { 99 99 ASSERT(scriptExecutionContext()); 100 ASSERT(!isDisturbed ());100 ASSERT(!isDisturbedOrLocked()); 101 101 return adoptRef(*new FetchResponse(*scriptExecutionContext(), FetchBody(m_body), FetchHeaders::create(headers()), ResourceResponse(m_response))); 102 102 } … … 271 271 { 272 272 ASSERT(!m_readableStreamSource); 273 ASSERT(! isDisturbed());273 ASSERT(!m_isDisturbed); 274 274 275 275 if (body().isEmpty()) -
trunk/Source/WebCore/Modules/fetch/FetchResponse.idl
r205110 r205251 55 55 56 56 // Copy of FetchBody IDL as we want to implement some of these as built-ins. 57 [ ImplementedAs=isDisturbed] readonly attribute boolean bodyUsed;57 [JSBuiltin] readonly attribute boolean bodyUsed; 58 58 [JSBuiltin] Promise arrayBuffer(); 59 59 [JSBuiltin] Promise blob(); -
trunk/Source/WebCore/Modules/fetch/FetchResponse.js
r205117 r205251 61 61 } 62 62 63 function bodyUsed() 64 { 65 if (!(this instanceof @Response)) 66 throw @makeGetterTypeError("Response", "bodyUsed"); 67 68 if (this.@body) 69 return @isReadableStreamDisturbed(this.@body); 70 71 return @Response.prototype.@isDisturbed.@call(this); 72 } 73 63 74 function body() 64 75 { … … 84 95 throw @makeThisTypeError("Response", "clone"); 85 96 86 if (@Response.prototype.@isDisturbed.@call(this) )97 if (@Response.prototype.@isDisturbed.@call(this) || (this.@body && @isReadableStreamLocked(this.@body))) 87 98 throw new @TypeError("Cannot clone a disturbed Response"); 88 99
Note: See TracChangeset
for help on using the changeset viewer.