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

Changeset 287633 in webkit


Ignore:
Timestamp:
Jan 5, 2022, 10:21:25 AM (5 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r287353. rdar://problem/87125345

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.

git-svn-id: ​https://svn.webkit.org/repository/webkit/trunk@287353 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-612-branch
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612-branch/LayoutTests/ChangeLog

    r287620 r287633  
     12022-01-05  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r287353. rdar://problem/87125345
     4
     5    Use requester when calling updateRequestAndAddExtraFields
     6    https://bugs.webkit.org/show_bug.cgi?id=234507
     7    <rdar://problem/85049490>
     8   
     9    Reviewed by Brent Fulgham.
     10   
     11    Source/WebCore:
     12   
     13    In case of navigation loads, the requester is the fetch request client.
     14    As such, it should be the one used to determine whether the request is cross-origin is not.
     15    Pass the requester to updateRequestAndAddExtraFields to do the correct computation.
     16    Validate that some request fields are now correctly observed in service workers.
     17   
     18    Test: http/wpt/service-workers/navigation-iframe-site.https.html
     19   
     20    * loader/FrameLoader.cpp:
     21    * loader/FrameLoader.h:
     22    * testing/ServiceWorkerInternals.cpp:
     23    * testing/ServiceWorkerInternals.h:
     24    * testing/ServiceWorkerInternals.idl:
     25   
     26    LayoutTests:
     27   
     28    * http/wpt/service-workers/navigation-iframe-site-worker.js: Added.
     29    * http/wpt/service-workers/navigation-iframe-site.https-expected.txt: Added.
     30    * http/wpt/service-workers/navigation-iframe-site.https.html: Added.
     31    * http/wpt/service-workers/resources/navigation-iframe-site-frame.html: Added.
     32   
     33    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287353 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     34
     35    2021-12-22  Youenn Fablet  <youenn@apple.com>
     36
     37            Use requester when calling updateRequestAndAddExtraFields
     38            https://bugs.webkit.org/show_bug.cgi?id=234507
     39            <rdar://problem/85049490>
     40
     41            Reviewed by Brent Fulgham.
     42
     43            * http/wpt/service-workers/navigation-iframe-site-worker.js: Added.
     44            * http/wpt/service-workers/navigation-iframe-site.https-expected.txt: Added.
     45            * http/wpt/service-workers/navigation-iframe-site.https.html: Added.
     46            * http/wpt/service-workers/resources/navigation-iframe-site-frame.html: Added.
     47
    1482022-01-05  Russell Epstein  <repstein@apple.com>
    249
  • branches/safari-612-branch/Source/WebCore/ChangeLog

    r287631 r287633  
     12022-01-05  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r287353. rdar://problem/87125345
     4
     5    Use requester when calling updateRequestAndAddExtraFields
     6    https://bugs.webkit.org/show_bug.cgi?id=234507
     7    <rdar://problem/85049490>
     8   
     9    Reviewed by Brent Fulgham.
     10   
     11    Source/WebCore:
     12   
     13    In case of navigation loads, the requester is the fetch request client.
     14    As such, it should be the one used to determine whether the request is cross-origin is not.
     15    Pass the requester to updateRequestAndAddExtraFields to do the correct computation.
     16    Validate that some request fields are now correctly observed in service workers.
     17   
     18    Test: http/wpt/service-workers/navigation-iframe-site.https.html
     19   
     20    * loader/FrameLoader.cpp:
     21    * loader/FrameLoader.h:
     22    * testing/ServiceWorkerInternals.cpp:
     23    * testing/ServiceWorkerInternals.h:
     24    * testing/ServiceWorkerInternals.idl:
     25   
     26    LayoutTests:
     27   
     28    * http/wpt/service-workers/navigation-iframe-site-worker.js: Added.
     29    * http/wpt/service-workers/navigation-iframe-site.https-expected.txt: Added.
     30    * http/wpt/service-workers/navigation-iframe-site.https.html: Added.
     31    * http/wpt/service-workers/resources/navigation-iframe-site-frame.html: Added.
     32   
     33    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287353 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     34
     35    2021-12-22  Youenn Fablet  <youenn@apple.com>
     36
     37            Use requester when calling updateRequestAndAddExtraFields
     38            https://bugs.webkit.org/show_bug.cgi?id=234507
     39            <rdar://problem/85049490>
     40
     41            Reviewed by Brent Fulgham.
     42
     43            In case of navigation loads, the requester is the fetch request client.
     44            As such, it should be the one used to determine whether the request is cross-origin is not.
     45            Pass the requester to updateRequestAndAddExtraFields to do the correct computation.
     46            Validate that some request fields are now correctly observed in service workers.
     47
     48            Test: http/wpt/service-workers/navigation-iframe-site.https.html
     49
     50            * loader/FrameLoader.cpp:
     51            * loader/FrameLoader.h:
     52            * testing/ServiceWorkerInternals.cpp:
     53            * testing/ServiceWorkerInternals.h:
     54            * testing/ServiceWorkerInternals.idl:
     55
    1562022-01-05  Russell Epstein  <repstein@apple.com>
    257
  • branches/safari-612-branch/Source/WebCore/loader/FrameLoader.cpp

    r286401 r287633  
    13571357        request.setHTTPReferrer(referrer);
    13581358
    1359     updateRequestAndAddExtraFields(request, IsMainResource::Yes, newLoadType);
     1359    updateRequestAndAddExtraFields(request, IsMainResource::Yes, newLoadType, ShouldUpdateAppInitiatedValue::Yes, FrameLoader::IsServiceWorkerNavigationLoad::No, &frameLoadRequest.requester());
    13601360
    13611361    ASSERT(newLoadType != FrameLoadType::Same);
    … …  
    29062906}
    29072907
    2908 void FrameLoader::updateRequestAndAddExtraFields(ResourceRequest& request, IsMainResource mainResource, FrameLoadType loadType, ShouldUpdateAppInitiatedValue shouldUpdate)
     2908void FrameLoader::updateRequestAndAddExtraFields(ResourceRequest& request, IsMainResource mainResource, FrameLoadType loadType, ShouldUpdateAppInitiatedValue shouldUpdate, Document* initiator)
    29092909{
    29102910    // If the request came from a previous process due to process-swap-on-navigation then we should not modify the request.
    … …  
    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);
    … …  
    30653067    workingResourceRequest.setHTTPBody(inRequest.httpBody());
    30663068    workingResourceRequest.setHTTPContentType(contentType);
    3067     updateRequestAndAddExtraFields(workingResourceRequest, IsMainResource::Yes, loadType);
     3069    updateRequestAndAddExtraFields(workingResourceRequest, IsMainResource::Yes, loadType, ShouldUpdateAppInitiatedValue::Yes, FrameLoader::IsServiceWorkerNavigationLoad::No, &request.requester());
    30683070
    30693071    if (Document* document = m_frame.document())
  • branches/safari-612-branch/Source/WebCore/loader/FrameLoader.h

    r286401 r287633  
    319319
    320320    // For subresource requests the FrameLoadType parameter has no effect and can be skipped.
    321     void updateRequestAndAddExtraFields(ResourceRequest&, IsMainResource, FrameLoadType = FrameLoadType::Standard, ShouldUpdateAppInitiatedValue = ShouldUpdateAppInitiatedValue::Yes);
     321    void updateRequestAndAddExtraFields(ResourceRequest&, IsMainResource, FrameLoadType = FrameLoadType::Standard, ShouldUpdateAppInitiatedValue = ShouldUpdateAppInitiatedValue::Yes, Document* = nullptr);
    322322
    323323    void scheduleRefreshIfNeeded(Document&, const String& content, IsMetaRefresh);
  • branches/safari-612-branch/Source/WebCore/testing/ServiceWorkerInternals.cpp

    r279750 r287633  
    137137}
    138138
     139bool ServiceWorkerInternals::fetchEventIsSameSite(FetchEvent& event)
     140{
     141    return event.request().internalRequest().isSameSite();
     142}
     143
    139144} // namespace WebCore
    140145
  • branches/safari-612-branch/Source/WebCore/testing/ServiceWorkerInternals.h

    r279750 r287633  
    6363    void lastNavigationWasAppInitiated(Ref<DeferredPromise>&&);
    6464
     65    bool fetchEventIsSameSite(FetchEvent&);
     66
    6567private:
    6668    explicit ServiceWorkerInternals(ServiceWorkerIdentifier);
  • branches/safari-612-branch/Source/WebCore/testing/ServiceWorkerInternals.idl

    r279750 r287633  
    4545
    4646    Promise<boolean> lastNavigationWasAppInitiated();
     47
     48    boolean fetchEventIsSameSite(FetchEvent event);
    4749};
Note: See TracChangeset for help on using the changeset viewer.