Changeset 228930 in webkit


Ignore:
Timestamp:
Feb 22, 2018 12:42:54 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Fetch event release assert should take into account the fetch mode
https://bugs.webkit.org/show_bug.cgi?id=183047

Patch by Youenn Fablet <youenn@apple.com> on 2018-02-22
Reviewed by Chris Dumez.

In case of navigation tasks, we should use the request URL and not the origin of the loading client.

  • WebProcess/Storage/WebSWContextManagerConnection.cpp:

(WebKit::isValidFetch):
(WebKit::WebSWContextManagerConnection::startFetch):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r228929 r228930  
     12018-02-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Fetch event release assert should take into account the fetch mode
     4        https://bugs.webkit.org/show_bug.cgi?id=183047
     5
     6        Reviewed by Chris Dumez.
     7
     8        In case of navigation tasks, we should use the request URL and not the origin of the loading client.
     9
     10        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
     11        (WebKit::isValidFetch):
     12        (WebKit::WebSWContextManagerConnection::startFetch):
     13
    1142018-02-22  Yousuke Kimoto  <yousuke.kimoto@sony.com>
    215
  • trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp

    r228919 r228930  
    181181}
    182182
     183static inline bool isValidFetch(const ResourceRequest& request, const FetchOptions& options, const URL& serviceWorkerURL, const String& referrer)
     184{
     185    // For exotic service workers, do not enforce checks.
     186    if (!serviceWorkerURL.protocolIsInHTTPFamily())
     187        return true;
     188
     189    if (options.mode == FetchOptions::Mode::Navigate)
     190        return protocolHostAndPortAreEqual(request.url(), serviceWorkerURL);
     191
     192    String origin = request.httpOrigin();
     193    URL url { URL(), origin.isEmpty() ? referrer : origin };
     194    if (!url.protocolIsInHTTPFamily())
     195        return true;
     196
     197    return protocolHostAndPortAreEqual(url, serviceWorkerURL);
     198}
     199
    183200void WebSWContextManagerConnection::startFetch(SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options, IPC::FormDataReference&& formData, String&& referrer)
    184201{
     
    189206    }
    190207
    191     String origin = request.httpOrigin();
    192     URL url { URL(), origin.isEmpty() ? referrer : origin };
    193     URL serviceWorkerURL = serviceWorkerThreadProxy->scriptURL();
    194     RELEASE_ASSERT(!url.protocolIsInHTTPFamily() || !serviceWorkerURL.protocolIsInHTTPFamily() || protocolHostAndPortAreEqual(url, serviceWorkerURL));
     208    RELEASE_ASSERT(isValidFetch(request, options, serviceWorkerThreadProxy->scriptURL(), referrer));
    195209
    196210    auto client = WebServiceWorkerFetchTaskClient::create(m_connectionToStorageProcess.copyRef(), serviceWorkerIdentifier, serverConnectionIdentifier, fetchIdentifier);
Note: See TracChangeset for help on using the changeset viewer.