Changeset 224059 in webkit


Ignore:
Timestamp:
Oct 26, 2017 3:57:29 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Add service worker handle fetch support for all subresource requests
https://bugs.webkit.org/show_bug.cgi?id=178769

Patch by Youenn Fablet <youenn@apple.com> on 2017-10-26
Reviewed by Chris Dumez.

Source/WebCore:

Test: http/tests/workers/service/image-fetch.html

Moving DocumentThreadableLoader logic to CachedResourceLoader to apply it for all resource loads.
Setting the selected service worker identifier for subresource only at the moment.

Testing is limited to images, future wpt tests should cover other subresource cases.

  • loader/DocumentThreadableLoader.cpp:

(WebCore::DocumentThreadableLoader::DocumentThreadableLoader):

  • loader/cache/CachedResourceLoader.cpp:

(WebCore::CachedResourceLoader::prepareFetch):

  • loader/cache/CachedResourceRequest.cpp:

(WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded):

  • loader/cache/CachedResourceRequest.h:

LayoutTests:

  • http/tests/workers/service/image-fetch-expected.txt: Added.
  • http/tests/workers/service/image-fetch.html: Added.
  • http/tests/workers/service/resources/image-fetch-worker.js: Added.

(event.event.request.url.indexOf):
(event.event.request.url.endsWith):

  • http/tests/workers/service/resources/image-fetch.js: Added.

(done):
(async.loadedImage):
(async.erroredImage):
(async.logStatus):
(async.test):

Location:
trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r224052 r224059  
     12017-10-26  Youenn Fablet  <youenn@apple.com>
     2
     3        Add service worker handle fetch support for all subresource requests
     4        https://bugs.webkit.org/show_bug.cgi?id=178769
     5
     6        Reviewed by Chris Dumez.
     7
     8        * http/tests/workers/service/image-fetch-expected.txt: Added.
     9        * http/tests/workers/service/image-fetch.html: Added.
     10        * http/tests/workers/service/resources/image-fetch-worker.js: Added.
     11        (event.event.request.url.indexOf):
     12        (event.event.request.url.endsWith):
     13        * http/tests/workers/service/resources/image-fetch.js: Added.
     14        (done):
     15        (async.loadedImage):
     16        (async.erroredImage):
     17        (async.logStatus):
     18        (async.test):
     19
    1202017-10-26  Ryosuke Niwa  <rniwa@webkit.org>
    221
  • trunk/Source/WebCore/ChangeLog

    r224057 r224059  
     12017-10-26  Youenn Fablet  <youenn@apple.com>
     2
     3        Add service worker handle fetch support for all subresource requests
     4        https://bugs.webkit.org/show_bug.cgi?id=178769
     5
     6        Reviewed by Chris Dumez.
     7
     8        Test: http/tests/workers/service/image-fetch.html
     9
     10        Moving DocumentThreadableLoader logic to CachedResourceLoader to apply it for all resource loads.
     11        Setting the selected service worker identifier for subresource only at the moment.
     12
     13        Testing is limited to images, future wpt tests should cover other subresource cases.
     14
     15        * loader/DocumentThreadableLoader.cpp:
     16        (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
     17        * loader/cache/CachedResourceLoader.cpp:
     18        (WebCore::CachedResourceLoader::prepareFetch):
     19        * loader/cache/CachedResourceRequest.cpp:
     20        (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded):
     21        * loader/cache/CachedResourceRequest.h:
     22
    1232017-10-26  Eric Carlson  <eric.carlson@apple.com>
    224
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp

    r224025 r224059  
    104104    relaxAdoptionRequirement();
    105105
    106 #if ENABLE(SERVICE_WORKER)
    107     if (m_options.serviceWorkersMode == ServiceWorkersMode::All && !m_options.serviceWorkerIdentifier)
    108         m_options.serviceWorkerIdentifier = document.selectedServiceWorkerIdentifier();
    109 #endif
    110 
    111106    // Setting a referrer header is only supported in the async code path.
    112107    ASSERT(m_async || m_referrer.isEmpty());
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r224024 r224059  
    687687{
    688688    // Implementing step 1 to 7 of https://fetch.spec.whatwg.org/#fetching
    689 
    690     if (!request.origin() && document())
    691         request.setOrigin(document()->securityOrigin());
     689    auto* document = this->document();
     690
     691    if (document) {
     692        if (!request.origin())
     693            request.setOrigin(document->securityOrigin());
     694#if ENABLE(SERVICE_WORKER)
     695        request.setSelectedServiceWorkerIdentifierIfNeeded(document->selectedServiceWorkerIdentifier());
     696#endif
     697    }
    692698
    693699    request.setAcceptHeaderIfNone(type);
  • trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp

    r224024 r224059  
    274274}
    275275
     276#if ENABLE(SERVICE_WORKER)
     277void CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded(uint64_t serviceWorkerIdentifier)
     278{
     279    if (isNonSubresourceRequest(m_options.destination))
     280        return;
     281    if (isPotentialNavigationOrSubresourceRequest(m_options.destination))
     282        return;
     283
     284    if (m_options.serviceWorkersMode != ServiceWorkersMode::All)
     285        return;
     286    if (m_options.serviceWorkerIdentifier)
     287        return;
     288
     289    m_options.serviceWorkerIdentifier = serviceWorkerIdentifier;
     290}
     291#endif
     292
    276293} // namespace WebCore
  • trunk/Source/WebCore/loader/cache/CachedResourceRequest.h

    r224024 r224059  
    9696    static String splitFragmentIdentifierFromRequestURL(ResourceRequest&);
    9797
     98#if ENABLE(SERVICE_WORKER)
     99    void setSelectedServiceWorkerIdentifierIfNeeded(uint64_t serviceWorkerIdentifier);
     100#endif
     101
    98102private:
    99103    ResourceRequest m_resourceRequest;
  • trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp

    r224024 r224059  
    6565        return false;
    6666
    67     // FIXME: We should probably assert that options.serviceWorkersIdentifier is not null.
    6867    if (isPotentialNavigationOrSubresourceRequest(options.destination))
    6968        return false;
    7069
    7170    // FIXME: Implement non-subresource request loads.
    72     if (isNonSubresourceRequest(options.destination))
     71    if (isNonSubresourceRequest(options.destination) || !options.serviceWorkerIdentifier)
    7372        return false;
    7473
Note: See TracChangeset for help on using the changeset viewer.