Changeset 286656 in webkit


Ignore:
Timestamp:
Dec 8, 2021 8:27:03 AM (7 months ago)
Author:
youenn@apple.com
Message:

Same-site lax cookies not sent by fetch event handler after page reload
https://bugs.webkit.org/show_bug.cgi?id=226386
<rdar://problem/78878853>

Reviewed by Chris Dumez.

Source/WebCore:

When a service worker fetches a navigation request exposed from the fetch event, we need to keep isTopSite intact as
the service worker does not really have the information of which frame is actually loaded and whether it is a main frame or not.

Tests: http/wpt/service-workers/cross-site-navigation-same-cookie-lax.https.html

http/wpt/service-workers/same-cookie-lax.https.html

  • loader/cache/CachedResource.cpp:

Source/WebKit:

StorageBlockingPolicy handling is not covered by generated code so explicit update StorageBlockingPolicy setting from preference store.
This impacts the computation of cookie/cache partitioning.

  • WebProcess/Storage/WebSWContextManagerConnection.cpp:

LayoutTests:

  • http/wpt/service-workers/cross-site-navigation-same-cookie-lax.https-expected.txt: Added.
  • http/wpt/service-workers/cross-site-navigation-same-cookie-lax.https.html: Added.
  • http/wpt/service-workers/resources/get-cookie.py: Added.
  • http/wpt/service-workers/resources/get-document-cookie.py: Added.
  • http/wpt/service-workers/resources/set-cookie-lax.py: Added.
  • http/wpt/service-workers/same-cookie-lax-worker.js: Added.
  • http/wpt/service-workers/same-cookie-lax.https-expected.txt: Added.
  • http/wpt/service-workers/same-cookie-lax.https.html: Added.
Location:
trunk
Files:
8 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286655 r286656  
     12021-12-08  Youenn Fablet  <youenn@apple.com>
     2
     3        Same-site lax cookies not sent by fetch event handler after page reload
     4        https://bugs.webkit.org/show_bug.cgi?id=226386
     5        <rdar://problem/78878853>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * http/wpt/service-workers/cross-site-navigation-same-cookie-lax.https-expected.txt: Added.
     10        * http/wpt/service-workers/cross-site-navigation-same-cookie-lax.https.html: Added.
     11        * http/wpt/service-workers/resources/get-cookie.py: Added.
     12        * http/wpt/service-workers/resources/get-document-cookie.py: Added.
     13        * http/wpt/service-workers/resources/set-cookie-lax.py: Added.
     14        * http/wpt/service-workers/same-cookie-lax-worker.js: Added.
     15        * http/wpt/service-workers/same-cookie-lax.https-expected.txt: Added.
     16        * http/wpt/service-workers/same-cookie-lax.https.html: Added.
     17
    1182021-12-08  Youenn Fablet  <youenn@apple.com>
    219
  • trunk/Source/WebCore/ChangeLog

    r286655 r286656  
     12021-12-08  Youenn Fablet  <youenn@apple.com>
     2
     3        Same-site lax cookies not sent by fetch event handler after page reload
     4        https://bugs.webkit.org/show_bug.cgi?id=226386
     5        <rdar://problem/78878853>
     6
     7        Reviewed by Chris Dumez.
     8
     9        When a service worker fetches a navigation request exposed from the fetch event, we need to keep isTopSite intact as
     10        the service worker does not really have the information of which frame is actually loaded and whether it is a main frame or not.
     11
     12        Tests: http/wpt/service-workers/cross-site-navigation-same-cookie-lax.https.html
     13               http/wpt/service-workers/same-cookie-lax.https.html
     14
     15        * loader/cache/CachedResource.cpp:
     16
    1172021-12-08  Youenn Fablet  <youenn@apple.com>
    218
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r285320 r286656  
    29002900}
    29012901
    2902 void FrameLoader::updateRequestAndAddExtraFields(ResourceRequest& request, IsMainResource mainResource, FrameLoadType loadType, ShouldUpdateAppInitiatedValue shouldUpdate)
    2903 {
     2902void FrameLoader::updateRequestAndAddExtraFields(ResourceRequest& request, IsMainResource mainResource, FrameLoadType loadType, ShouldUpdateAppInitiatedValue shouldUpdate, IsServiceWorkerNavigationLoad isServiceWorkerNavigationLoad)
     2903{
     2904    ASSERT(isServiceWorkerNavigationLoad == IsServiceWorkerNavigationLoad::No || mainResource != IsMainResource::Yes);
     2905
    29042906    // If the request came from a previous process due to process-swap-on-navigation then we should not modify the request.
    29052907    if (m_currentLoadContinuingState == LoadContinuingState::ContinuingWithRequest)
     
    29292931        addSameSiteInfoToRequestIfNeeded(request, initiator);
    29302932    }
    2931     request.setIsTopSite(isMainFrameMainResource);
     2933
     2934    // In case of service worker navigation load, we inherit isTopSite from the FetchEvent request directly.
     2935    if (isServiceWorkerNavigationLoad == IsServiceWorkerNavigationLoad::No)
     2936        request.setIsTopSite(isMainFrameMainResource);
    29322937
    29332938    Page* page = frame().page();
  • trunk/Source/WebCore/loader/FrameLoader.h

    r285320 r286656  
    318318    bool alwaysAllowLocalWebarchive() const { return m_alwaysAllowLocalWebarchive; }
    319319
     320    enum class IsServiceWorkerNavigationLoad : bool { No, Yes };
    320321    // For subresource requests the FrameLoadType parameter has no effect and can be skipped.
    321     void updateRequestAndAddExtraFields(ResourceRequest&, IsMainResource, FrameLoadType = FrameLoadType::Standard, ShouldUpdateAppInitiatedValue = ShouldUpdateAppInitiatedValue::Yes);
     322    void updateRequestAndAddExtraFields(ResourceRequest&, IsMainResource, FrameLoadType = FrameLoadType::Standard, ShouldUpdateAppInitiatedValue = ShouldUpdateAppInitiatedValue::Yes, IsServiceWorkerNavigationLoad = IsServiceWorkerNavigationLoad::No);
    322323
    323324    void scheduleRefreshIfNeeded(Document&, const String& content, IsMetaRefresh);
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r286419 r286656  
    242242    // Navigation algorithm is setting up the request before sending it to CachedResourceLoader?CachedResource.
    243243    // So no need for extra fields for MainResource.
    244     if (type() != Type::MainResource)
    245         frameLoader.updateRequestAndAddExtraFields(m_resourceRequest, IsMainResource::No);
     244    if (type() != Type::MainResource) {
     245        bool isServiceWorkerNavigationLoad = type() != Type::SVGDocumentResource && m_options.serviceWorkersMode == ServiceWorkersMode::None && (m_options.destination == FetchOptions::Destination::Document || m_options.destination == FetchOptions::Destination::Iframe);
     246        frameLoader.updateRequestAndAddExtraFields(m_resourceRequest, IsMainResource::No, FrameLoadType::Standard, ShouldUpdateAppInitiatedValue::Yes, isServiceWorkerNavigationLoad ? FrameLoader::IsServiceWorkerNavigationLoad::Yes : FrameLoader::IsServiceWorkerNavigationLoad::No);
     247    }
    246248
    247249    // FIXME: It's unfortunate that the cache layer and below get to know anything about fragment identifiers.
  • trunk/Source/WebKit/ChangeLog

    r286650 r286656  
     12021-12-08  Youenn Fablet  <youenn@apple.com>
     2
     3        Same-site lax cookies not sent by fetch event handler after page reload
     4        https://bugs.webkit.org/show_bug.cgi?id=226386
     5        <rdar://problem/78878853>
     6
     7        Reviewed by Chris Dumez.
     8
     9        StorageBlockingPolicy handling is not covered by generated code so explicit update StorageBlockingPolicy setting from preference store.
     10        This impacts the computation of cookie/cache partitioning.
     11
     12        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
     13
    1142021-12-08  Youenn Fablet  <youenn@apple.com>
    215
  • trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp

    r286455 r286656  
    168168    auto lastNavigationWasAppInitiated = contextData.lastNavigationWasAppInitiated;
    169169    auto page = makeUniqueRef<Page>(WTFMove(pageConfiguration));
    170     if (m_preferencesStore)
     170    if (m_preferencesStore) {
    171171        WebPage::updateSettingsGenerated(*m_preferencesStore, page->settings());
     172        page->settings().setStorageBlockingPolicy(static_cast<StorageBlockingPolicy>(m_preferencesStore->getUInt32ValueForKey(WebPreferencesKey::storageBlockingPolicyKey())));
     173    }
    172174    ServiceWorkerThreadProxy::setupPageForServiceWorker(page.get(), contextData);
    173175    auto serviceWorkerThreadProxy = ServiceWorkerThreadProxy::create(WTFMove(page), WTFMove(contextData), WTFMove(workerData), WTFMove(effectiveUserAgent), workerThreadMode, WebProcess::singleton().cacheStorageProvider());
Note: See TracChangeset for help on using the changeset viewer.