Changeset 198891 in webkit


Ignore:
Timestamp:
Mar 31, 2016 4:05:11 AM (8 years ago)
Author:
youenn.fablet@crf.canon.fr
Message:

[Fetch API] Add basic loading of resources for Workers
https://bugs.webkit.org/show_bug.cgi?id=155886

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Updating test expectations as new tests are passing.

  • web-platform-tests/fetch/api/basic/accept-header-worker-expected.txt:
  • web-platform-tests/fetch/api/basic/integrity-worker-expected.txt:
  • web-platform-tests/fetch/api/basic/mode-no-cors-worker-expected.txt:
  • web-platform-tests/fetch/api/basic/mode-same-origin-worker-expected.txt:
  • web-platform-tests/fetch/api/basic/request-forbidden-headers-worker-expected.txt:
  • web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt:
  • web-platform-tests/fetch/api/basic/scheme-about-worker-expected.txt:
  • web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt:
  • web-platform-tests/fetch/api/basic/scheme-data-worker-expected.txt:
  • web-platform-tests/fetch/api/basic/scheme-others-worker-expected.txt:
  • web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt:

Source/WebCore:

Adding impplementation to WorkerGlobalScopeFetch::fetch similarly to DOMWindowFetch::fetch.
Refactored code in FetchResponse to share code between the two.

Updated WorkerThreadableLoader to cope with an ASSERT.
The ASSERT ensures that a DocumentThreadableLoader::create returns non null.
In our case, it might happen as all cross origin fetch requests are denied at the moment.
This leads to calling didFail in DocumentThreadableLoader::create call and DocumentThreadableLoader::create to return null.
Updated the ASSERT to ensures that either the load is finished or DocumentThreadableLoader::create does not return null.

Covered by rebased tests.

  • Modules/fetch/DOMWindowFetch.cpp:

(WebCore::DOMWindowFetch::fetch):

  • Modules/fetch/FetchResponse.cpp:

(WebCore::FetchResponse::startFetching):
(WebCore::FetchResponse::fetch):

  • Modules/fetch/FetchResponse.h:
  • Modules/fetch/WorkerGlobalScopeFetch.cpp:

(WebCore::WorkerGlobalScopeFetch::fetch):

  • Modules/fetch/WorkerGlobalScopeFetch.h:
  • loader/WorkerThreadableLoader.cpp:

(WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishLoading):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFail):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFailAccessControlCheck):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck):

  • loader/WorkerThreadableLoader.h:

LayoutTests:

Soup and Mac HTTP backends differ on Content-Length header handling.

  • platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt: Added.
Location:
trunk
Files:
1 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r198889 r198891  
     12016-03-31  Youenn Fablet  <youenn.fablet@crf.canon.fr>
     2
     3        [Fetch API] Add basic loading of resources for Workers
     4        https://bugs.webkit.org/show_bug.cgi?id=155886
     5
     6        Reviewed by Alex Christensen.
     7
     8        Soup and Mac HTTP backends differ on Content-Length header handling.
     9
     10        * platform/gtk/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt: Added.
     11
    1122016-03-31  Youenn Fablet  <youenn.fablet@crf.canon.fr>
    213
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r198888 r198891  
     12016-03-31  Youenn Fablet  <youenn.fablet@crf.canon.fr>
     2
     3        [Fetch API] Add basic loading of resources for Workers
     4        https://bugs.webkit.org/show_bug.cgi?id=155886
     5
     6        Reviewed by Alex Christensen.
     7
     8        Updating test expectations as new tests are passing.
     9
     10        * web-platform-tests/fetch/api/basic/accept-header-worker-expected.txt:
     11        * web-platform-tests/fetch/api/basic/integrity-worker-expected.txt:
     12        * web-platform-tests/fetch/api/basic/mode-no-cors-worker-expected.txt:
     13        * web-platform-tests/fetch/api/basic/mode-same-origin-worker-expected.txt:
     14        * web-platform-tests/fetch/api/basic/request-forbidden-headers-worker-expected.txt:
     15        * web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt:
     16        * web-platform-tests/fetch/api/basic/scheme-about-worker-expected.txt:
     17        * web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt:
     18        * web-platform-tests/fetch/api/basic/scheme-data-worker-expected.txt:
     19        * web-platform-tests/fetch/api/basic/scheme-others-worker-expected.txt:
     20        * web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt:
     21
    1222016-03-31  Youenn Fablet  <youenn.fablet@crf.canon.fr>
    223
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/accept-header-worker-expected.txt

    r197748 r198891  
    11
    2 FAIL Request through fetch should have 'accept' header with value '*/*' promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
     2PASS Request through fetch should have 'accept' header with value '*/*'
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/integrity-worker-expected.txt

    r197748 r198891  
    11
    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")
     2PASS Empty string integrity
     3PASS SHA-256 integrity
     4PASS SHA-384 integrity
     5PASS SHA-512 integrity
     6FAIL Invalid integrity assert_unreached: Should have rejected. Reached unreachable code
     7PASS Multiple integrities: valid stronger than invalid
     8FAIL Multiple integrities: invalid stronger than valid assert_unreached: Should have rejected. Reached unreachable code
     9PASS Multiple integrities: invalid as strong as valid
     10PASS Multiple integrities: both are valid
     11FAIL Multiple integrities: both are invalid assert_unreached: Should have rejected. Reached unreachable code
     12FAIL CORS empty integrity promise_test: Unhandled rejection with value: object "TypeError: Type error"
     13FAIL CORS SHA-512 integrity promise_test: Unhandled rejection with value: object "TypeError: Type error"
     14PASS CORS invalid integrity
    1515
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-no-cors-worker-expected.txt

    r198116 r198891  
    11
    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"
     2PASS Fetch ../resources/top.txt with no-cors mode
     3PASS Fetch http://localhost:8800/fetch/api/resources/top.txt with no-cors mode
     4FAIL Fetch https://localhost:9443/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: object "TypeError: Type error"
     5FAIL Fetch http://www.localhost:8800/fetch/api/resources/top.txt with no-cors mode promise_test: Unhandled rejection with value: object "TypeError: Type error"
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin-worker-expected.txt

    r198116 r198891  
    11
    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")
     2PASS Fetch ../resources/top.txt with same-origin mode
     3PASS Fetch http://localhost:8800/fetch/api/resources/top.txt with same-origin mode
     4PASS Fetch https://localhost:9443/fetch/api/resources/top.txt with same-origin mode
     5PASS Fetch http://www.localhost:8800/fetch/api/resources/top.txt with same-origin mode
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-forbidden-headers-worker-expected.txt

    r197748 r198891  
    11
    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"
     2PASS Accept-Charset is a forbidden request header
     3PASS Accept-Encoding is a forbidden request header
     4PASS Access-Control-Request-Headers is a forbidden request header
     5PASS Access-Control-Request-Method is a forbidden request header
     6PASS Connection is a forbidden request header
     7PASS Content-Length is a forbidden request header
     8PASS Cookie is a forbidden request header
     9PASS Cookie2 is a forbidden request header
     10PASS Date is a forbidden request header
     11PASS DNT is a forbidden request header
     12PASS Expect is a forbidden request header
     13PASS Host is a forbidden request header
     14PASS Keep-Alive is a forbidden request header
     15PASS Origin is a forbidden request header
     16PASS Referer is a forbidden request header
     17PASS TE is a forbidden request header
     18PASS Trailer is a forbidden request header
     19PASS Transfer-Encoding is a forbidden request header
     20PASS Upgrade is a forbidden request header
     21PASS Via is a forbidden request header
     22PASS Proxy- is a forbidden request header
     23PASS Proxy-Test is a forbidden request header
     24PASS Sec- is a forbidden request header
     25PASS Sec-Test is a forbidden request header
    2626
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt

    r197748 r198891  
    11
    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"
     2FAIL Fetch with GET assert_equals: Request has header origin: http://localhost:8800 expected (string) "http://localhost:8800" but got (object) null
     3FAIL Fetch with HEAD assert_equals: Request has header origin: http://localhost:8800 expected (string) "http://localhost:8800" but got (object) null
     4FAIL Fetch with HEAD with body promise_test: Unhandled rejection with value: object "TypeError: Type error"
     5PASS Fetch with PUT without body
     6PASS Fetch with PUT with body
     7PASS Fetch with POST without body
     8PASS Fetch with POST with body
     9FAIL Fetch with Chicken assert_equals: Request has header content-length: null expected (object) null but got (string) "0"
     10PASS Fetch with Chicken with body
    1111
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about-worker-expected.txt

    r197748 r198891  
    11
    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")
     2FAIL Fetching about:blank is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
     3FAIL Fetching about:unicorn is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
     4PASS Fetching about:invalid.com is KO
     5PASS Fetching about:config is KO
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt

    r198888 r198891  
    11
    2 FAIL Fetching [GET] URL.createObjectURL(blob) 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] URL.createObjectURL(blob) is KO assert_throws: function "function () { throw e }" threw "Fetch is not yet implemented" (undefined) expected object "TypeError" ("TypeError")
     2PASS Fetching [GET] URL.createObjectURL(blob) is OK
     3PASS Fetching [GET] blob:http://www.localhost:8800/ is KO
     4FAIL Fetching [POST] URL.createObjectURL(blob) is KO assert_unreached: Should have rejected. Reached unreachable code
    55
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data-worker-expected.txt

    r197748 r198891  
    11
    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")
     2FAIL Fetching data:,response%27s%20body is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
     3FAIL Fetching data:text/plain;base64,cmVzcG9uc2UncyBib[...] is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
     4FAIL Fetching data:image/png;base64,cmVzcG9uc2UncyBib2[...] is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
     5PASS Fetching [GET] data:notAdataUrl.com is KO
     6PASS Fetching [POST] data:,response%27s%20body is KO
     7PASS Fetching [HEAD] data:,response%27s%20body is KO
    88
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-others-worker-expected.txt

    r197748 r198891  
    11
    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")
     2PASS Fetching aaa://localhost:8800/ is KO
     3PASS Fetching cap://localhost:8800/ is KO
     4PASS Fetching cid://localhost:8800/ is KO
     5PASS Fetching dav://localhost:8800/ is KO
     6PASS Fetching dict://localhost:8800/ is KO
     7PASS Fetching dns://localhost:8800/ is KO
     8PASS Fetching geo://localhost:8800/ is KO
     9PASS Fetching im://localhost:8800/ is KO
     10PASS Fetching imap://localhost:8800/ is KO
     11PASS Fetching ipp://localhost:8800/ is KO
     12PASS Fetching ldap://localhost:8800/ is KO
     13PASS Fetching mailto://localhost:8800/ is KO
     14PASS Fetching nfs://localhost:8800/ is KO
     15PASS Fetching pop://localhost:8800/ is KO
     16PASS Fetching rtsp://localhost:8800/ is KO
     17PASS Fetching snmp://localhost:8800/ is KO
    1818
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt

    r197748 r198891  
    11
    2 FAIL Stream response's body promise_test: Unhandled rejection with value: "Fetch is not yet implemented"
     2FAIL Stream response's body assert_unreached: Body does not exist in response Reached unreachable code
    33
  • trunk/Source/WebCore/ChangeLog

    r198890 r198891  
     12016-03-31  Youenn Fablet  <youenn.fablet@crf.canon.fr>
     2
     3        [Fetch API] Add basic loading of resources for Workers
     4        https://bugs.webkit.org/show_bug.cgi?id=155886
     5
     6        Reviewed by Alex Christensen.
     7
     8        Adding impplementation to WorkerGlobalScopeFetch::fetch similarly to DOMWindowFetch::fetch.
     9        Refactored code in FetchResponse to share code between the two.
     10
     11        Updated WorkerThreadableLoader to cope with an ASSERT.
     12        The ASSERT ensures that a DocumentThreadableLoader::create returns non null.
     13        In our case, it might happen as all cross origin fetch requests are denied at the moment.
     14        This leads to calling didFail in DocumentThreadableLoader::create call and DocumentThreadableLoader::create to return null.
     15        Updated the ASSERT to ensures that either the load is finished or DocumentThreadableLoader::create does not return null.
     16
     17        Covered by rebased tests.
     18
     19        * Modules/fetch/DOMWindowFetch.cpp:
     20        (WebCore::DOMWindowFetch::fetch):
     21        * Modules/fetch/FetchResponse.cpp:
     22        (WebCore::FetchResponse::startFetching):
     23        (WebCore::FetchResponse::fetch):
     24        * Modules/fetch/FetchResponse.h:
     25        * Modules/fetch/WorkerGlobalScopeFetch.cpp:
     26        (WebCore::WorkerGlobalScopeFetch::fetch):
     27        * Modules/fetch/WorkerGlobalScopeFetch.h:
     28        * loader/WorkerThreadableLoader.cpp:
     29        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
     30        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishLoading):
     31        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFail):
     32        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFailAccessControlCheck):
     33        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck):
     34        * loader/WorkerThreadableLoader.h:
     35
    1362016-03-31  Youenn Fablet  <youenn.fablet@crf.canon.fr>
    237
  • trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp

    r198833 r198891  
    4242    if (!window.scriptExecutionContext())
    4343        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));
     44    FetchResponse::fetch(*window.scriptExecutionContext(), input, dictionary, WTFMove(promise));
    5445}
    5546
     
    5849    if (!window.scriptExecutionContext())
    5950        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));
     51    FetchResponse::fetch(*window.scriptExecutionContext(), url, dictionary, WTFMove(promise));
    7052}
    7153
  • trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp

    r198890 r198891  
    3434#include "Dictionary.h"
    3535#include "ExceptionCode.h"
     36#include "FetchRequest.h"
    3637#include "JSFetchResponse.h"
    3738#include "ScriptExecutionContext.h"
     
    154155}
    155156
    156 void FetchResponse::fetch(ScriptExecutionContext& context, const FetchRequest& request, FetchPromise&& promise)
     157void FetchResponse::startFetching(ScriptExecutionContext& context, const FetchRequest& request, FetchPromise&& promise)
    157158{
    158159    Ref<FetchResponse> response = adoptRef(*new FetchResponse(context, Type::Basic, FetchBody::loadingBody(), FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse()));
     
    164165    if (!response->m_bodyLoader->start(context, request))
    165166        response->m_bodyLoader = Nullopt;
     167}
     168
     169void FetchResponse::fetch(ScriptExecutionContext& context, FetchRequest& input, const Dictionary& dictionary, FetchPromise&& promise)
     170{
     171    ExceptionCode ec = 0;
     172    RefPtr<FetchRequest> fetchRequest = FetchRequest::create(context, input, dictionary, ec);
     173    if (ec) {
     174        promise.reject(ec);
     175        return;
     176    }
     177    ASSERT(fetchRequest);
     178    startFetching(context, *fetchRequest, WTFMove(promise));
     179}
     180
     181void FetchResponse::fetch(ScriptExecutionContext& context, const String& url, const Dictionary& dictionary, FetchPromise&& promise)
     182{
     183    ExceptionCode ec = 0;
     184    RefPtr<FetchRequest> fetchRequest = FetchRequest::create(context, url, dictionary, ec);
     185    if (ec) {
     186        promise.reject(ec);
     187        return;
     188    }
     189    ASSERT(fetchRequest);
     190    startFetching(context, *fetchRequest, WTFMove(promise));
    166191}
    167192
  • trunk/Source/WebCore/Modules/fetch/FetchResponse.h

    r198665 r198891  
    5656
    5757    using FetchPromise = DOMPromise<RefPtr<FetchResponse>, ExceptionCode>;
    58     static void fetch(ScriptExecutionContext&, const FetchRequest&, FetchPromise&&);
     58    static void fetch(ScriptExecutionContext&, FetchRequest&, const Dictionary&, FetchPromise&&);
     59    static void fetch(ScriptExecutionContext&, const String&, const Dictionary&, FetchPromise&&);
    5960
    6061    void initializeWith(const Dictionary&, ExceptionCode&);
     
    7475
    7576    FetchResponse(ScriptExecutionContext&, Type, FetchBody&&, Ref<FetchHeaders>&&, ResourceResponse&&);
     77
     78    static void startFetching(ScriptExecutionContext&, const FetchRequest&, FetchPromise&&);
    7679
    7780    // ActiveDOMObject API
  • trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp

    r198833 r198891  
    3232#if ENABLE(FETCH_API)
    3333
     34#include "FetchResponse.h"
     35#include "WorkerGlobalScope.h"
     36
    3437namespace WebCore {
    3538
    36 void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope&, FetchRequest&, const Dictionary&, FetchPromise&& promise)
     39void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, FetchRequest& input, const Dictionary& dictionary, DeferredWrapper&& promise)
    3740{
    38     promise.reject(ASCIILiteral("Fetch is not yet implemented"));
     41    if (!scope.scriptExecutionContext())
     42        return;
     43    FetchResponse::fetch(*scope.scriptExecutionContext(), input, dictionary, WTFMove(promise));
    3944}
    4045
    41 void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope&, const String&, const Dictionary&, FetchPromise&& promise)
     46void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, const String& url, const Dictionary& dictionary, DeferredWrapper&& promise)
    4247{
    43     promise.reject(ASCIILiteral("Fetch is not yet implemented"));
     48    if (!scope.scriptExecutionContext())
     49        return;
     50    FetchResponse::fetch(*scope.scriptExecutionContext(), url, dictionary, WTFMove(promise));
    4451}
    4552
  • trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h

    r198833 r198891  
    3232
    3333#include "JSDOMPromise.h"
     34#include <wtf/Forward.h>
    3435
    3536namespace WebCore {
    3637
     38class WorkerGlobalScope;
     39class DeferredWrapper;
    3740class Dictionary;
    3841class FetchRequest;
    39 class FetchResponse;
    40 class ScriptExecutionContext;
    41 class WorkerGlobalScope;
    4242
    4343class WorkerGlobalScopeFetch {
    4444public:
    45     using FetchPromise = DOMPromise<RefPtr<FetchResponse>, String>;
    46     static void fetch(WorkerGlobalScope&, FetchRequest&, const Dictionary&, FetchPromise&&);
    47     static void fetch(WorkerGlobalScope&, const String&, const Dictionary&, FetchPromise&&);
     45    static void fetch(WorkerGlobalScope&, FetchRequest&, const Dictionary&, DeferredWrapper&&);
     46    static void fetch(WorkerGlobalScope&, const String&, const Dictionary&, DeferredWrapper&&);
    4847};
    4948
  • trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp

    r197551 r198891  
    113113        // a failure.
    114114        m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, *request, *options, std::unique_ptr<ContentSecurityPolicy>(contentSecurityPolicyCopy));
    115         ASSERT(m_mainThreadLoader);
     115        ASSERT(m_mainThreadLoader || m_loadingFinished);
    116116    });
    117117}
     
    194194void WorkerThreadableLoader::MainThreadBridge::didFinishLoading(unsigned long identifier, double finishTime)
    195195{
     196    m_loadingFinished = true;
    196197    RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper = m_workerClientWrapper;
    197198    m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper, identifier, finishTime] (ScriptExecutionContext& context) {
     
    203204void WorkerThreadableLoader::MainThreadBridge::didFail(const ResourceError& error)
    204205{
     206    m_loadingFinished = true;
    205207    RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper = m_workerClientWrapper;
    206208    ResourceError* capturedError = new ResourceError(error.copy());
     
    215217void WorkerThreadableLoader::MainThreadBridge::didFailAccessControlCheck(const ResourceError& error)
    216218{
     219    m_loadingFinished = true;
    217220    RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper = m_workerClientWrapper;
    218221    ResourceError* capturedError = new ResourceError(error.copy());
     
    227230void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck()
    228231{
     232    m_loadingFinished = true;
    229233    RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper = m_workerClientWrapper;
    230234    m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper] (ScriptExecutionContext& context) {
  • trunk/Source/WebCore/loader/WorkerThreadableLoader.h

    r197563 r198891  
    112112            // Only to be used on the main thread.
    113113            RefPtr<ThreadableLoader> m_mainThreadLoader;
     114            bool m_loadingFinished { false };
    114115
    115116            // ThreadableLoaderClientWrapper is to be used on the worker context thread.
Note: See TracChangeset for help on using the changeset viewer.