Title: [235798] branches/safari-606-branch
Revision
235798
Author
[email protected]
Date
2018-09-07 13:08:05 -0700 (Fri, 07 Sep 2018)

Log Message

Cherry-pick r235569. rdar://problem/44169479

    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 ].

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

Modified Paths

Added Paths

Removed Paths

Diff

Modified: branches/safari-606-branch/LayoutTests/ChangeLog (235797 => 235798)


--- branches/safari-606-branch/LayoutTests/ChangeLog	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/LayoutTests/ChangeLog	2018-09-07 20:08:05 UTC (rev 235798)
@@ -1,5 +1,75 @@
 2018-09-06  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r235569. rdar://problem/44169479
+
+    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 ].
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235569 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-08-31  John Wilander  <[email protected]>
+
+            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.
+
+            * 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 ].
+
+2018-09-06  Babak Shafiei  <[email protected]>
+
         Cherry-pick r235318. rdar://problem/44209848
 
     [Apple Pay] Allow $0 totals

Copied: branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access-expected.txt (from rev 235797, branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt) (0 => 235798)


--- branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access-expected.txt	                        (rev 0)
+++ branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access-expected.txt	2018-09-07 20:08:05 UTC (rev 235798)
@@ -0,0 +1,13 @@
+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.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.cookie == 
+PASS Storage access was granted.
+PASS document.cookie == cookieSetClientSideAfterGrantedStorageAccess=value; firstPartyCookie=value
+PASS No storage access. document.cookie == , cookies seen server-side == "No cookies"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access.html (from rev 235797, branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html) (0 => 235798)


--- branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access.html	                        (rev 0)
+++ branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access.html	2018-09-07 20:08:05 UTC (rev 235798)
@@ -0,0 +1,90 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script src=""
+    <script>
+        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.");
+        jsTestIsAsync = true;
+
+        window.addEventListener("message", receiveMessage, false);
+
+        function finishTest() {
+            setEnableFeature(false, finishJSTest);
+        }
+
+        const expectedPassMessages = 2;
+        var passMessagesReceived = 0;
+        function receiveMessage(event) {
+            if (event.origin === "http://localhost:8000") {
+                if (event.data.indexOf("document.cookie") === 0) {
+                    testPassed(event.data);
+                } else if (event.data.indexOf("PASS") !== -1) {
+                    testPassed(event.data.replace("PASS ", ""));
+                    passMessagesReceived++;
+                    if (passMessagesReceived >= expectedPassMessages)
+                        finishTest();
+                } else {
+                    testFailed(event.data);
+                    finishTest();
+                }
+            } else {
+                testFailed("Received a message from an unexpected origin: " + event.origin);
+                finishTest();
+            }
+        }
+
+        function activateElement(elementId) {
+            var element = document.getElementById(elementId);
+            var centerX = element.offsetLeft + element.offsetWidth / 2;
+            var centerY = element.offsetTop + element.offsetHeight / 2;
+            UIHelper.activateAt(centerX, centerY).then(
+                function () {
+                    if (window.eventSender)
+                        eventSender.keyDown("escape");
+                    else {
+                        testFailed("No eventSender.");
+                        finishTest();
+                    }
+                },
+                function () {
+                    testFailed("Promise rejected.");
+                    finishTest();
+                }
+            );
+        }
+
+        function runTest() {
+            activateElement("TheIframeThatRequestsStorageAccess");
+        }
+
+        const hostUnderTest = "localhost:8000";
+        const statisticsUrl = "http://" + hostUnderTest;
+        if (document.location.hash !== "#firstPartyCookieSet") {
+            setEnableFeature(true, function() {
+                document.location.href = "" + "/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";
+            });
+        } else {
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
+                if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                    testFailed("Host did not get set as prevalent resource.");
+                testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() {
+                    if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                        testFailed("Host did not get logged for user interaction.");
+                    testRunner.statisticsUpdateCookieBlocking(function() {
+                        let iframeElement = document.createElement("iframe");
+                        iframeElement.setAttribute("sandbox", "allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals");
+                        iframeElement._onload_ = runTest;
+                        iframeElement.id = "TheIframeThatRequestsStorageAccess";
+                        iframeElement.src = ""
+                        document.body.appendChild(iframeElement);
+                    });
+                });
+            });
+        }
+    </script>
+</head>
+<body>
+</body>
+</html>
\ No newline at end of file

Copied: branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access-expected.txt (from rev 235797, branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt) (0 => 235798)


--- branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access-expected.txt	                        (rev 0)
+++ branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access-expected.txt	2018-09-07 20:08:05 UTC (rev 235798)
@@ -0,0 +1,13 @@
+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.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.cookie == 
+PASS Storage access was granted.
+PASS document.cookie == cookieSetClientSideAfterGrantedStorageAccess=value; firstPartyCookie=value
+PASS Has storage access. document.cookie == cookieSetClientSideAfterGrantedStorageAccess=value; firstPartyCookie=value, cookies seen server-side == {"cookieSetClientSideAfterGrantedStorageAccess":"value","firstPartyCookie":"value"}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html (from rev 235797, branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html) (0 => 235798)


--- branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html	                        (rev 0)
+++ branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html	2018-09-07 20:08:05 UTC (rev 235798)
@@ -0,0 +1,112 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script>
+        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.");
+        jsTestIsAsync = true;
+
+        window.addEventListener("message", receiveMessage, false);
+
+        function setEnableFeature(enable) {
+            if (!enable)
+                testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(enable);
+            testRunner.setCookieStoragePartitioningEnabled(enable);
+            testRunner.setStorageAccessAPIEnabled(enable);
+        }
+
+        function finishTest() {
+            setEnableFeature(false);
+            finishJSTest();
+        }
+
+        const expectedPassMessages = 2;
+        var passMessagesReceived = 0;
+        function receiveMessage(event) {
+            if (event.origin === "http://localhost:8000") {
+                if (event.data.indexOf("document.cookie") === 0) {
+                    testPassed(event.data);
+                } else if (event.data.indexOf("PASS") !== -1) {
+                    testPassed(event.data.replace("PASS ", ""));
+                    passMessagesReceived++;
+                    if (passMessagesReceived >= expectedPassMessages)
+                        finishTest();
+                } else {
+                    testFailed(event.data);
+                    finishTest();
+                }
+            } else {
+                testFailed("Received a message from an unexpected origin: " + event.origin);
+                finishTest();
+            }
+        }
+
+        function activateElement(elementId) {
+            var element = document.getElementById(elementId);
+            var centerX = element.offsetLeft + element.offsetWidth / 2;
+            var centerY = element.offsetTop + element.offsetHeight / 2;
+            UIHelper.activateAt(centerX, centerY).then(
+                function () {
+                    if (window.eventSender)
+                        eventSender.keyDown("escape");
+                    else {
+                        testFailed("No eventSender.");
+                        finishTest();
+                    }
+                },
+                function () {
+                    testFailed("Promise rejected.");
+                    finishTest();
+                }
+            );
+        }
+
+        function runTest() {
+            activateElement("TheIframeThatRequestsStorageAccess");
+        }
+
+        const hostUnderTest = "localhost:8000";
+        const statisticsUrl = "http://" + hostUnderTest;
+        if (document.location.hash !== "#firstPartyCookieSet") {
+<<<<<<< HEAD:LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html
+            setEnableFeature(true);
+            document.location.href = "" + "/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";
+        } else {
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as prevalent resource.");
+            testRunner.setStatisticsHasHadNonRecentUserInteraction(statisticsUrl, true);
+            if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                testFailed("Host did not get logged for user interaction.");
+            testRunner.statisticsUpdateCookiePartitioning();
+=======
+            setEnableFeature(true, function() {
+                document.location.href = "" + "/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";
+            });
+        } else {
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
+                if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                    testFailed("Host did not get set as prevalent resource.");
+                testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() {
+                    if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                        testFailed("Host did not get logged for user interaction.");
+                    testRunner.statisticsUpdateCookieBlocking(function() {
+                        let iframeElement = document.createElement("iframe");
+                        iframeElement.setAttribute("sandbox", "allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals");
+                        iframeElement._onload_ = runTest;
+                        iframeElement.id = "TheIframeThatRequestsStorageAccess";
+                        iframeElement.src = ""
+                        document.body.appendChild(iframeElement);
+                    });
+                });
+            });
+>>>>>>> 0ba6eeb59ae... Storage Access API: Maintain access through same-site navigations:LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html
+        }
+    </script>
+</head>
+<body>
+<iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals" _onload_="runTest()" id="TheIframeThatRequestsStorageAccess" src=""
+</body>
+</html>
\ No newline at end of file

Deleted: branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt (235797 => 235798)


--- branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt	2018-09-07 20:08:05 UTC (rev 235798)
@@ -1,13 +0,0 @@
-Tests that a cross-origin iframe from a prevalent domain that is granted storage access and then navigates itself does not have storage access.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS document.cookie == 
-PASS Storage access was granted.
-PASS document.cookie == cookieSetClientSideAfterGrantedStorageAccess=value; firstPartyCookie=value
-PASS No storage access. document.cookie == , cookies seen server-side == "No cookies"
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Deleted: branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html (235797 => 235798)


--- branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html	2018-09-07 20:08:05 UTC (rev 235798)
@@ -1,89 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <script src=""
-    <script src=""
-    <script>
-        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.");
-        jsTestIsAsync = true;
-
-        window.addEventListener("message", receiveMessage, false);
-
-        function setEnableFeature(enable) {
-            if (!enable)
-                testRunner.statisticsResetToConsistentState();
-            internals.setResourceLoadStatisticsEnabled(enable);
-            testRunner.setCookieStoragePartitioningEnabled(enable);
-            testRunner.setStorageAccessAPIEnabled(enable);
-        }
-
-        function finishTest() {
-            setEnableFeature(false);
-            finishJSTest();
-        }
-
-        const expectedPassMessages = 2;
-        var passMessagesReceived = 0;
-        function receiveMessage(event) {
-            if (event.origin === "http://localhost:8000") {
-                if (event.data.indexOf("document.cookie") === 0) {
-                    testPassed(event.data);
-                } else if (event.data.indexOf("PASS") !== -1) {
-                    testPassed(event.data.replace("PASS ", ""));
-                    passMessagesReceived++;
-                    if (passMessagesReceived >= expectedPassMessages)
-                        finishTest();
-                } else {
-                    testFailed(event.data);
-                    finishTest();
-                }
-            } else {
-                testFailed("Received a message from an unexpected origin: " + event.origin);
-                finishTest();
-            }
-        }
-
-        function activateElement(elementId) {
-            var element = document.getElementById(elementId);
-            var centerX = element.offsetLeft + element.offsetWidth / 2;
-            var centerY = element.offsetTop + element.offsetHeight / 2;
-            UIHelper.activateAt(centerX, centerY).then(
-                function () {
-                    if (window.eventSender)
-                        eventSender.keyDown("escape");
-                    else {
-                        testFailed("No eventSender.");
-                        finishTest();
-                    }
-                },
-                function () {
-                    testFailed("Promise rejected.");
-                    finishTest();
-                }
-            );
-        }
-
-        function runTest() {
-            activateElement("TheIframeThatRequestsStorageAccess");
-        }
-
-        const hostUnderTest = "localhost:8000";
-        const statisticsUrl = "http://" + hostUnderTest;
-        if (document.location.hash !== "#firstPartyCookieSet") {
-            setEnableFeature(true);
-            document.location.href = "" + "/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";
-        } else {
-            testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
-            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-                testFailed("Host did not get set as prevalent resource.");
-            testRunner.setStatisticsHasHadNonRecentUserInteraction(statisticsUrl, true);
-            if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
-                testFailed("Host did not get logged for user interaction.");
-            testRunner.statisticsUpdateCookiePartitioning();
-        }
-    </script>
-</head>
-<body>
-<iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals" _onload_="runTest()" id="TheIframeThatRequestsStorageAccess" src=""
-</body>
-</html>
\ No newline at end of file

Modified: branches/safari-606-branch/LayoutTests/http/tests/storageAccess/resources/get-cookies.php (235797 => 235798)


--- branches/safari-606-branch/LayoutTests/http/tests/storageAccess/resources/get-cookies.php	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/LayoutTests/http/tests/storageAccess/resources/get-cookies.php	2018-09-07 20:08:05 UTC (rev 235798)
@@ -21,4 +21,29 @@
 <p id="output"></p>
 <script>
     document.getElementById("output").textContent = "Client-side document.cookie: " + document.cookie;
+
+    function messageToTop(messagePrefix, fetchData) {
+        top.postMessage(messagePrefix + " document.cookie == " + document.cookie +
+            (fetchData ? ", cookies seen server-side == " + JSON.stringify(fetchData) : ""), "http://127.0.0.1:8000");
+    }
+
+    function receiveMessage(event) {
+        if (event.origin === "http://127.0.0.1:8000") {
+            if (event.data.indexOf("reportBackCookies") !== -1) {
+                fetch("echo-incoming-cookies-as-json.php", { credentials: "same-origin" }).then(function(response) {
+                    return response.json();
+                }).then(function(data) {
+                    messageToTop("PASS", data);
+                }).catch(function(error) {
+                    console.log(error.message);
+                });
+            } else {
+                messageToTop("FAIL Unknown request.");
+            }
+        } else {
+            messageToTop("Fail Received a message from an unexpected origin: " + event.origin);
+        }
+    }
+
+    window.addEventListener("message", receiveMessage, false);
 </script>
\ No newline at end of file

Modified: branches/safari-606-branch/LayoutTests/http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html (235797 => 235798)


--- branches/safari-606-branch/LayoutTests/http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/LayoutTests/http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html	2018-09-07 20:08:05 UTC (rev 235798)
@@ -5,6 +5,7 @@
         const userShouldGrantAccess = hashArguments[0] === "userShouldGrantAccess";
         const userShouldBeConsulted = hashArguments[1] === "userShouldBeConsulted";
         const policyShouldGrantAccess = hashArguments[2] === "policyShouldGrantAccess";
+        const sameSiteNavigation = hashArguments[3] === "sameSiteNavigation";
 
         if (internals && userShouldGrantAccess)
             internals.setUserGrantsStorageAccess(true);
@@ -26,7 +27,11 @@
         }
 
         function navigate() {
-            document.location.href = ""
+            if (sameSiteNavigation) {
+                document.location.href = ""
+            } else {
+                document.location.href = ""
+            }
         }
 
         function setCookieAndNavigate() {

Modified: branches/safari-606-branch/LayoutTests/platform/mac-wk2/TestExpectations (235797 => 235798)


--- branches/safari-606-branch/LayoutTests/platform/mac-wk2/TestExpectations	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/LayoutTests/platform/mac-wk2/TestExpectations	2018-09-07 20:08:05 UTC (rev 235798)
@@ -748,7 +748,8 @@
 [ HighSierra+ ] http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-non-recent-user-interaction.html [ Pass ]
 [ HighSierra+ ] http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-recent-user-interaction.html [ Pass ]
 [ HighSierra+ ] http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html [ Pass ]
-[ HighSierra+ ] http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html [ Pass ]
+[ HighSierra+ ] http/tests/storageAccess/request-and-grant-access-then-navigate-cross-site-should-not-have-access.html [ Pass ]
+[ HighSierra+ ] http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html [ Pass ]
 [ HighSierra+ ] http/tests/storageAccess/deny-storage-access-under-opener.html [ Pass ]
 [ HighSierra+ ] http/tests/storageAccess/grant-storage-access-under-opener.html [ Pass ]
 

Modified: branches/safari-606-branch/Source/WebCore/ChangeLog (235797 => 235798)


--- branches/safari-606-branch/Source/WebCore/ChangeLog	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog	2018-09-07 20:08:05 UTC (rev 235798)
@@ -1,5 +1,70 @@
 2018-09-06  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r235569. rdar://problem/44169479
+
+    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 ].
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235569 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-08-31  John Wilander  <[email protected]>
+
+            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.
+
+            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:
+
+2018-09-06  Babak Shafiei  <[email protected]>
+
         Cherry-pick r235318. rdar://problem/44209848
 
     [Apple Pay] Allow $0 totals

Modified: branches/safari-606-branch/Source/WebCore/dom/Document.h (235797 => 235798)


--- branches/safari-606-branch/Source/WebCore/dom/Document.h	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/Source/WebCore/dom/Document.h	2018-09-07 20:08:05 UTC (rev 235798)
@@ -1952,7 +1952,6 @@
 
     static bool hasEverCreatedAnAXObjectCache;
 
-    bool m_hasFrameSpecificStorageAccess { false };
     bool m_grantStorageAccessOverride { false };
 
 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)

Modified: branches/safari-606-branch/Source/WebCore/loader/DocumentLoader.cpp (235797 => 235798)


--- branches/safari-606-branch/Source/WebCore/loader/DocumentLoader.cpp	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/Source/WebCore/loader/DocumentLoader.cpp	2018-09-07 20:08:05 UTC (rev 235798)
@@ -600,7 +600,7 @@
     FrameLoader::addSameSiteInfoToRequestIfNeeded(newRequest, m_frame->document());
 
     if (!didReceiveRedirectResponse)
-        frameLoader()->client().dispatchWillChangeDocument();
+        frameLoader()->client().dispatchWillChangeDocument(m_frame->document()->url(), newRequest.url());
 
     // If we're fielding a redirect in response to a POST, force a load from origin, since
     // this is a common site technique to return to a page viewing some data that the POST

Modified: branches/safari-606-branch/Source/WebCore/loader/FrameLoaderClient.h (235797 => 235798)


--- branches/safari-606-branch/Source/WebCore/loader/FrameLoaderClient.h	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/Source/WebCore/loader/FrameLoaderClient.h	2018-09-07 20:08:05 UTC (rev 235798)
@@ -164,7 +164,7 @@
     virtual void dispatchDidCancelClientRedirect() = 0;
     virtual void dispatchWillPerformClientRedirect(const URL&, double interval, WallTime fireDate) = 0;
     virtual void dispatchDidChangeMainDocument() { }
-    virtual void dispatchWillChangeDocument() { }
+    virtual void dispatchWillChangeDocument(const URL&, const URL&) { }
     virtual void dispatchDidNavigateWithinPage() { }
     virtual void dispatchDidChangeLocationWithinPage() = 0;
     virtual void dispatchDidPushStateWithinPage() = 0;

Modified: branches/safari-606-branch/Source/WebKit/ChangeLog (235797 => 235798)


--- branches/safari-606-branch/Source/WebKit/ChangeLog	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/Source/WebKit/ChangeLog	2018-09-07 20:08:05 UTC (rev 235798)
@@ -1,5 +1,68 @@
 2018-09-06  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r235569. rdar://problem/44169479
+
+    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 ].
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235569 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-08-31  John Wilander  <[email protected]>
+
+            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.
+
+            * 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:
+
+2018-09-06  Babak Shafiei  <[email protected]>
+
         Cherry-pick r235251. rdar://problem/44209840
 
     [Apple Pay] Introduce Apple Pay JS v4 on iOS 12 and macOS Mojave

Modified: branches/safari-606-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (235797 => 235798)


--- branches/safari-606-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2018-09-07 20:08:05 UTC (rev 235798)
@@ -83,6 +83,7 @@
 #include <WebCore/PolicyChecker.h>
 #include <WebCore/ProgressTracker.h>
 #include <WebCore/ResourceError.h>
+#include <WebCore/ResourceRequest.h>
 #include <WebCore/ScriptController.h>
 #include <WebCore/SecurityOriginData.h>
 #include <WebCore/Settings.h>
@@ -384,7 +385,7 @@
     webPage->send(Messages::WebPageProxy::DidChangeMainDocument(m_frame->frameID()));
 }
 
-void WebFrameLoaderClient::dispatchWillChangeDocument()
+void WebFrameLoaderClient::dispatchWillChangeDocument(const URL& currentUrl, const URL& newUrl)
 {
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     if (m_frame->isMainFrame())
@@ -394,7 +395,7 @@
     if (!webPage)
         return;
 
-    if (m_hasFrameSpecificStorageAccess) {
+    if (m_hasFrameSpecificStorageAccess && !WebCore::registrableDomainsAreEqual(currentUrl, newUrl)) {
         WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RemoveStorageAccessForFrame(sessionID(), frameID().value(), pageID().value()), 0);
         m_hasFrameSpecificStorageAccess = false;
     }

Modified: branches/safari-606-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (235797 => 235798)


--- branches/safari-606-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2018-09-07 20:07:58 UTC (rev 235797)
+++ branches/safari-606-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2018-09-07 20:08:05 UTC (rev 235798)
@@ -97,7 +97,7 @@
     void dispatchDidFinishDataDetection(NSArray *detectionResults) final;
 #endif
     void dispatchDidChangeMainDocument() final;
-    void dispatchWillChangeDocument() final;
+    void dispatchWillChangeDocument(const WebCore::URL& currentUrl, const WebCore::URL& newUrl) final;
 
     void dispatchDidDispatchOnloadEvents() final;
     void dispatchDidReceiveServerRedirectForProvisionalLoad() final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to