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

Changeset 236130 in webkit


Ignore:
Timestamp:
Sep 18, 2018, 8:39:30 AM (8 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r235569 - Storage Access API: Maintain access through same-site navigations
https://bugs.webkit.org/show_bug.cgi?id=188564
<rdar://problem/43445160>

Reviewed by Alex Christensen.

Source/WebCore:

Tests: http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access.html

http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html

  • dom/Document.h:

Removed unused member variable m_hasFrameSpecificStorageAccess.

  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::willSendRequest):

  • loader/FrameLoaderClient.h:

Source/WebKit:

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::dispatchWillChangeDocument):

Now takes the current URL and the new URL as parameters
and only clears out storage access if the navigation is
cross-site, i.e. with differing eTLD+1s.

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.h:

LayoutTests:

  • http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-user-interaction-and-access-from-right-frame-expected.txt:
  • http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-user-interaction-and-access-from-right-frame.html:

Added both a same-site and a cross-site navigation to the sub frame to test maintained and cleared access.

  • http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access-expected.txt: Copied from LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt.
  • http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access.html: Copied from LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html.
  • http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access-expected.txt: Renamed from LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt.
  • http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html: Renamed from LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html.
  • http/tests/storageAccess/resources/get-cookies.php:

Support for the new test scenarios.

  • http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html:

Support for the new test scenarios.

  • platform/mac-wk2/TestExpectations:

Marked the new and the renamed tests as [ Pass ].

Location:
releases/WebKitGTK/webkit-2.22
Files:
13 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.22/LayoutTests/ChangeLog

    r236120 r236130  
     12018-08-31  John Wilander  <wilander@apple.com>
     2
     3        Storage Access API: Maintain access through same-site navigations
     4        https://bugs.webkit.org/show_bug.cgi?id=188564
     5        <rdar://problem/43445160>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-user-interaction-and-access-from-right-frame-expected.txt:
     10        * http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-user-interaction-and-access-from-right-frame.html:
     11            Added both a same-site and a cross-site navigation to the sub frame to test maintained and cleared access.
     12        * http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access-expected.txt: Copied from LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt.
     13        * http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access.html: Copied from LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html.
     14        * http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access-expected.txt: Renamed from LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt.
     15        * http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html: Renamed from LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html.
     16        * http/tests/storageAccess/resources/get-cookies.php:
     17            Support for the new test scenarios.
     18        * http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html:
     19            Support for the new test scenarios.
     20        * platform/mac-wk2/TestExpectations:
     21            Marked the new and the renamed tests as [ Pass ].
     22
    1232018-08-30  Zalan Bujtas  <zalan@apple.com>
    224
  • releases/WebKitGTK/webkit-2.22/LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-user-interaction-and-access-from-right-frame-expected.txt

    r234440 r236130  
    55
    66PASS Storage access was granted. document.cookie == firstPartyCookie=value, cookies seen server-side == {"firstPartyCookie":"value"}
     7Did navigate iframe same-site and will now check that it still has storage access.
     8PASS document.cookie == firstPartyCookie=value, cookies seen server-side == {"firstPartyCookie":"value"}
    79PASS successfullyParsed is true
    810
     
    4345Frame: '<!--frame5-->'
    4446--------
    45 After the top frame navigates the sub frame, the sub frame should no longer have access to cookies.
     47After the top frame navigates the sub frame cross-site and back, the sub frame should no longer have access to cookies.
    4648Did not receive cookie named 'firstPartyCookie'.
    4749Did not receive cookie named 'partitionedCookie'.
  • releases/WebKitGTK/webkit-2.22/LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-user-interaction-and-access-from-right-frame.html

    r234440 r236130  
    120120                case "#step7":
    121121                    document.location.hash = "step8";
    122                     // Check that no cookie gets sent for localhost under 127.0.0.1 since we're opening in the frame that was granted access.
    123                     let existingIframe = document.getElementById("TheIframeThatRequestsStorageAccess");
    124                     existingIframe.onload = runTest;
    125                     existingIframe.src = thirdPartyBaseUrl + subPathToGetCookies + "&message=After the top frame navigates the sub frame, the sub frame should no longer have access to cookies.";
     122                    // Navigate the frame same-site.
     123                    let existingIframe1 = document.getElementById("TheIframeThatRequestsStorageAccess");
     124                    existingIframe1.onload = function () {
     125                        debug("Did navigate iframe same-site and will now check that it still has storage access.");
     126                        let iframe = document.getElementById("TheIframeThatRequestsStorageAccess");
     127                        iframe.contentWindow.postMessage("reportBackCookies", "http://localhost:8000");
     128                    };
     129                    existingIframe1.src = thirdPartyBaseUrl + subPathToGetCookies;
    126130                    break;
    127131                case "#step8":
     132                    document.location.hash = "step9";
     133                    // Navigate the frame cross-site. This should clear out storage access.
     134                    let existingIframe2 = document.getElementById("TheIframeThatRequestsStorageAccess");
     135                    existingIframe2.onload = runTest;
     136                    existingIframe2.src = "http://" + partitionHost;
     137                    break;
     138                case "#step9":
     139                    document.location.hash = "step10";
     140                    // Again open localhost in the existing frame and check that no cookie gets sent for localhost under 127.0.0.1 since it has been navigated cross-site.
     141                    let existingIframe3 = document.getElementById("TheIframeThatRequestsStorageAccess");
     142                    existingIframe3.onload = runTest;
     143                    existingIframe3.src = thirdPartyBaseUrl + subPathToGetCookies + "&message=After the top frame navigates the sub frame cross-site and back, the sub frame should no longer have access to cookies.";
     144                    break;
     145                case "#step10":
    128146                    setEnableFeature(false, finishJSTest);
    129147                    break;
  • releases/WebKitGTK/webkit-2.22/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access-expected.txt

    r236129 r236130  
    1 Tests that a cross-origin iframe from a prevalent domain that is granted storage access and then navigates itself does not have storage access.
     1Tests that a cross-origin iframe from a prevalent domain that is granted storage access and then navigates itself cross-site does not have storage access.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
  • releases/WebKitGTK/webkit-2.22/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access.html

    r236129 r236130  
    66    <script src="/resourceLoadStatistics/resources/util.js"></script>
    77    <script>
    8         description("Tests that a cross-origin iframe from a prevalent domain that is granted storage access and then navigates itself does not have storage access.");
     8        description("Tests that a cross-origin iframe from a prevalent domain that is granted storage access and then navigates itself cross-site does not have storage access.");
    99        jsTestIsAsync = true;
    1010
     
    6464        if (document.location.hash !== "#firstPartyCookieSet") {
    6565            setEnableFeature(true, function() {
    66                 document.location.href = statisticsUrl + "/storageAccess/resources/set-cookie.php?name=firstPartyCookie&value=value#http://127.0.0.1:8000/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html#firstPartyCookieSet";
     66                document.location.href = statisticsUrl + "/storageAccess/resources/set-cookie.php?name=firstPartyCookie&value=value#http://127.0.0.1:8000/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access.html#firstPartyCookieSet";
    6767            });
    6868        } else {
     
    7878                        iframeElement.onload = runTest;
    7979                        iframeElement.id = "TheIframeThatRequestsStorageAccess";
    80                         iframeElement.src = "http://localhost:8000/storageAccess/resources/self-navigating-frame-after-granted-access.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldGrantAccess";
     80                        iframeElement.src = "http://localhost:8000/storageAccess/resources/self-navigating-frame-after-granted-access.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldGrantAccess,crossSiteNavigation";
    8181                        document.body.appendChild(iframeElement);
    8282                    });
  • releases/WebKitGTK/webkit-2.22/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access-expected.txt

    r236129 r236130  
    1 Tests that a cross-origin iframe from a prevalent domain that is granted storage access and then navigates itself does not have storage access.
     1Tests that a cross-origin iframe from a prevalent domain that is granted storage access and then navigates itself same-site still has storage access.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
     
    77PASS Storage access was granted.
    88PASS document.cookie == cookieSetClientSideAfterGrantedStorageAccess=value; firstPartyCookie=value
    9 PASS No storage access. document.cookie == , cookies seen server-side == "No cookies"
     9PASS Has storage access. document.cookie == cookieSetClientSideAfterGrantedStorageAccess=value; firstPartyCookie=value, cookies seen server-side == {"cookieSetClientSideAfterGrantedStorageAccess":"value","firstPartyCookie":"value"}
    1010PASS successfullyParsed is true
    1111
  • releases/WebKitGTK/webkit-2.22/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html

    r236129 r236130  
    66    <script src="/resourceLoadStatistics/resources/util.js"></script>
    77    <script>
    8         description("Tests that a cross-origin iframe from a prevalent domain that is granted storage access and then navigates itself does not have storage access.");
     8        description("Tests that a cross-origin iframe from a prevalent domain that is granted storage access and then navigates itself same-site still has storage access.");
    99        jsTestIsAsync = true;
    1010
     
    6464        if (document.location.hash !== "#firstPartyCookieSet") {
    6565            setEnableFeature(true, function() {
    66                 document.location.href = statisticsUrl + "/storageAccess/resources/set-cookie.php?name=firstPartyCookie&value=value#http://127.0.0.1:8000/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html#firstPartyCookieSet";
     66                document.location.href = statisticsUrl + "/storageAccess/resources/set-cookie.php?name=firstPartyCookie&value=value#http://127.0.0.1:8000/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html#firstPartyCookieSet";
    6767            });
    6868        } else {
     
    7878                        iframeElement.onload = runTest;
    7979                        iframeElement.id = "TheIframeThatRequestsStorageAccess";
    80                         iframeElement.src = "http://localhost:8000/storageAccess/resources/self-navigating-frame-after-granted-access.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldGrantAccess";
     80                        iframeElement.src = "http://localhost:8000/storageAccess/resources/self-navigating-frame-after-granted-access.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldGrantAccess,sameSiteNavigation";
    8181                        document.body.appendChild(iframeElement);
    8282                    });
  • releases/WebKitGTK/webkit-2.22/LayoutTests/http/tests/storageAccess/resources/get-cookies.php

    r225006 r236130  
    2222<script>
    2323    document.getElementById("output").textContent = "Client-side document.cookie: " + document.cookie;
     24
     25    function messageToTop(messagePrefix, fetchData) {
     26        top.postMessage(messagePrefix + " document.cookie == " + document.cookie +
     27            (fetchData ? ", cookies seen server-side == " + JSON.stringify(fetchData) : ""), "http://127.0.0.1:8000");
     28    }
     29
     30    function receiveMessage(event) {
     31        if (event.origin === "http://127.0.0.1:8000") {
     32            if (event.data.indexOf("reportBackCookies") !== -1) {
     33                fetch("echo-incoming-cookies-as-json.php", { credentials: "same-origin" }).then(function(response) {
     34                    return response.json();
     35                }).then(function(data) {
     36                    messageToTop("PASS", data);
     37                }).catch(function(error) {
     38                    console.log(error.message);
     39                });
     40            } else {
     41                messageToTop("FAIL Unknown request.");
     42            }
     43        } else {
     44            messageToTop("Fail Received a message from an unexpected origin: " + event.origin);
     45        }
     46    }
     47
     48    window.addEventListener("message", receiveMessage, false);
    2449</script>
  • releases/WebKitGTK/webkit-2.22/LayoutTests/http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html

    r226235 r236130  
    66        const userShouldBeConsulted = hashArguments[1] === "userShouldBeConsulted";
    77        const policyShouldGrantAccess = hashArguments[2] === "policyShouldGrantAccess";
     8        const sameSiteNavigation = hashArguments[3] === "sameSiteNavigation";
    89
    910        if (internals && userShouldGrantAccess)
     
    2728
    2829        function navigate() {
    29             document.location.href = "http://localhost:8000/storageAccess/resources/has-storage-access-iframe.html#policyShouldNotGrantAccess"
     30            if (sameSiteNavigation) {
     31                document.location.href = "http://localhost:8000/storageAccess/resources/has-storage-access-iframe.html#policyShouldGrantAccess";
     32            } else {
     33                document.location.href = "http://127.0.0.1:8000/resourceLoadStatistics/resources/redirect.php?redirectTo=http://localhost:8000/storageAccess/resources/has-storage-access-iframe.html";
     34            }
    3035        }
    3136
  • releases/WebKitGTK/webkit-2.22/LayoutTests/platform/mac-wk2/TestExpectations

    r234756 r236130  
    708708[ HighSierra+ ] http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-user-interaction.html [ Pass ]
    709709[ HighSierra+ ] http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html [ Pass ]
    710 [ HighSierra+ ] http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html [ Pass ]
     710[ HighSierra+ ] http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access.html [ Pass ]
     711[ HighSierra+ ] http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html [ Pass ]
    711712[ HighSierra+ ] http/tests/storageAccess/deny-storage-access-under-opener.html [ Pass ]
    712713[ HighSierra+ ] http/tests/storageAccess/grant-storage-access-under-opener.html [ Pass ]
  • releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog

    r236129 r236130  
     12018-08-31  John Wilander  <wilander@apple.com>
     2
     3        Storage Access API: Maintain access through same-site navigations
     4        https://bugs.webkit.org/show_bug.cgi?id=188564
     5        <rdar://problem/43445160>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Tests: http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access.html
     10               http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html
     11
     12        * dom/Document.h:
     13            Removed unused member variable m_hasFrameSpecificStorageAccess.
     14        * loader/DocumentLoader.cpp:
     15        (WebCore::DocumentLoader::willSendRequest):
     16        * loader/FrameLoaderClient.h:
     17
    1182018-08-31  Chris Dumez  <cdumez@apple.com>
    219
  • releases/WebKitGTK/webkit-2.22/Source/WebCore/dom/Document.h

    r236118 r236130  
    19801980    static bool hasEverCreatedAnAXObjectCache;
    19811981
    1982     bool m_hasFrameSpecificStorageAccess { false };
    19831982    bool m_grantStorageAccessOverride { false };
    19841983
  • releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/DocumentLoader.cpp

    r235061 r236130  
    601601
    602602    if (!didReceiveRedirectResponse)
    603         frameLoader()->client().dispatchWillChangeDocument();
     603        frameLoader()->client().dispatchWillChangeDocument(m_frame->document()->url(), newRequest.url());
    604604
    605605    // If we're fielding a redirect in response to a POST, force a load from origin, since
  • releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/FrameLoaderClient.h

    r236129 r236130  
    165165    virtual void dispatchWillPerformClientRedirect(const URL&, double interval, WallTime fireDate) = 0;
    166166    virtual void dispatchDidChangeMainDocument() { }
    167     virtual void dispatchWillChangeDocument() { }
     167    virtual void dispatchWillChangeDocument(const URL&, const URL&) { }
    168168    virtual void dispatchDidNavigateWithinPage() { }
    169169    virtual void dispatchDidChangeLocationWithinPage() = 0;
  • releases/WebKitGTK/webkit-2.22/Source/WebKit/ChangeLog

    r236129 r236130  
     12018-08-31  John Wilander  <wilander@apple.com>
     2
     3        Storage Access API: Maintain access through same-site navigations
     4        https://bugs.webkit.org/show_bug.cgi?id=188564
     5        <rdar://problem/43445160>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     10        (WebKit::WebFrameLoaderClient::dispatchWillChangeDocument):
     11            Now takes the current URL and the new URL as parameters
     12            and only clears out storage access if the navigation is
     13            cross-site, i.e. with differing eTLD+1s.
     14        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
     15
    1162018-08-31  Chris Dumez  <cdumez@apple.com>
    217
  • releases/WebKitGTK/webkit-2.22/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r236129 r236130  
    8484#include <WebCore/ProgressTracker.h>
    8585#include <WebCore/ResourceError.h>
     86#include <WebCore/ResourceRequest.h>
    8687#include <WebCore/ScriptController.h>
    8788#include <WebCore/SecurityOriginData.h>
     
    384385}
    385386
    386 void WebFrameLoaderClient::dispatchWillChangeDocument()
     387void WebFrameLoaderClient::dispatchWillChangeDocument(const URL& currentUrl, const URL& newUrl)
    387388{
    388389#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     
    394395        return;
    395396
    396     if (m_hasFrameSpecificStorageAccess) {
     397    if (m_hasFrameSpecificStorageAccess && !WebCore::registrableDomainsAreEqual(currentUrl, newUrl)) {
    397398        WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RemoveStorageAccessForFrame(sessionID(), frameID().value(), pageID().value()), 0);
    398399        m_hasFrameSpecificStorageAccess = false;
  • releases/WebKitGTK/webkit-2.22/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h

    r236129 r236130  
    9898#endif
    9999    void dispatchDidChangeMainDocument() final;
    100     void dispatchWillChangeDocument() final;
     100    void dispatchWillChangeDocument(const WebCore::URL& currentUrl, const WebCore::URL& newUrl) final;
    101101
    102102    void dispatchDidDispatchOnloadEvents() final;
Note: See TracChangeset for help on using the changeset viewer.