Changeset 198665 in webkit
- Timestamp:
- Mar 25, 2016 7:19:31 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 12 added
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r198663 r198665 1 2016-03-25 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Fetch API] Add basic loading of resources 4 https://bugs.webkit.org/show_bug.cgi?id=155637 5 6 Reviewed by Darin Adler. 7 8 * TestExpectations: Removed flaky test expectations. 9 * http/tests/fetch/closing-while-fetching-expected.txt: Added. 10 * http/tests/fetch/closing-while-fetching.html: Added. 11 * http/tests/fetch/get-response-body-while-loading-expected.txt: Added. 12 * http/tests/fetch/get-response-body-while-loading.html: Added. 13 * http/tests/resources/download-json-with-delay.php: Added. 14 * platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt: Added. 15 1 16 2016-03-25 Gyuyoung Kim <gyuyoung.kim@webkit.org> 2 17 -
trunk/LayoutTests/TestExpectations
r198649 r198665 317 317 imported/w3c/web-platform-tests/XMLHttpRequest/send-redirect-to-cors.htm [ Skip ] 318 318 imported/w3c/web-platform-tests/XMLHttpRequest/send-redirect-to-non-cors.htm [ Skip ] 319 320 # Tests that are flaky as failing assertions print a new token generated for each test run.321 imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.html [ Failure ]322 imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker.html [ Failure ]323 319 324 320 # New W3C ref tests that are failing. -
trunk/LayoutTests/imported/w3c/ChangeLog
r198649 r198665 1 2016-03-25 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Fetch API] Add basic loading of resources 4 https://bugs.webkit.org/show_bug.cgi?id=155637 5 6 Reviewed by Darin Adler. 7 8 Rebasing test expectations. 9 Updating scheme-blob.js to ensure generated test names are stable run after run. 10 11 * web-platform-tests/fetch/api/basic/accept-header-expected.txt: 12 * web-platform-tests/fetch/api/basic/integrity-expected.txt: 13 * web-platform-tests/fetch/api/basic/mode-no-cors-expected.txt: 14 * web-platform-tests/fetch/api/basic/mode-same-origin-expected.txt: 15 * web-platform-tests/fetch/api/basic/request-forbidden-headers-expected.txt: 16 * web-platform-tests/fetch/api/basic/request-headers-expected.txt: 17 * web-platform-tests/fetch/api/basic/scheme-about-expected.txt: 18 * web-platform-tests/fetch/api/basic/scheme-blob-expected.txt: 19 * web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt: 20 * web-platform-tests/fetch/api/basic/scheme-blob.js: 21 (checkFetchResponse): Deleted. 22 (checkKoUrl): Deleted. 23 * web-platform-tests/fetch/api/basic/scheme-data-expected.txt: 24 * web-platform-tests/fetch/api/basic/scheme-others-expected.txt: 25 * web-platform-tests/fetch/api/basic/stream-response-expected.txt: 26 1 27 2016-03-24 Commit Queue <commit-queue@webkit.org> 2 28 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/accept-header-expected.txt
r198649 r198665 1 1 2 FAIL Request through fetch should have 'accept' header with value '*/*' promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 2 PASS Request through fetch should have 'accept' header with value '*/*' 3 3 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/integrity-expected.txt
r198649 r198665 1 1 2 FAIL Empty string integrity promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 3 FAIL SHA-256 integrity promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 4 FAIL SHA-384 integrity promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 5 FAIL SHA-512 integrity promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 6 FAIL Invalid integrity assert_ throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")7 FAIL Multiple integrities: valid stronger than invalid promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 8 FAIL Multiple integrities: invalid stronger than valid assert_ throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")9 FAIL Multiple integrities: invalid as strong as valid promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 10 FAIL Multiple integrities: both are valid promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 11 FAIL Multiple integrities: both are invalid assert_ throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")12 FAIL CORS empty integrity promise_test: Unhandled rejection with value: "Fetch is not yet implemented"13 FAIL CORS SHA-512 integrity promise_test: Unhandled rejection with value: "Fetch is not yet implemented"14 FAIL CORS invalid integrity assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 2 PASS Empty string integrity 3 PASS SHA-256 integrity 4 PASS SHA-384 integrity 5 PASS SHA-512 integrity 6 FAIL Invalid integrity assert_unreached: Should have rejected. Reached unreachable code 7 PASS Multiple integrities: valid stronger than invalid 8 FAIL Multiple integrities: invalid stronger than valid assert_unreached: Should have rejected. Reached unreachable code 9 PASS Multiple integrities: invalid as strong as valid 10 PASS Multiple integrities: both are valid 11 FAIL Multiple integrities: both are invalid assert_unreached: Should have rejected. Reached unreachable code 12 FAIL CORS empty integrity promise_test: Unhandled rejection with value: object "TypeError: Type error" 13 FAIL CORS SHA-512 integrity promise_test: Unhandled rejection with value: object "TypeError: Type error" 14 PASS CORS invalid integrity 15 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-no-cors-expected.txt
r198649 r198665 1 1 2 FAIL Fetch ../resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 3 FAIL Fetch http://localhost:8800/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 4 FAIL Fetch https://localhost:9443/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: "Fetch is not yet implemented"5 FAIL Fetch http://www.localhost:8800/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: "Fetch is not yet implemented"2 PASS Fetch ../resources/top.txt with no-cors mode 3 PASS Fetch http://localhost:8800/fetch/api/resources/top.txt with no-cors mode 4 FAIL Fetch https://localhost:9443/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: object "TypeError: Type error" 5 FAIL Fetch http://www.localhost:8800/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: object "TypeError: Type error" 6 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin-expected.txt
r198649 r198665 1 1 2 FAIL Fetch ../resources/top.txt with same-origin mode promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 3 FAIL Fetch http://localhost:8800/fetch/api/resources/top.txt with same-origin mode promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 4 FAIL Fetch https://localhost:9443/fetch/api/resources/top.txt with same-origin mode assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 5 FAIL Fetch http://www.localhost:8800/fetch/api/resources/top.txt with same-origin mode assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 2 PASS Fetch ../resources/top.txt with same-origin mode 3 PASS Fetch http://localhost:8800/fetch/api/resources/top.txt with same-origin mode 4 PASS Fetch https://localhost:9443/fetch/api/resources/top.txt with same-origin mode 5 PASS Fetch http://www.localhost:8800/fetch/api/resources/top.txt with same-origin mode 6 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-forbidden-headers-expected.txt
r198649 r198665 1 1 2 FAIL Accept-Charset is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 3 FAIL Accept-Encoding is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 4 FAIL Access-Control-Request-Headers is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 5 FAIL Access-Control-Request-Method is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 6 FAIL Connection is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 7 FAIL Content-Length is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 8 FAIL Cookie is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 9 FAIL Cookie2 is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 10 FAIL Date is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 11 FAIL DNT is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 12 FAIL Expect is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 13 FAIL Host is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 14 FAIL Keep-Alive is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 15 FAIL Origin is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 16 FAIL Referer is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 17 FAIL TE is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 18 FAIL Trailer is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 19 FAIL Transfer-Encoding is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 20 FAIL Upgrade is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 21 FAIL Via is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 22 FAIL Proxy- is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 23 FAIL Proxy-Test is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 24 FAIL Sec- is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 25 FAIL Sec-Test is a forbidden request header promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 2 PASS Accept-Charset is a forbidden request header 3 PASS Accept-Encoding is a forbidden request header 4 PASS Access-Control-Request-Headers is a forbidden request header 5 PASS Access-Control-Request-Method is a forbidden request header 6 PASS Connection is a forbidden request header 7 PASS Content-Length is a forbidden request header 8 PASS Cookie is a forbidden request header 9 PASS Cookie2 is a forbidden request header 10 PASS Date is a forbidden request header 11 PASS DNT is a forbidden request header 12 PASS Expect is a forbidden request header 13 PASS Host is a forbidden request header 14 PASS Keep-Alive is a forbidden request header 15 PASS Origin is a forbidden request header 16 PASS Referer is a forbidden request header 17 PASS TE is a forbidden request header 18 PASS Trailer is a forbidden request header 19 PASS Transfer-Encoding is a forbidden request header 20 PASS Upgrade is a forbidden request header 21 PASS Via is a forbidden request header 22 PASS Proxy- is a forbidden request header 23 PASS Proxy-Test is a forbidden request header 24 PASS Sec- is a forbidden request header 25 PASS Sec-Test is a forbidden request header 26 26 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-expected.txt
r198649 r198665 1 1 2 FAIL Fetch with GET promise_test: Unhandled rejection with value: "Fetch is not yet implemented"3 FAIL Fetch with HEAD promise_test: Unhandled rejection with value: "Fetch is not yet implemented"4 FAIL Fetch with HEAD with body promise_test: Unhandled rejection with value: "Fetch is not yet implemented"5 FAIL Fetch with PUT without body promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 6 FAIL Fetch with PUT with body promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 7 FAIL Fetch with POST without body promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 8 FAIL Fetch with POST with body promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 9 FAIL Fetch with Chicken promise_test: Unhandled rejection with value: "Fetch is not yet implemented"10 FAIL Fetch with Chicken with body promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 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" 5 PASS Fetch with PUT without body 6 PASS Fetch with PUT with body 7 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" 10 PASS Fetch with Chicken with body 11 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about-expected.txt
r198649 r198665 1 1 2 FAIL Fetching about:blank is OK promise_test: Unhandled rejection with value: "Fetch is not yet implemented"3 FAIL Fetching about:unicorn is OK promise_test: Unhandled rejection with value: "Fetch is not yet implemented"4 FAIL Fetching about:invalid.com is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 5 FAIL Fetching about:config is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 2 FAIL Fetching about:blank is OK promise_test: Unhandled rejection with value: object "TypeError: Type error" 3 FAIL Fetching about:unicorn is OK promise_test: Unhandled rejection with value: object "TypeError: Type error" 4 PASS Fetching about:invalid.com is KO 5 PASS Fetching about:config is KO 6 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt
r198649 r198665 1 1 2 FAIL Fetching blob:http://localhost:8800/4580501e-3c0f-4b03[...] is OK promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 3 FAIL Fetching [GET] blob:http://www.localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 4 FAIL Fetching [POST] blob:http://localhost:8800/ad829fe3-9045-4b29[...] is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")2 PASS Regular Blob loading 3 PASS Loading an erroneous blob scheme URL 4 FAIL Loading a blob URL using POST assert_unreached: Should have rejected. Reached unreachable code 5 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt
r198649 r198665 1 1 2 FAIL Fetching blob:http://localhost:8800/8807dca8-91bf-4414[...] is OKpromise_test: Unhandled rejection with value: "Fetch is not yet implemented"3 FAIL Fetching [GET] blob:http://www.localhost:8800/ is KOassert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")4 FAIL Fetching [POST] blob:http://localhost:8800/41805be3-d8cc-490f[...] is KOassert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")2 FAIL Regular Blob loading promise_test: Unhandled rejection with value: "Fetch is not yet implemented" 3 FAIL Loading an erroneous blob scheme URL assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 4 FAIL Loading a blob URL using POST assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 5 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.js
r198649 r198665 5 5 6 6 function checkFetchResponse(url, data, mime, size, desc) { 7 if (!desc)8 var cut = (url.length >= 45) ? "[...]" : "";9 desc = "Fetching " + url.substring(0, 45) + cut + " is OK"10 7 promise_test(function(test) { 11 8 size = size.toString(); … … 23 20 24 21 var blob = new Blob(["Blob's data"], { "type" : "text/plain" }); 25 checkFetchResponse(URL.createObjectURL(blob), "Blob's data", "text/plain", blob.size );22 checkFetchResponse(URL.createObjectURL(blob), "Blob's data", "text/plain", blob.size, "Regular Blob loading"); 26 23 27 24 function checkKoUrl(url, method, desc) { 28 if (!desc)29 var cut = (url.length >= 45) ? "[...]" : "";30 desc = "Fetching [" + method + "] " + url.substring(0, 45) + cut + " is KO"31 25 promise_test(function(test) { 32 26 var promise = fetch(url, {"method": method}); … … 36 30 37 31 var blob2 = new Blob(["Blob's data"], { "type" : "text/plain" }); 38 checkKoUrl("blob:http://{{domains[www]}}:{{ports[http][0]}}/", "GET" );39 checkKoUrl(URL.createObjectURL(blob2), "POST" );32 checkKoUrl("blob:http://{{domains[www]}}:{{ports[http][0]}}/", "GET", "Loading an erroneous blob scheme URL"); 33 checkKoUrl(URL.createObjectURL(blob2), "POST", "Loading a blob URL using POST"); 40 34 41 35 done(); -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data-expected.txt
r198649 r198665 1 1 2 FAIL Fetching data:,response%27s%20body is OK promise_test: Unhandled rejection with value: "Fetch is not yet implemented"3 FAIL Fetching data:text/plain;base64,cmVzcG9uc2UncyBib[...] is OK promise_test: Unhandled rejection with value: "Fetch is not yet implemented"4 FAIL Fetching data:image/png;base64,cmVzcG9uc2UncyBib2[...] is OK promise_test: Unhandled rejection with value: "Fetch is not yet implemented"5 FAIL Fetching [GET] data:notAdataUrl.com is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 6 FAIL Fetching [POST] data:,response%27s%20body is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 7 FAIL Fetching [HEAD] data:,response%27s%20body is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 2 FAIL Fetching data:,response%27s%20body is OK promise_test: Unhandled rejection with value: object "TypeError: Type error" 3 FAIL Fetching data:text/plain;base64,cmVzcG9uc2UncyBib[...] is OK promise_test: Unhandled rejection with value: object "TypeError: Type error" 4 FAIL Fetching data:image/png;base64,cmVzcG9uc2UncyBib2[...] is OK promise_test: Unhandled rejection with value: object "TypeError: Type error" 5 PASS Fetching [GET] data:notAdataUrl.com is KO 6 PASS Fetching [POST] data:,response%27s%20body is KO 7 PASS Fetching [HEAD] data:,response%27s%20body is KO 8 8 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-others-expected.txt
r198649 r198665 1 1 2 FAIL Fetching aaa://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 3 FAIL Fetching cap://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 4 FAIL Fetching cid://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 5 FAIL Fetching dav://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 6 FAIL Fetching dict://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 7 FAIL Fetching dns://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 8 FAIL Fetching geo://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 9 FAIL Fetching im://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 10 FAIL Fetching imap://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 11 FAIL Fetching ipp://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 12 FAIL Fetching ldap://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 13 FAIL Fetching mailto://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 14 FAIL Fetching nfs://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 15 FAIL Fetching pop://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 16 FAIL Fetching rtsp://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 17 FAIL Fetching snmp://localhost:8800/ is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError") 2 PASS Fetching aaa://localhost:8800/ is KO 3 PASS Fetching cap://localhost:8800/ is KO 4 PASS Fetching cid://localhost:8800/ is KO 5 PASS Fetching dav://localhost:8800/ is KO 6 PASS Fetching dict://localhost:8800/ is KO 7 PASS Fetching dns://localhost:8800/ is KO 8 PASS Fetching geo://localhost:8800/ is KO 9 PASS Fetching im://localhost:8800/ is KO 10 PASS Fetching imap://localhost:8800/ is KO 11 PASS Fetching ipp://localhost:8800/ is KO 12 PASS Fetching ldap://localhost:8800/ is KO 13 PASS Fetching mailto://localhost:8800/ is KO 14 PASS Fetching nfs://localhost:8800/ is KO 15 PASS Fetching pop://localhost:8800/ is KO 16 PASS Fetching rtsp://localhost:8800/ is KO 17 PASS Fetching snmp://localhost:8800/ is KO 18 18 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-expected.txt
r198649 r198665 1 1 2 FAIL Stream response's body promise_test: Unhandled rejection with value: "Fetch is not yet implemented"2 FAIL Stream response's body assert_unreached: Body does not exist in response Reached unreachable code 3 3 -
trunk/Source/WebCore/ChangeLog
r198664 r198665 1 2016-03-25 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Fetch API] Add basic loading of resources 4 https://bugs.webkit.org/show_bug.cgi?id=155637 5 6 Reviewed by Darin Adler. 7 8 Adding support for basic fetch for Window (no support for Worker yet). 9 A FetchResponse object is created for every fetch task. 10 But it will only be exposed to JS at promise fulfillment time, i.e. once initial response headers are retrieved. 11 12 Updating Blob resource handle to add Content-Type and Content-Length header and notifying of error in case of erroneous HTTP method. 13 14 Fetch is limited to same origin requests currently due to some WPT tests that would timeout otherwise. 15 16 Tests: http/tests/fetch/closing-while-fetching.html 17 http/tests/fetch/get-response-body-while-loading.html 18 Also covered by rebased tests. 19 20 * Modules/fetch/DOMWindowFetch.cpp: Creating a FetchResponse to start fetching. 21 (WebCore::DOMWindowFetch::fetch): 22 * Modules/fetch/DOMWindowFetch.h: 23 * Modules/fetch/FetchBody.cpp: 24 (WebCore::FetchBody::consume): 25 (WebCore::FetchBody::consumeArrayBuffer): Handling of body promises in case of data stored as a buffer. 26 (WebCore::FetchBody::consumeText): Passing the promise as a reference. 27 (WebCore::blobFromArrayBuffer): Helper routine. 28 (WebCore::FetchBody::fulfillTextPromise): Helper routine. 29 (WebCore::FetchBody::loadedAsArrayBuffer): Updated to handle storing of data as a buffer. 30 (WebCore::FetchBody::loadedAsText): 31 (WebCore::FetchBody::bodyForInternalRequest): Helper routine to generate the request body data to be sent as part of the fetch request. 32 (WebCore::FetchBody::extractFromText): 33 * Modules/fetch/FetchBody.h: 34 (WebCore::FetchBody::loadingBody): 35 (WebCore::FetchBody::FetchBody): 36 * Modules/fetch/FetchBodyOwner.cpp: 37 (WebCore::FetchBodyOwner::loadBlob): Updated to cope with the change that FetchLoader::start does not return a boolean anymore 38 but will directly call failure callbacks. 39 (WebCore::FetchBodyOwner::loadedBlobAsText): Moving it closer to other blob loading routines. 40 (WebCore::FetchBodyOwner::finishBlobLoading): 41 * Modules/fetch/FetchBodyOwner.h: 42 (WebCore::FetchBodyOwner::body): 43 (WebCore::FetchBodyOwner::loadedBlobAsArrayBuffer): 44 * Modules/fetch/FetchHeaders.cpp: 45 (WebCore::FetchHeaders::fill): 46 (WebCore::FetchHeaders::filterAndFill): Helper routine to fill headers from a HTTPHeaderMap after being filtered. 47 * Modules/fetch/FetchHeaders.h: 48 (WebCore::FetchHeaders::internalHeaders): 49 * Modules/fetch/FetchLoader.cpp: 50 (WebCore::FetchLoader::start): 51 (WebCore::FetchLoader::didFailRedirectCheck): 52 * Modules/fetch/FetchLoader.h: 53 * Modules/fetch/FetchRequest.cpp: 54 (WebCore::FetchRequest::internalRequest): Routine used to create the ResourceRequest transmitted to ThreadableLoader. 55 * Modules/fetch/FetchRequest.h: 56 * Modules/fetch/FetchResponse.cpp: 57 (WebCore::FetchResponse::fetch): Start fetching by creating a FetchLoader based on passed request. 58 (WebCore::FetchResponse::BodyLoader::didSucceed): FetchLoader callback. 59 (WebCore::FetchResponse::BodyLoader::didFail): Ditto. 60 (WebCore::FetchResponse::BodyLoader::BodyLoader): Ditto. 61 (WebCore::FetchResponse::BodyLoader::didReceiveResponse): Ditto. 62 (WebCore::FetchResponse::BodyLoader::didFinishLoadingAsArrayBuffer): Ditto. 63 (WebCore::FetchResponse::BodyLoader::start): Starting fetch loader. 64 (WebCore::FetchResponse::BodyLoader::stop): Stopping fetch loader. 65 (WebCore::FetchResponse::stop): Stop loader if any. 66 * Modules/fetch/FetchResponse.h: 67 * platform/network/BlobResourceHandle.cpp: 68 (WebCore::BlobResourceHandle::doStart: Notifying the loader with an error if verb is not GET. 69 (WebCore::BlobResourceHandle::notifyResponseOnSuccess): Adding support for Content-Type and Content-Lenth headers. 70 (WebCore::BlobResourceHandle::createAsync): Removing GET verb check. 71 1 72 2016-03-25 Konstantin Tokarev <annulen@yandex.ru> 2 73 -
trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp
r198649 r198665 32 32 #if ENABLE(FETCH_API) 33 33 34 #include "DOMWindow.h" 35 #include "FetchRequest.h" 36 #include "FetchResponse.h" 37 34 38 namespace WebCore { 35 39 36 void DOMWindowFetch::fetch(DOMWindow& , FetchRequest*, const Dictionary&, FetchPromise&& promise)40 void DOMWindowFetch::fetch(DOMWindow& window, FetchRequest* input, const Dictionary& dictionary, DeferredWrapper&& promise) 37 41 { 38 promise.reject(ASCIILiteral("Fetch is not yet implemented")); 42 if (!window.scriptExecutionContext()) 43 return; 44 ScriptExecutionContext& context = *window.scriptExecutionContext(); 45 46 ExceptionCode ec = 0; 47 RefPtr<FetchRequest> fetchRequest = FetchRequest::create(context, input, dictionary, ec); 48 if (ec) { 49 promise.reject(ec); 50 return; 51 } 52 ASSERT(fetchRequest); 53 FetchResponse::fetch(context, *fetchRequest, WTFMove(promise)); 39 54 } 40 55 41 void DOMWindowFetch::fetch(DOMWindow& , const String&, const Dictionary&, FetchPromise&& promise)56 void DOMWindowFetch::fetch(DOMWindow& window, const String& url, const Dictionary& dictionary, DeferredWrapper&& promise) 42 57 { 43 promise.reject(ASCIILiteral("Fetch is not yet implemented")); 58 if (!window.scriptExecutionContext()) 59 return; 60 ScriptExecutionContext& context = *window.scriptExecutionContext(); 61 62 ExceptionCode ec = 0; 63 RefPtr<FetchRequest> fetchRequest = FetchRequest::create(context, url, dictionary, ec); 64 if (ec) { 65 promise.reject(ec); 66 return; 67 } 68 ASSERT(fetchRequest); 69 FetchResponse::fetch(context, *fetchRequest, WTFMove(promise)); 44 70 } 45 71 -
trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.h
r198649 r198665 31 31 #if ENABLE(FETCH_API) 32 32 33 #include "JSDOMPromise.h"33 #include <wtf/Forward.h> 34 34 35 35 namespace WebCore { 36 36 37 class DOMWindow; 38 class DeferredWrapper; 37 39 class Dictionary; 38 40 class FetchRequest; 39 class FetchResponse;40 41 41 42 class DOMWindowFetch { 42 43 public: 43 using FetchPromise = DOMPromise<RefPtr<FetchResponse>, String>; 44 static void fetch(DOMWindow&, FetchRequest*, const Dictionary&, FetchPromise&&); 45 static void fetch(DOMWindow&, const String&, const Dictionary&, FetchPromise&&); 44 static void fetch(DOMWindow&, FetchRequest*, const Dictionary&, DeferredWrapper&&); 45 static void fetch(DOMWindow&, const String&, const Dictionary&, DeferredWrapper&&); 46 46 }; 47 47 -
trunk/Source/WebCore/Modules/fetch/FetchBody.cpp
r198649 r198665 36 36 #include "ExceptionCode.h" 37 37 #include "FetchBodyOwner.h" 38 #include "FormData.h" 38 39 #include "HTTPParsers.h" 39 40 #include "JSBlob.h" … … 41 42 42 43 namespace WebCore { 44 45 static RefPtr<Blob> blobFromArrayBuffer(ArrayBuffer*, const String&); 43 46 44 47 FetchBody::FetchBody(Ref<Blob>&& blob) … … 156 159 void FetchBody::consume(FetchBodyOwner& owner, Consumer::Type type, DeferredWrapper&& promise) 157 160 { 161 if (m_type == Type::ArrayBuffer) { 162 consumeArrayBuffer(type, promise); 163 return; 164 } 158 165 if (m_type == Type::Text) { 159 consumeText(type, WTFMove(promise));166 consumeText(type, promise); 160 167 return; 161 168 } … … 164 171 return; 165 172 } 173 if (m_type == Type::Loading) { 174 // FIXME: We should be able to change the loading type to text if consumer type is JSON or Text. 175 m_consumer = Consumer({type, WTFMove(promise)}); 176 return; 177 } 166 178 167 179 // FIXME: Support other types. … … 169 181 } 170 182 171 void FetchBody::consumeText(Consumer::Type type, DeferredWrapper&& promise) 183 void FetchBody::consumeArrayBuffer(Consumer::Type type, DeferredWrapper& promise) 184 { 185 if (type == Consumer::Type::ArrayBuffer) { 186 fulfillPromiseWithArrayBuffer(promise, m_data.get()); 187 return; 188 } 189 if (type == Consumer::Type::Blob) { 190 promise.resolve(blobFromArrayBuffer(m_data.get(), Blob::normalizedContentType(extractMIMETypeFromMediaType(m_mimeType)))); 191 return; 192 } 193 194 ASSERT(type == Consumer::Type::Text || type == Consumer::Type::JSON); 195 // FIXME: Do we need TextResourceDecoder to create a String to decode UTF-8 data. 196 fulfillTextPromise(type, TextResourceDecoder::create(ASCIILiteral("text/plain"), "UTF-8")->decodeAndFlush(static_cast<const char*>(m_data->data()), m_data->byteLength()), promise); 197 } 198 199 void FetchBody::consumeText(Consumer::Type type, DeferredWrapper& promise) 172 200 { 173 201 ASSERT(type == Consumer::Type::ArrayBuffer || type == Consumer::Type::Blob); … … 215 243 } 216 244 245 static inline RefPtr<Blob> blobFromArrayBuffer(ArrayBuffer* buffer, const String& contentType) 246 { 247 if (!buffer) 248 return Blob::create(Vector<char>(), contentType); 249 250 // FIXME: We should try to move buffer to Blob without doing this copy. 251 Vector<char> value(buffer->byteLength()); 252 memcpy(value.data(), buffer->data(), buffer->byteLength()); 253 return Blob::create(WTFMove(value), contentType); 254 } 255 256 void FetchBody::fulfillTextPromise(FetchBody::Consumer::Type type, const String& text, DeferredWrapper& promise) 257 { 258 ASSERT(type == Consumer::Type::Text || type == Consumer::Type::JSON); 259 if (type == FetchBody::Consumer::Type::Text) 260 promise.resolve(text); 261 else 262 fulfillPromiseWithJSON(promise, text); 263 } 264 217 265 void FetchBody::loadingFailed() 218 266 { … … 224 272 void FetchBody::loadedAsArrayBuffer(RefPtr<ArrayBuffer>&& buffer) 225 273 { 274 if (m_type == Type::Loading) { 275 m_type = Type::ArrayBuffer; 276 m_data = buffer; 277 if (m_consumer) { 278 consumeArrayBuffer(m_consumer->type, m_consumer->promise); 279 m_consumer = Nullopt; 280 } 281 return; 282 } 283 226 284 ASSERT(m_consumer); 227 285 ASSERT(m_consumer->type == Consumer::Type::Blob || m_consumer->type == Consumer::Type::ArrayBuffer); … … 230 288 else { 231 289 ASSERT(m_blob); 232 Vector<char> data; 233 data.reserveCapacity(buffer->byteLength()); 234 data.append(static_cast<const char*>(buffer->data()), buffer->byteLength()); 235 m_consumer->promise.resolve<RefPtr<Blob>>(Blob::create(WTFMove(data), m_blob->type())); 290 m_consumer->promise.resolve(blobFromArrayBuffer(buffer.get(), m_blob->type())); 236 291 } 237 292 m_consumer = Nullopt; … … 242 297 ASSERT(m_consumer); 243 298 ASSERT(m_consumer->type == Consumer::Type::Text || m_consumer->type == Consumer::Type::JSON); 244 if (m_consumer->type == Consumer::Type::Text) 245 m_consumer->promise.resolve(text); 246 else 247 fulfillPromiseWithJSON(m_consumer->promise, text); 299 300 fulfillTextPromise(m_consumer->type, text, m_consumer->promise); 248 301 m_consumer = Nullopt; 249 302 } 250 303 304 RefPtr<FormData> FetchBody::bodyForInternalRequest() const 305 { 306 if (m_type == Type::None) 307 return nullptr; 308 if (m_type == Type::Text) 309 return FormData::create(UTF8Encoding().encode(m_text, EntitiesForUnencodables)); 310 if (m_type == Type::Blob) { 311 RefPtr<FormData> body = FormData::create(); 312 body->appendBlob(m_blob->url()); 313 return body; 314 } 315 ASSERT_NOT_REACHED(); 316 return nullptr; 317 } 318 251 319 } 252 320 -
trunk/Source/WebCore/Modules/fetch/FetchBody.h
r198649 r198665 45 45 46 46 class FetchBodyOwner; 47 class FormData; 47 48 48 49 class FetchBody { … … 62 63 static FetchBody extract(JSC::ExecState&, JSC::JSValue); 63 64 static FetchBody extractFromBody(FetchBody*); 65 static FetchBody loadingBody() { return { Type::Loading }; } 64 66 FetchBody() = default; 65 67 … … 68 70 void loadedAsText(String&&); 69 71 72 RefPtr<FormData> bodyForInternalRequest() const; 73 70 74 private: 71 enum class Type { None, Text, Blob, FormData };75 enum class Type { None, ArrayBuffer, Loading, Text, Blob, FormData }; 72 76 73 77 FetchBody(Ref<Blob>&&); 74 78 FetchBody(Ref<DOMFormData>&&); 75 79 FetchBody(String&&); 80 FetchBody(Type type) : m_type(type) { } 76 81 77 82 struct Consumer { … … 85 90 Vector<char> extractFromText() const; 86 91 bool processIfEmptyOrDisturbed(Consumer::Type, DeferredWrapper&); 87 void consumeText(Consumer::Type, DeferredWrapper&&); 92 void consumeArrayBuffer(Consumer::Type, DeferredWrapper&); 93 void consumeText(Consumer::Type, DeferredWrapper&); 88 94 void consumeBlob(FetchBodyOwner&, Consumer::Type, DeferredWrapper&&); 89 95 static FetchLoader::Type loadingType(Consumer::Type); 96 static void fulfillTextPromise(FetchBody::Consumer::Type, const String&, DeferredWrapper&); 97 static void fulfillArrayBufferPromise(FetchBody::Consumer::Type, const String&, DeferredWrapper&); 90 98 91 Type m_type = Type::None;99 Type m_type { Type::None }; 92 100 String m_mimeType; 93 bool m_isDisturbed = false;101 bool m_isDisturbed { false }; 94 102 95 103 // FIXME: Add support for BufferSource and URLSearchParams. 96 104 RefPtr<Blob> m_blob; 97 105 RefPtr<DOMFormData> m_formData; 106 RefPtr<ArrayBuffer> m_data; 98 107 String m_text; 99 108 -
trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp
r198649 r198665 60 60 ASSERT(!m_blobLoader); 61 61 62 if (!scriptExecutionContext()) { 63 m_body.loadingFailed(); 64 return; 65 } 66 62 67 m_blobLoader = { *this }; 63 68 m_blobLoader->loader = std::make_unique<FetchLoader>(type, *m_blobLoader); 64 69 70 m_blobLoader->loader->start(*scriptExecutionContext(), blob); 71 if (!m_blobLoader->loader->isStarted()) { 72 m_body.loadingFailed(); 73 m_blobLoader = Nullopt; 74 return; 75 } 65 76 setPendingActivity(this); 66 if (!scriptExecutionContext() || !m_blobLoader->loader->start(*scriptExecutionContext(), blob))67 blobLoadingFailed();68 }69 70 void FetchBodyOwner::loadedBlobAsText(String&& text)71 {72 m_body.loadedAsText(WTFMove(text));73 77 } 74 78 … … 79 83 m_blobLoader = Nullopt; 80 84 unsetPendingActivity(this); 85 } 86 87 void FetchBodyOwner::loadedBlobAsText(String&& text) 88 { 89 m_body.loadedAsText(WTFMove(text)); 81 90 } 82 91 … … 98 107 } 99 108 109 void FetchBodyOwner::BlobLoader::didFail() 110 { 111 // didFail might be called within FetchLoader::start call. 112 if (loader->isStarted()) 113 owner.blobLoadingFailed(); 114 } 115 100 116 } // namespace WebCore 101 117 -
trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h
r198649 r198665 55 55 bool isActive() const { return !!m_blobLoader; } 56 56 57 protected: 58 const FetchBody& body() const { return m_body; } 59 FetchBody& body() { return m_body; } 60 61 // ActiveDOMObject API 62 void stop() override; 63 57 64 private: 58 65 // Blob loading routines … … 63 70 void finishBlobLoading(); 64 71 65 // ActiveDOMObject API66 void stop() override;67 68 72 struct BlobLoader final : FetchLoaderClient { 69 73 BlobLoader(FetchBodyOwner&); … … 73 77 void didFinishLoadingAsArrayBuffer(RefPtr<ArrayBuffer>&& buffer) final { owner.loadedBlobAsArrayBuffer(WTFMove(buffer)); } 74 78 void didReceiveResponse(const ResourceResponse&) final; 75 void didFail() final { owner.blobLoadingFailed(); };79 void didFail() final; 76 80 void didSucceed() final { owner.blobLoadingSucceeded(); } 77 81 -
trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp
r198649 r198665 157 157 void FetchHeaders::fill(const FetchHeaders* headers) 158 158 { 159 ASSERT(m_guard != Guard::Immutable); 160 159 161 if (!headers) 160 162 return; 161 163 162 ASSERT(m_guard != Guard::Immutable); 163 164 filterAndFill(headers->m_headers, m_guard); 165 } 166 167 void FetchHeaders::filterAndFill(const HTTPHeaderMap& headers, Guard guard) 168 { 164 169 ExceptionCode ec; 165 for (auto& header : headers ->m_headers) {166 if (canWriteHeader(header.key, header.value, m_guard, ec)) {170 for (auto& header : headers) { 171 if (canWriteHeader(header.key, header.value, guard, ec)) { 167 172 if (header.keyAsHTTPHeaderName) 168 173 m_headers.add(header.keyAsHTTPHeaderName.value(), header.value); -
trunk/Source/WebCore/Modules/fetch/FetchHeaders.h
r198649 r198665 65 65 void fill(const FetchHeaders*); 66 66 67 void filterAndFill(const HTTPHeaderMap&, Guard); 68 67 69 String fastGet(HTTPHeaderName name) const { return m_headers.get(name); } 68 70 void fastSet(HTTPHeaderName name, const String& value) { m_headers.set(name, value); } … … 80 82 Iterator createIterator() { return Iterator(*this); } 81 83 84 const HTTPHeaderMap& internalHeaders() const { return m_headers; } 85 82 86 private: 83 87 FetchHeaders(Guard guard) : m_guard(guard) { } -
trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp
r198649 r198665 35 35 #include "FetchBody.h" 36 36 #include "FetchLoaderClient.h" 37 #include "FetchRequest.h" 37 38 #include "ResourceRequest.h" 38 39 #include "ScriptExecutionContext.h" 40 #include "SecurityOrigin.h" 39 41 #include "SharedBuffer.h" 40 42 #include "TextResourceDecoder.h" … … 44 46 namespace WebCore { 45 47 46 boolFetchLoader::start(ScriptExecutionContext& context, Blob& blob)48 void FetchLoader::start(ScriptExecutionContext& context, Blob& blob) 47 49 { 48 50 auto urlForReading = BlobURL::createPublicURL(context.securityOrigin()); 49 if (urlForReading.isEmpty()) 50 return false; 51 if (urlForReading.isEmpty()) { 52 m_client.didFail(); 53 return; 54 } 55 51 56 ThreadableBlobRegistry::registerBlobURL(context.securityOrigin(), urlForReading, blob.url()); 52 57 … … 64 69 65 70 m_loader = ThreadableLoader::create(&context, this, request, options); 66 return true; 71 } 72 73 void FetchLoader::start(ScriptExecutionContext& context, const FetchRequest& request) 74 { 75 // FIXME: Compute loading options according fetch options. 76 ThreadableLoaderOptions options; 77 options.setSendLoadCallbacks(SendCallbacks); 78 options.setSniffContent(DoNotSniffContent); 79 options.setDataBufferingPolicy(DoNotBufferData); 80 options.preflightPolicy = ConsiderPreflight; 81 options.setAllowCredentials(AllowStoredCredentials); 82 options.crossOriginRequestPolicy = DenyCrossOriginRequests; 83 options.contentSecurityPolicyEnforcement = ContentSecurityPolicyEnforcement::DoNotEnforce; 84 85 m_loader = ThreadableLoader::create(&context, this, request.internalRequest(), options); 67 86 } 68 87 … … 114 133 } 115 134 135 void FetchLoader::didFailRedirectCheck() 136 { 137 m_client.didFail(); 138 } 139 116 140 } // namespace WebCore 117 141 -
trunk/Source/WebCore/Modules/fetch/FetchLoader.h
r198649 r198665 40 40 class Blob; 41 41 class FetchLoaderClient; 42 class FetchRequest; 42 43 class ScriptExecutionContext; 43 44 … … 48 49 FetchLoader(Type, FetchLoaderClient&); 49 50 50 bool start(ScriptExecutionContext&, Blob&); 51 void start(ScriptExecutionContext&, const FetchRequest&); 52 void start(ScriptExecutionContext&, Blob&); 51 53 void stop(); 52 54 55 bool isStarted() const { return !!m_loader; } 53 56 private: 54 57 // ThreadableLoaderClient API. … … 57 60 void didFinishLoading(unsigned long, double) final; 58 61 void didFail(const ResourceError&) final; 62 void didFailRedirectCheck() final; 59 63 60 64 private: -
trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp
r198649 r198665 436 436 } 437 437 438 ResourceRequest FetchRequest::internalRequest() const 439 { 440 ResourceRequest request = m_internalRequest.request; 441 request.setHTTPHeaderFields(m_headers->internalHeaders()); 442 request.setHTTPBody(body().bodyForInternalRequest()); 443 return request; 444 } 445 438 446 RefPtr<FetchRequest> FetchRequest::clone(ScriptExecutionContext& context, ExceptionCode& ec) 439 447 { -
trunk/Source/WebCore/Modules/fetch/FetchRequest.h
r198649 r198665 73 73 }; 74 74 75 const FetchOptions& fetchOptions() const { return m_internalRequest.options; } 76 ResourceRequest internalRequest() const; 77 75 78 private: 76 79 FetchRequest(ScriptExecutionContext&, FetchBody&&, Ref<FetchHeaders>&&, InternalRequest&&); -
trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp
r198649 r198665 154 154 } 155 155 156 void FetchResponse::fetch(ScriptExecutionContext& context, const FetchRequest& request, FetchPromise&& promise) 157 { 158 Ref<FetchResponse> response = adoptRef(*new FetchResponse(context, Type::Basic, FetchBody::loadingBody(), FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse())); 159 160 // Setting pending activity until BodyLoader didFail or didSucceed callback is called. 161 response->setPendingActivity(response.ptr()); 162 163 response->m_bodyLoader = BodyLoader(response.get(), WTFMove(promise)); 164 if (!response->m_bodyLoader->start(context, request)) 165 response->m_bodyLoader = Nullopt; 166 } 167 168 void FetchResponse::BodyLoader::didSucceed() 169 { 170 m_response.m_bodyLoader = Nullopt; 171 m_response.unsetPendingActivity(&m_response); 172 } 173 174 void FetchResponse::BodyLoader::didFail() 175 { 176 if (m_promise) 177 std::exchange(m_promise, Nullopt)->reject(TypeError); 178 179 // Check whether didFail is called as part of FetchLoader::start. 180 if (m_loader->isStarted()) 181 m_response.m_bodyLoader = Nullopt; 182 183 // FIXME: Handle the case of failing after didReceiveResponse is called. 184 185 m_response.unsetPendingActivity(&m_response); 186 } 187 188 FetchResponse::BodyLoader::BodyLoader(FetchResponse& response, FetchPromise&& promise) 189 : m_response(response) 190 , m_promise(WTFMove(promise)) 191 { 192 } 193 194 void FetchResponse::BodyLoader::didReceiveResponse(const ResourceResponse& resourceResponse) 195 { 196 ASSERT(m_promise); 197 198 m_response.m_response = resourceResponse; 199 m_response.m_headers->filterAndFill(resourceResponse.httpHeaderFields(), FetchHeaders::Guard::Response); 200 201 std::exchange(m_promise, Nullopt)->resolve(&m_response); 202 } 203 204 void FetchResponse::BodyLoader::didFinishLoadingAsArrayBuffer(RefPtr<ArrayBuffer>&& buffer) 205 { 206 m_response.body().loadedAsArrayBuffer(WTFMove(buffer)); 207 } 208 209 bool FetchResponse::BodyLoader::start(ScriptExecutionContext& context, const FetchRequest& request) 210 { 211 m_loader = std::make_unique<FetchLoader>(FetchLoader::Type::ArrayBuffer, *this); 212 m_loader->start(context, request); 213 return m_loader->isStarted(); 214 } 215 216 void FetchResponse::BodyLoader::stop() 217 { 218 if (m_loader) 219 m_loader->stop(); 220 } 221 222 void FetchResponse::stop() 223 { 224 FetchBodyOwner::stop(); 225 if (m_bodyLoader) { 226 RefPtr<FetchResponse> protect(this); 227 m_bodyLoader->stop(); 228 m_bodyLoader = Nullopt; 229 } 230 } 231 156 232 const char* FetchResponse::activeDOMObjectName() const 157 233 { -
trunk/Source/WebCore/Modules/fetch/FetchResponse.h
r198649 r198665 43 43 44 44 class Dictionary; 45 class FetchRequest; 45 46 46 47 typedef int ExceptionCode; … … 53 54 // FIXME: Binding generator should not require below method to handle optional status parameter. 54 55 static RefPtr<FetchResponse> redirect(ScriptExecutionContext& context, const String& url, ExceptionCode& ec) { return redirect(context, url, 302, ec); } 56 57 using FetchPromise = DOMPromise<RefPtr<FetchResponse>, ExceptionCode>; 58 static void fetch(ScriptExecutionContext&, const FetchRequest&, FetchPromise&&); 55 59 56 60 void initializeWith(const Dictionary&, ExceptionCode&); … … 72 76 73 77 // ActiveDOMObject API 78 void stop() final; 74 79 const char* activeDOMObjectName() const final; 75 80 bool canSuspendForDocumentSuspension() const final; 81 82 class BodyLoader final : public FetchLoaderClient { 83 public: 84 BodyLoader(FetchResponse&, FetchPromise&&); 85 86 bool start(ScriptExecutionContext&, const FetchRequest&); 87 void stop(); 88 89 private: 90 // FetchLoaderClient API 91 void didSucceed() final; 92 void didFail() final; 93 void didReceiveResponse(const ResourceResponse&); 94 void didFinishLoadingAsArrayBuffer(RefPtr<ArrayBuffer>&&) final; 95 96 FetchResponse& m_response; 97 Optional<FetchPromise> m_promise; 98 std::unique_ptr<FetchLoader> m_loader; 99 }; 76 100 77 101 Type m_type; … … 80 104 bool m_isLocked = false; 81 105 bool m_isRedirected = false; 106 Optional<BodyLoader> m_bodyLoader; 82 107 }; 83 108 -
trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp
r198649 r198665 137 137 PassRefPtr<BlobResourceHandle> BlobResourceHandle::createAsync(BlobData* blobData, const ResourceRequest& request, ResourceHandleClient* client) 138 138 { 139 // FIXME: Should probably call didFail() instead of blocking the load without explanation.140 if (!equalLettersIgnoringASCIICase(request.httpMethod(), "get"))141 return nullptr;142 143 139 return adoptRef(new BlobResourceHandle(blobData, request, client, true)); 144 140 } … … 207 203 if (m_aborted || m_errorCode) 208 204 return; 205 206 if (!equalLettersIgnoringASCIICase(firstRequest().httpMethod(), "get")) { 207 m_errorCode = methodNotAllowed; 208 notifyResponse(); 209 return; 210 } 209 211 210 212 // If the blob data is not found, fail now. … … 579 581 response.setHTTPStatusCode(isRangeRequest ? httpPartialContent : httpOK); 580 582 response.setHTTPStatusText(isRangeRequest ? httpPartialContentText : httpOKText); 583 584 response.setHTTPHeaderField(HTTPHeaderName::ContentType, m_blobData->contentType()); 585 response.setHTTPHeaderField(HTTPHeaderName::ContentLength, String::number(m_totalRemainingSize)); 586 581 587 if (isRangeRequest) 582 588 response.setHTTPHeaderField(HTTPHeaderName::ContentRange, ParsedContentRange(m_rangeOffset, m_rangeEnd, m_totalSize).headerValue());
Note: See TracChangeset
for help on using the changeset viewer.