⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287353 in webkit


Ignore:
Timestamp:
Dec 22, 2021, 2:13:07 AM (5 years ago)
Author:
youenn@apple.com
Message:

Use requester when calling updateRequestAndAddExtraFields
​https://bugs.webkit.org/show_bug.cgi?id=234507
<rdar://problem/85049490>

Reviewed by Brent Fulgham.

Source/WebCore:

In case of navigation loads, the requester is the fetch request client.
As such, it should be the one used to determine whether the request is cross-origin is not.
Pass the requester to updateRequestAndAddExtraFields to do the correct computation.
Validate that some request fields are now correctly observed in service workers.

Test: http/wpt/service-workers/navigation-iframe-site.https.html

  • loader/FrameLoader.cpp:
  • loader/FrameLoader.h:
  • testing/ServiceWorkerInternals.cpp:
  • testing/ServiceWorkerInternals.h:
  • testing/ServiceWorkerInternals.idl:

LayoutTests:

  • http/wpt/service-workers/navigation-iframe-site-worker.js: Added.
  • http/wpt/service-workers/navigation-iframe-site.https-expected.txt: Added.
  • http/wpt/service-workers/navigation-iframe-site.https.html: Added.
  • http/wpt/service-workers/resources/navigation-iframe-site-frame.html: Added.
Location:
trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r287351 r287353  
     12021-12-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Use requester when calling updateRequestAndAddExtraFields
     4        https://bugs.webkit.org/show_bug.cgi?id=234507
     5        <rdar://problem/85049490>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * http/wpt/service-workers/navigation-iframe-site-worker.js: Added.
     10        * http/wpt/service-workers/navigation-iframe-site.https-expected.txt: Added.
     11        * http/wpt/service-workers/navigation-iframe-site.https.html: Added.
     12        * http/wpt/service-workers/resources/navigation-iframe-site-frame.html: Added.
     13
    1142021-12-22  Arcady Goldmints-Orlov  <agoldmints@igalia.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r287350 r287353  
     12021-12-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Use requester when calling updateRequestAndAddExtraFields
     4        https://bugs.webkit.org/show_bug.cgi?id=234507
     5        <rdar://problem/85049490>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        In case of navigation loads, the requester is the fetch request client.
     10        As such, it should be the one used to determine whether the request is cross-origin is not.
     11        Pass the requester to updateRequestAndAddExtraFields to do the correct computation.
     12        Validate that some request fields are now correctly observed in service workers.
     13
     14        Test: http/wpt/service-workers/navigation-iframe-site.https.html
     15
     16        * loader/FrameLoader.cpp:
     17        * loader/FrameLoader.h:
     18        * testing/ServiceWorkerInternals.cpp:
     19        * testing/ServiceWorkerInternals.h:
     20        * testing/ServiceWorkerInternals.idl:
     21
    1222021-12-22  Philippe Normand  <pnormand@igalia.com>
    223
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r287348 r287353  
    13431343        request.setHTTPReferrer(referrer);
    13441344
    1345     updateRequestAndAddExtraFields(request, IsMainResource::Yes, newLoadType);
     1345    updateRequestAndAddExtraFields(request, IsMainResource::Yes, newLoadType, ShouldUpdateAppInitiatedValue::Yes, FrameLoader::IsServiceWorkerNavigationLoad::No, &frameLoadRequest.requester());
    13461346
    13471347    ASSERT(newLoadType != FrameLoadType::Same);
    … …  
    29042904}
    29052905
    2906 void FrameLoader::updateRequestAndAddExtraFields(ResourceRequest& request, IsMainResource mainResource, FrameLoadType loadType, ShouldUpdateAppInitiatedValue shouldUpdate, IsServiceWorkerNavigationLoad isServiceWorkerNavigationLoad)
     2906void FrameLoader::updateRequestAndAddExtraFields(ResourceRequest& request, IsMainResource mainResource, FrameLoadType loadType, ShouldUpdateAppInitiatedValue shouldUpdate, IsServiceWorkerNavigationLoad isServiceWorkerNavigationLoad, Document* initiator)
    29072907{
    29082908    ASSERT(isServiceWorkerNavigationLoad == IsServiceWorkerNavigationLoad::No || mainResource != IsMainResource::Yes);
    … …  
    29242924
    29252925    if (request.isSameSiteUnspecified()) {
    2926         auto* initiator = m_frame.document();
    2927         if (isMainResource) {
    2928             auto* ownerFrame = m_frame.tree().parent();
    2929             if (!ownerFrame && m_stateMachine.isDisplayingInitialEmptyDocument())
    2930                 ownerFrame = m_opener.get();
    2931             if (ownerFrame)
    2932                 initiator = ownerFrame->document();
    2933             ASSERT(ownerFrame || m_frame.isMainFrame());
     2926        if (!initiator) {
     2927            initiator = m_frame.document();
     2928            if (isMainResource) {
     2929                auto* ownerFrame = m_frame.tree().parent();
     2930                if (!ownerFrame && m_stateMachine.isDisplayingInitialEmptyDocument())
     2931                    ownerFrame = m_opener.get();
     2932                if (ownerFrame)
     2933                    initiator = ownerFrame->document();
     2934                ASSERT(ownerFrame || m_frame.isMainFrame());
     2935            }
    29342936        }
    29352937        addSameSiteInfoToRequestIfNeeded(request, initiator);
    … …  
    30683070    workingResourceRequest.setHTTPBody(inRequest.httpBody());
    30693071    workingResourceRequest.setHTTPContentType(contentType);
    3070     updateRequestAndAddExtraFields(workingResourceRequest, IsMainResource::Yes, loadType);
     3072    updateRequestAndAddExtraFields(workingResourceRequest, IsMainResource::Yes, loadType, ShouldUpdateAppInitiatedValue::Yes, FrameLoader::IsServiceWorkerNavigationLoad::No, &request.requester());
    30713073
    30723074    if (Document* document = m_frame.document())
  • trunk/Source/WebCore/loader/FrameLoader.h

    r287021 r287353  
    320320    enum class IsServiceWorkerNavigationLoad : bool { No, Yes };
    321321    // For subresource requests the FrameLoadType parameter has no effect and can be skipped.
    322     void updateRequestAndAddExtraFields(ResourceRequest&, IsMainResource, FrameLoadType = FrameLoadType::Standard, ShouldUpdateAppInitiatedValue = ShouldUpdateAppInitiatedValue::Yes, IsServiceWorkerNavigationLoad = IsServiceWorkerNavigationLoad::No);
     322    void updateRequestAndAddExtraFields(ResourceRequest&, IsMainResource, FrameLoadType = FrameLoadType::Standard, ShouldUpdateAppInitiatedValue = ShouldUpdateAppInitiatedValue::Yes, IsServiceWorkerNavigationLoad = IsServiceWorkerNavigationLoad::No, Document* = nullptr);
    323323
    324324    void scheduleRefreshIfNeeded(Document&, const String& content, IsMetaRefresh);
  • trunk/Source/WebCore/testing/ServiceWorkerInternals.cpp

    r286044 r287353  
    189189}
    190190
     191bool ServiceWorkerInternals::fetchEventIsSameSite(FetchEvent& event)
     192{
     193    return event.request().internalRequest().isSameSite();
     194}
     195
    191196} // namespace WebCore
    192197
  • trunk/Source/WebCore/testing/ServiceWorkerInternals.h

    r286044 r287353  
    7070    RefPtr<PushSubscription> createPushSubscription(const String& endpoint, std::optional<EpochTimeStamp> expirationTime, const ArrayBuffer& serverVAPIDPublicKey, const ArrayBuffer& clientECDHPublicKey, const ArrayBuffer& auth);
    7171
     72    bool fetchEventIsSameSite(FetchEvent&);
     73
    7274private:
    7375    explicit ServiceWorkerInternals(ServiceWorkerIdentifier);
  • trunk/Source/WebCore/testing/ServiceWorkerInternals.idl

    r286044 r287353  
    5050   
    5151    PushSubscription createPushSubscription(USVString endpoint, EpochTimeStamp? expirationTime, ArrayBuffer serverVAPIDPublicKey, ArrayBuffer clientECDHPublicKey, ArrayBuffer auth);
     52
     53    boolean fetchEventIsSameSite(FetchEvent event);
    5254};
Note: See TracChangeset for help on using the changeset viewer.