Changeset 204225 in webkit
- Timestamp:
- Aug 6, 2016 1:51:01 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r204224 r204225 1 2016-08-06 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Fetching with a FormData body should reject until it is implemented 4 https://bugs.webkit.org/show_bug.cgi?id=160595 5 6 Reviewed by Alex Christensen. 7 8 Adding new tests to cover changes. 9 Removing HEAD with body test as it throws as expected and is redundant with 10 web-platform-tests/fetch/api/request/request-init-002.html. 11 12 * web-platform-tests/fetch/api/basic/request-headers-expected.txt: 13 * web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt: 14 * web-platform-tests/fetch/api/basic/request-headers.js: 15 (checkContentType): 16 (requestHeaders): 17 1 18 2016-08-06 Youenn Fablet <youenn@apple.com> 2 19 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt
r204079 r204225 1 1 2 FAIL Fetch with GET assert_equals: Request has header origin: http://localhost:8800 expected (string) "http://localhost:8800" but got (object) null 3 FAIL Fetch with HEAD assert_equals: Request has header origin: http://localhost:8800 expected (string) "http://localhost:8800" but got (object) null 4 FAIL Fetch with HEAD with body promise_test: Unhandled rejection with value: object "TypeError: Type error" 2 FAIL Fetch with GET assert_equals: Request should have header origin: http://localhost:8800 expected (string) "http://localhost:8800" but got (object) null 3 FAIL Fetch with HEAD assert_equals: Request should have header content-length: null expected (object) null but got (string) "0" 5 4 PASS Fetch with PUT without body 6 5 PASS Fetch with PUT with body 7 6 PASS Fetch with POST without body 8 PASS Fetch with POST with body 9 FAIL Fetch with Chicken assert_equals: Request has header content-length: null expected (object) null but got (string) "0" 7 PASS Fetch with POST with text body 8 FAIL Fetch with POST with FormData body promise_test: Unhandled rejection with value: object "TypeError: Uploading FormData is not yet implemented" 9 FAIL Fetch with POST with Blob body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded" 10 FAIL Fetch with POST with ArrayBuffer body promise_test: Unhandled rejection with value: object "TypeError: Type error" 11 PASS Fetch with POST with Blob body with mime type 12 FAIL Fetch with Chicken assert_equals: Request should have header content-length: null expected (object) null but got (string) "0" 10 13 PASS Fetch with Chicken with body 11 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt
r204079 r204225 1 1 2 FAIL Fetch with GET assert_equals: Request has header origin: http://localhost:8800 expected (string) "http://localhost:8800" but got (object) null 3 FAIL Fetch with HEAD assert_equals: Request has header origin: http://localhost:8800 expected (string) "http://localhost:8800" but got (object) null 4 FAIL Fetch with HEAD with body promise_test: Unhandled rejection with value: object "TypeError: Type error" 2 FAIL Fetch with GET assert_equals: Request should have header origin: http://localhost:8800 expected (string) "http://localhost:8800" but got (object) null 3 FAIL Fetch with HEAD assert_equals: Request should have header content-length: null expected (object) null but got (string) "0" 5 4 PASS Fetch with PUT without body 6 5 PASS Fetch with PUT with body 7 6 PASS Fetch with POST without body 8 PASS Fetch with POST with body 9 FAIL Fetch with Chicken assert_equals: Request has header content-length: null expected (object) null but got (string) "0" 7 PASS Fetch with POST with text body 8 FAIL Fetch with POST with Blob body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded" 9 FAIL Fetch with POST with ArrayBuffer body promise_test: Unhandled rejection with value: object "TypeError: Type error" 10 PASS Fetch with POST with Blob body with mime type 11 FAIL Fetch with Chicken assert_equals: Request should have header content-length: null expected (object) null but got (string) "0" 10 12 PASS Fetch with Chicken with body 11 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.js
r204079 r204225 4 4 } 5 5 6 function checkContentType(contentType, body) 7 { 8 if (self.FormData && body instanceof self.FormData) { 9 assert_true(contentType.startsWith("multipart/form-data;boundary="), "Request should have header content-type starting with multipart/form-data;boundary=, but got " + contentType); 10 return; 11 } 12 13 var expectedContentType = "text/plain;charset=UTF-8"; 14 if(body === null || body instanceof ArrayBuffer) 15 expectedContentType = null; 16 else if (body instanceof Blob) 17 expectedContentType = body.type ? body.type : null; 18 19 assert_equals(contentType , expectedContentType, "Request should have header content-type: " + expectedContentType); 20 } 21 6 22 function requestHeaders(desc, url, method, body, expectedOrigin, expectedContentLength) { 7 var urlParameters = "?headers=origin|user-agent|accept-charset|content-length ";23 var urlParameters = "?headers=origin|user-agent|accept-charset|content-length|content-type"; 8 24 var requestInit = {"method": method} 9 25 if (body) … … 13 29 assert_equals(resp.status, 200, "HTTP status is 200"); 14 30 assert_equals(resp.type , "basic", "Response's type is basic"); 15 assert_equals(resp.headers.get("x-request-origin") , expectedOrigin, "Request has header origin: " + expectedOrigin); 16 assert_equals(resp.headers.get("x-request-content-length") , expectedContentLength, "Request has header content-length: " + expectedContentLength); 31 checkContentType(resp.headers.get("x-request-content-type"), body); 32 if (expectedContentLength !== undefined) 33 assert_equals(resp.headers.get("x-request-content-length") , expectedContentLength, "Request should have header content-length: " + expectedContentLength); 17 34 assert_true(resp.headers.has("x-request-user-agent"), "Request has header user-agent"); 18 35 assert_false(resp.headers.has("accept-charset"), "Request has header accept-charset"); 36 assert_equals(resp.headers.get("x-request-origin") , expectedOrigin, "Request should have header origin: " + expectedOrigin); 19 37 }); 20 38 }, desc); … … 25 43 requestHeaders("Fetch with GET", url, "GET", null, location.origin, null); 26 44 requestHeaders("Fetch with HEAD", url, "HEAD", null, location.origin, null); 27 requestHeaders("Fetch with HEAD with body", url, "HEAD", "Request's body", location.origin, "14");28 45 requestHeaders("Fetch with PUT without body", url, "POST", null, location.origin, "0"); 29 46 requestHeaders("Fetch with PUT with body", url, "PUT", "Request's body", location.origin, "14"); 30 47 requestHeaders("Fetch with POST without body", url, "POST", null, location.origin, "0"); 31 requestHeaders("Fetch with POST with body", url, "POST", "Request's body", location.origin, "14"); 48 requestHeaders("Fetch with POST with text body", url, "POST", "Request's body", location.origin, "14"); 49 if (self.FormData) 50 requestHeaders("Fetch with POST with FormData body", url, "POST", new FormData(), location.origin); 51 requestHeaders("Fetch with POST with Blob body", url, "POST", new Blob(["Test"]), location.origin, "4"); 52 requestHeaders("Fetch with POST with ArrayBuffer body", url, "POST", new ArrayBuffer(4), location.origin, "4"); 53 requestHeaders("Fetch with POST with Blob body with mime type", url, "POST", new Blob(["Test"], { type: "text/maybe" }), location.origin, "4"); 32 54 requestHeaders("Fetch with Chicken", url, "Chicken", null, location.origin, null); 33 55 requestHeaders("Fetch with Chicken with body", url, "Chicken", "Request's body", location.origin, "14"); -
trunk/Source/WebCore/ChangeLog
r204224 r204225 1 2016-08-06 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Fetching with a FormData body should reject until it is implemented 4 https://bugs.webkit.org/show_bug.cgi?id=160595 5 6 Reviewed by Alex Christensen. 7 8 Covered by updated tests. 9 10 This patch ensures that fetch will throw if trying to upload something that is not supported. 11 This is the case of BufferSource (FetchBody does not yet extract it) and FormData (no upload support yet). 12 13 * Modules/fetch/FetchBody.cpp: 14 (WebCore::FetchBody::extract): Added a FIXME. 15 * Modules/fetch/FetchBodyOwner.h: 16 (WebCore::FetchBodyOwner::bodyType): Getter used by FetchResponse. 17 * Modules/fetch/FetchRequest.cpp: 18 (WebCore::FetchRequest::setBody): Throwing if given body parameter cannot be extracted by FetchBody. 19 This ensures that a fetch with a body that cannot be uploaded will fail. 20 This is the case of BufferSource which is not yet supported. 21 * Modules/fetch/FetchResponse.cpp: 22 (WebCore::FetchResponse::fetch): Rejecting fetch promise if trying to upload a FormData as it is not implemented. 23 1 24 2016-08-06 Youenn Fablet <youenn@apple.com> 2 25 -
trunk/Source/WebCore/Modules/fetch/FetchBody.cpp
r203767 r204225 77 77 if (value.inherits(JSReadableStream::info())) 78 78 return { Type::ReadableStream }; 79 // FIXME: Implement BufferSource extraction. 79 80 return { }; 80 81 } -
trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h
r203767 r204225 57 57 bool isActive() const { return !!m_blobLoader; } 58 58 59 FetchBody::Type bodyType() const { return m_body.type(); } 60 59 61 protected: 60 62 const FetchBody& body() const { return m_body; } -
trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp
r204224 r204225 257 257 void FetchRequest::setBody(JSC::ExecState& execState, JSC::JSValue body, FetchRequest* request, ExceptionCode& ec) 258 258 { 259 if (!body.isNull()) 259 if (!body.isNull()) { 260 260 m_body = FetchBody::extract(execState, body); 261 if (m_body.type() == FetchBody::Type::None) { 262 ec = TypeError; 263 return; 264 } 265 } 261 266 else if (request && !request->m_body.isEmpty()) { 262 267 m_body = FetchBody::extractFromBody(&request->m_body); -
trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp
r204020 r204225 106 106 auto response = adoptRef(*new FetchResponse(context, FetchBody::loadingBody(), FetchHeaders::create(FetchHeaders::Guard::Immutable), { })); 107 107 108 // FIXME: Implement form data upload. 109 if (request.bodyType() == FetchBody::Type::FormData) { 110 promise.reject(TypeError, "Uploading FormData is not yet implemented"); 111 return; 112 } 108 113 // Setting pending activity until BodyLoader didFail or didSucceed callback is called. 109 114 response->setPendingActivity(response.ptr());
Note: See TracChangeset
for help on using the changeset viewer.