Title: [226235] trunk
Revision
226235
Author
[email protected]
Date
2017-12-21 11:56:45 -0800 (Thu, 21 Dec 2017)

Log Message

Storage Access API: Make DocumentLoader::willSendRequest() and WebFrameLoaderClient::detachedFromParent2() tell the network process to get rid of any sub frame access entries
https://bugs.webkit.org/show_bug.cgi?id=180728
<rdar://problem/36009288>

Reviewed by Youenn Fablet.

Source/WebCore:

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

This change calls the network process to clear any storage access
entries when a subframe navigates or is detached.

* dom/Document.cpp:
(WebCore::Document::hasStorageAccess):
(WebCore::Document::requestStorageAccess):
(WebCore::Document::hasFrameSpecificStorageAccess):
(WebCore::Document::setHasFrameSpecificStorageAccess):
* dom/Document.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::willSendRequest):
* loader/EmptyFrameLoaderClient.h:
* loader/FrameLoaderClient.h:
* platform/network/NetworkStorageSession.h:
* platform/network/cf/NetworkStorageSessionCFNet.cpp:
(WebCore::NetworkStorageSession::removeStorageAccess):

Source/WebKit:

This change calls the network process to clear any storage access
entries when a subframe navigates or is detached.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::removeStorageAccess):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::removeStorageAccess):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::removeStorageAccess):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::hasStorageAccess):
(WebKit::WebsiteDataStore::requestStorageAccess):
(WebKit::WebsiteDataStore::removeStorageAccess):
* UIProcess/WebsiteData/WebsiteDataStore.h:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::detachedFromParent2):
(WebKit::WebFrameLoaderClient::dispatchWillChangeDocument):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
* WebProcess/WebPage/WebPage.cpp:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

LayoutTests:

This change calls the network process to clear any storage access
entries when a subframe navigates or is detached.

* http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-non-recent-user-interaction-expected.txt:
* http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-recent-user-interaction-expected.txt:
* http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe-expected.txt:
* http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt:
* http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access-expected.txt: Added.
* http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html: Added.
* http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt: Added.
* http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html: Added.
* http/tests/storageAccess/request-and-grant-storage-access-cross-origin-non-sandboxed-iframe-expected.txt:
* http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-expected.txt:
* http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame-expected.txt:
* http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame.html:
* http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-but-try-access-from-wrong-frame-expected.txt:
* http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-recent-user-interaction-expected.txt:
* http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction-expected.txt:
* http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-nested-iframe-expected.txt:
* http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin-expected.txt:
* http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html:
* http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token-expected.txt:
* http/tests/storageAccess/request-storage-access-same-origin-iframe-expected.txt:
* http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-expected.txt:
* http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-without-allow-token-expected.txt:
* http/tests/storageAccess/resources/echo-incoming-cookies-as-json.php: Added.
* http/tests/storageAccess/resources/has-storage-access-iframe.html:
* http/tests/storageAccess/resources/request-storage-access-iframe.html:
* http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html: Added.
* platform/wk2/TestExpectations:
    Removed http/tests/storageAccess/request-storage-access-top-frame.html
    because it now only passes on High Sierra+.
* platform/mac-wk2/TestExpectations:
    Added the new tests as [ Pass ] on High Sierra+.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (226234 => 226235)


--- trunk/LayoutTests/ChangeLog	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/ChangeLog	2017-12-21 19:56:45 UTC (rev 226235)
@@ -1,3 +1,46 @@
+2017-12-21  John Wilander  <[email protected]>
+
+        Storage Access API: Make DocumentLoader::willSendRequest() and WebFrameLoaderClient::detachedFromParent2() tell the network process to get rid of any sub frame access entries
+        https://bugs.webkit.org/show_bug.cgi?id=180728
+        <rdar://problem/36009288>
+
+        Reviewed by Youenn Fablet.
+
+        This change calls the network process to clear any storage access
+        entries when a subframe navigates or is detached.
+
+        * http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-non-recent-user-interaction-expected.txt:
+        * http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-recent-user-interaction-expected.txt:
+        * http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe-expected.txt:
+        * http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt:
+        * http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access-expected.txt: Added.
+        * http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html: Added.
+        * http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt: Added.
+        * http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html: Added.
+        * http/tests/storageAccess/request-and-grant-storage-access-cross-origin-non-sandboxed-iframe-expected.txt:
+        * http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-expected.txt:
+        * http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame-expected.txt:
+        * http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame.html:
+        * http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-but-try-access-from-wrong-frame-expected.txt:
+        * http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-recent-user-interaction-expected.txt:
+        * http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction-expected.txt:
+        * http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-nested-iframe-expected.txt:
+        * http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin-expected.txt:
+        * http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html:
+        * http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token-expected.txt:
+        * http/tests/storageAccess/request-storage-access-same-origin-iframe-expected.txt:
+        * http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-expected.txt:
+        * http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-without-allow-token-expected.txt:
+        * http/tests/storageAccess/resources/echo-incoming-cookies-as-json.php: Added.
+        * http/tests/storageAccess/resources/has-storage-access-iframe.html:
+        * http/tests/storageAccess/resources/request-storage-access-iframe.html:
+        * http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html: Added.
+        * platform/wk2/TestExpectations:
+            Removed http/tests/storageAccess/request-storage-access-top-frame.html
+            because it now only passes on High Sierra+.
+        * platform/mac-wk2/TestExpectations:
+            Added the new tests as [ Pass ] on High Sierra+.
+
 2017-12-21  Antoine Quint  <[email protected]>
 
         [Web Animations] Complete support for keyframe animations

Modified: trunk/LayoutTests/http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-non-recent-user-interaction-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-non-recent-user-interaction-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-non-recent-user-interaction-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS No storage access.
+PASS No storage access. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-recent-user-interaction-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-recent-user-interaction-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-recent-user-interaction-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Has storage access.
+PASS Has storage access. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was denied.
+PASS Storage access was denied. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -4,7 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was denied.
+PASS Storage access was denied. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Added: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access-expected.txt (0 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -0,0 +1,12 @@
+CONFIRM: Do you want to use your localhost ID on 127.0.0.1?
+Tests that a cross-origin iframe from a prevalent domain that is granted storage access and then is detached from the DOM does not have storage access.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Storage access was granted. document.cookie == firstPartyCookie=value, cookies seen server-side == {"firstPartyCookie":"value"}
+PASS PASS. document.cookie == , cookies seen server-side == "No cookies"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ 

Added: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html (0 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html	2017-12-21 19:56:45 UTC (rev 226235)
@@ -0,0 +1,104 @@
+<!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 is detached from the DOM 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 iframeID = "TheIframeThatRequestsStorageAccess";
+        function askIframeIfItHasStorageAccess() {
+            var iframeContentWindow = document.getElementById(iframeID).contentWindow;
+            iframeContentWindow.postMessage("reportBackCookies", "http://localhost:8000");
+        }
+
+        function detachIframeAndAskWhetherItStillHasStorageAccess() {
+            var theIframe = document.getElementById(iframeID);
+            theIframe._onload_ = askIframeIfItHasStorageAccess;
+            document.getElementsByTagName('body')[0].appendChild(theIframe);
+        }
+
+        const expectedPassMessages = 2;
+        var passMessagesReceived = 0;
+        function receiveMessage(event) {
+            if (event.origin === "http://localhost:8000") {
+                if (event.data.indexOf("PASS") !== -1) {
+                    testPassed(event.data.replace("PASS ", ""));
+                    passMessagesReceived++;
+                    if (passMessagesReceived >= expectedPassMessages)
+                        finishTest();
+                    else
+                        detachIframeAndAskWhetherItStillHasStorageAccess();
+                } 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() {
+            if (document.location.hash !== "#elementActivated") {
+                activateElement(iframeID);
+                document.location.hash = "elementActivated";
+            }
+        }
+
+        const hostUnderTest = "localhost:8000";
+        const statisticsUrl = "http://" + hostUnderTest;
+        if (document.location.hash !== "#firstPartyCookieSet" && document.location.hash !== "#elementActivated") {
+            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-detach-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

Added: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt (0 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -0,0 +1,14 @@
+CONFIRM: Do you want to use your localhost ID on 127.0.0.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.
+
+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
+

Added: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html (0 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html	2017-12-21 19:56:45 UTC (rev 226235)
@@ -0,0 +1,89 @@
+<!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: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-non-sandboxed-iframe-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-non-sandboxed-iframe-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-non-sandboxed-iframe-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was denied.
+PASS Storage access was denied. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -4,7 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was granted.
+PASS Storage access was granted. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -4,7 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was granted.
+PASS Storage access was granted. document.cookie == firstPartyCookie=value, cookies seen server-side == {"firstPartyCookie":"value"}
 PASS successfullyParsed is true
 
 TEST COMPLETE
@@ -13,10 +13,10 @@
 --------
 Frame: 'TheIframeThatRequestsStorageAccess'
 --------
-After access granted, should receive first-party cookie.
-Received cookie named 'firstPartyCookie'.
-Did not receive cookie named 'partitionedCookie'.
-Client-side document.cookie: firstPartyCookie=value
+After the top frame navigates the sub frame, the sub frame should no longer have access to first-party cookies.
+Did not receive cookie named 'firstPartyCookie'.
+Received cookie named 'partitionedCookie'.
+Client-side document.cookie: partitionedCookie=value
 
 --------
 Frame: '<!--framePath //<!--frame1-->-->'

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame.html (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame.html	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame.html	2017-12-21 19:56:45 UTC (rev 226235)
@@ -114,7 +114,7 @@
                 case "#step7":
                     document.location.hash = "step8";
                     // Check that the first-party cookie gets sent for localhost under 127.0.0.1 since we're opening in the frame that was granted access.
-                    document.getElementById("TheIframeThatRequestsStorageAccess").src = "" + subPathToGetCookies + "&message=After access granted, should receive first-party cookie.";
+                    document.getElementById("TheIframeThatRequestsStorageAccess").src = "" + subPathToGetCookies + "&message=After the top frame navigates the sub frame, the sub frame should no longer have access to first-party cookies.";
                     break;
                 case "#step8":
                     setEnableFeature(false);

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-but-try-access-from-wrong-frame-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-but-try-access-from-wrong-frame-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-but-try-access-from-wrong-frame-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -4,7 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was granted.
+PASS Storage access was granted. document.cookie == firstPartyCookie=value, cookies seen server-side == {"firstPartyCookie":"value"}
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-recent-user-interaction-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-recent-user-interaction-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-recent-user-interaction-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -4,7 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was granted.
+PASS Storage access was granted. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -4,7 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was denied.
+PASS Storage access was denied. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-nested-iframe-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-nested-iframe-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-nested-iframe-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was denied.
+PASS Storage access was denied. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was denied.
+PASS Storage access was denied for origin null.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html	2017-12-21 19:56:45 UTC (rev 226235)
@@ -46,6 +46,6 @@
     </script>
 </head>
 <body>
-    <iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-modals" _onload_="runTest()" id="theIframe" src=""
+    <iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-modals" _onload_="runTest()" id="theIframe" src=""
 </body>
 </html>
\ No newline at end of file

Modified: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was denied.
+PASS Storage access was denied. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-iframe-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-iframe-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-iframe-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was granted.
+PASS Storage access was granted. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was granted.
+PASS Storage access was granted. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-without-allow-token-expected.txt (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-without-allow-token-expected.txt	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-without-allow-token-expected.txt	2017-12-21 19:56:45 UTC (rev 226235)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Storage access was granted.
+PASS Storage access was granted. document.cookie == , cookies seen server-side == "No cookies"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Added: trunk/LayoutTests/http/tests/storageAccess/resources/echo-incoming-cookies-as-json.php (0 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/resources/echo-incoming-cookies-as-json.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/storageAccess/resources/echo-incoming-cookies-as-json.php	2017-12-21 19:56:45 UTC (rev 226235)
@@ -0,0 +1,7 @@
+<?php
+if(empty($_COOKIE)) {
+    echo json_encode('No cookies');
+} else {
+    echo json_encode($_COOKIE);
+}
+?>
\ No newline at end of file

Modified: trunk/LayoutTests/http/tests/storageAccess/resources/has-storage-access-iframe.html (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/resources/has-storage-access-iframe.html	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/resources/has-storage-access-iframe.html	2017-12-21 19:56:45 UTC (rev 226235)
@@ -3,23 +3,40 @@
     <script>
         const policyShouldGrantAccess = document.location.hash === "#policyShouldGrantAccess";
 
+        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 checkHasStorageAccess() {
             var promise = document.hasStorageAccess();
             promise.then(
                 function (hasAccess) {
                     if (hasAccess && policyShouldGrantAccess)
-                        top.postMessage("PASS Has storage access.", "http://127.0.0.1:8000");
+                        fetch("echo-incoming-cookies-as-json.php", { credentials: "same-origin" }).then(function(response) {
+                            return response.json();
+                        }).then(function(data) {
+                            messageToTop("PASS Has storage access.", data);
+                        }).catch(function(error) {
+                            console.log(error.message);
+                        });
                     else if (!hasAccess && !policyShouldGrantAccess)
-                        top.postMessage("PASS No storage access.", "http://127.0.0.1:8000");
+                        fetch("echo-incoming-cookies-as-json.php", { credentials: "same-origin" }).then(function(response) {
+                            return response.json();
+                        }).then(function(data) {
+                            messageToTop("PASS No storage access.", data);
+                        }).catch(function(error) {
+                            console.log(error.message);
+                        });
                     else
-                        top.postMessage("FAIL " +
+                        messageToTop("FAIL " +
                             (hasAccess ? "Storage " : "No storage ") +
                             "access when there should " +
                             (policyShouldGrantAccess ? "" : "not ") +
-                            "have been access.", "http://127.0.0.1:8000");
+                            "have been access.");
                 },
                 function (reason) {
-                    top.postMessage("FAIL document.hasStorageAccess() was rejected. Reason: " + reason, "http://127.0.0.1:8000");
+                    messageToTop("FAIL document.hasStorageAccess() was rejected. Reason: " + reason);
                 }
             );
         }

Modified: trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-iframe.html (226234 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-iframe.html	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-iframe.html	2017-12-21 19:56:45 UTC (rev 226235)
@@ -5,6 +5,8 @@
         const userShouldGrantAccess = hashArguments[0] === "userShouldGrantAccess";
         const userShouldBeConsulted = hashArguments[1] === "userShouldBeConsulted";
         const policyShouldGrantAccess = hashArguments[2] === "policyShouldGrantAccess";
+        const isSameOriginIframe = hashArguments[3] === "isSameOriginIframe";
+        const originIsNull = hashArguments[4] === "originIsNull";
 
         if (internals && userShouldGrantAccess)
                 internals.setUserGrantsStorageAccess(true);
@@ -11,6 +13,35 @@
 
         var requestStorageAccessResolved;
 
+        function messageToTop(messagePrefix, fetchData) {
+            if (originIsNull) {
+                top.postMessage(messagePrefix, "http://127.0.0.1:8000");
+            } else {
+                top.postMessage(messagePrefix + " document.cookie == " + document.cookie +
+                    (fetchData ? ", cookies seen server-side == " + JSON.stringify(fetchData) : ""), "http://127.0.0.1:8000");
+            }
+        }
+
+        window.addEventListener("message", receiveMessage, false);
+
+        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);
+            }
+        }
+
         function makeRequestWithUserGesture() {
             var promise = document.requestStorageAccess();
             promise.then(
@@ -32,23 +63,40 @@
                     if (requestStorageAccessResolved
                         && hasAccess
                         && (userShouldGrantAccess || !userShouldBeConsulted)
-                        && policyShouldGrantAccess)
-                        top.postMessage("PASS Storage access was granted.", "http://127.0.0.1:8000");
-                    else if (!hasAccess
+                        && policyShouldGrantAccess) {
+                        fetch("echo-incoming-cookies-as-json.php", { credentials: "same-origin" }).then(function(response) {
+                            return response.json();
+                        }).then(function(data) {
+                            messageToTop("PASS Storage access was granted.", data);
+                        }).catch(function(error) {
+                            console.log(error.message);
+                        });
+
+                    } else if (!hasAccess
                         && !requestStorageAccessResolved
-                        && ((!userShouldGrantAccess && userShouldBeConsulted) || !policyShouldGrantAccess))
-                        top.postMessage("PASS Storage access was denied.", "http://127.0.0.1:8000");
-                    else
-                        top.postMessage("FAIL Storage access was " +
+                        && ((!userShouldGrantAccess && userShouldBeConsulted) || !policyShouldGrantAccess)) {
+                        if (originIsNull) {
+                            messageToTop("PASS Storage access was denied for origin null.");
+                        } else {
+                            fetch("echo-incoming-cookies-as-json.php", { credentials: "same-origin" }).then(function(response) {
+                                return response.json();
+                            }).then(function(data) {
+                                messageToTop("PASS Storage access was denied.", data);
+                            }).catch(function(error) {
+                                console.log(error.message);
+                            });
+                        }
+                    } else
+                        messageToTop("FAIL Storage access was " +
                             (hasAccess ? "" : "not ") +
                             "granted and requestStorageAccessResolved was " +
                             (requestStorageAccessResolved ? "" : "not ") +
                             "granted but should " +
                             (userShouldGrantAccess && policyShouldGrantAccess ? "" : "not ") +
-                            "have been granted.", "http://127.0.0.1:8000");
+                            "have been granted.");
                 },
                 function (reason) {
-                    top.postMessage("FAIL document.hasStorageAccess() was rejected. Reason: " + reason, "http://127.0.0.1:8000");
+                    messageToTop("FAIL document.hasStorageAccess() was rejected. Reason: " + reason);
                 }
             );
         }

Copied: trunk/LayoutTests/http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html (from rev 226234, trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-iframe.html) (0 => 226235)


--- trunk/LayoutTests/http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html	2017-12-21 19:56:45 UTC (rev 226235)
@@ -0,0 +1,72 @@
+<html>
+<head>
+    <script>
+        const hashArguments = document.location.hash.substring(1).split(",");
+        const userShouldGrantAccess = hashArguments[0] === "userShouldGrantAccess";
+        const userShouldBeConsulted = hashArguments[1] === "userShouldBeConsulted";
+        const policyShouldGrantAccess = hashArguments[2] === "policyShouldGrantAccess";
+
+        if (internals && userShouldGrantAccess)
+            internals.setUserGrantsStorageAccess(true);
+
+        var requestStorageAccessResolved;
+
+        function makeRequestWithUserGesture() {
+            var promise = document.requestStorageAccess();
+            promise.then(
+                function () {
+                    requestStorageAccessResolved = true;
+                    continueAfterRequestWithUserGesture();
+                },
+                function () {
+                    requestStorageAccessResolved = false;
+                    continueAfterRequestWithUserGesture();
+                }
+            );
+        }
+
+        function navigate() {
+            document.location.href = ""
+        }
+
+        function setCookieAndNavigate() {
+            document.cookie = "cookieSetClientSideAfterGrantedStorageAccess=value";
+            top.postMessage("document.cookie == " + document.cookie, "http://127.0.0.1:8000");
+            setTimeout("navigate()", 200);
+        }
+
+        function continueAfterRequestWithUserGesture() {
+            var promise = document.hasStorageAccess();
+            promise.then(
+                function (hasAccess) {
+                    if (requestStorageAccessResolved
+                        && hasAccess
+                        && (userShouldGrantAccess || !userShouldBeConsulted)
+                        && policyShouldGrantAccess)
+                        top.postMessage("PASS Storage access was granted.", "http://127.0.0.1:8000");
+                    else if (!hasAccess
+                        && !requestStorageAccessResolved
+                        && ((!userShouldGrantAccess && userShouldBeConsulted) || !policyShouldGrantAccess))
+                        top.postMessage("PASS Storage access was denied.", "http://127.0.0.1:8000");
+                    else
+                        top.postMessage("FAIL Storage access was " +
+                            (hasAccess ? "" : "not ") +
+                            "granted and requestStorageAccessResolved was " +
+                            (requestStorageAccessResolved ? "" : "not ") +
+                            "granted but should " +
+                            (userShouldGrantAccess && policyShouldGrantAccess ? "" : "not ") +
+                            "have been granted.", "http://127.0.0.1:8000");
+                    setTimeout("setCookieAndNavigate()", 200);
+                },
+                function (reason) {
+                    top.postMessage("FAIL document.hasStorageAccess() was rejected. Reason: " + reason, "http://127.0.0.1:8000");
+                }
+            );
+        }
+
+        top.postMessage("document.cookie == " + document.cookie, "http://127.0.0.1:8000");
+    </script>
+</head>
+<body _onclick_="makeRequestWithUserGesture()">
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (226234 => 226235)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2017-12-21 19:56:45 UTC (rev 226235)
@@ -766,6 +766,8 @@
 [ HighSierra+ ] http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture.html [ Pass ]
 [ 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 ]
 
 webkit.org/b/173861 [ Release ] http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html [ Pass Timeout ]
 webkit.org/b/173861 [ Release ] http/tests/webrtc/filtering-ice-candidate-cross-origin-frame.html [ Pass Timeout ]

Modified: trunk/LayoutTests/platform/wk2/TestExpectations (226234 => 226235)


--- trunk/LayoutTests/platform/wk2/TestExpectations	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/LayoutTests/platform/wk2/TestExpectations	2017-12-21 19:56:45 UTC (rev 226235)
@@ -689,7 +689,6 @@
 http/tests/resourceLoadStatistics/grandfathering.html [ Pass ]
 webkit.org/b/180703 http/tests/resourceLoadStatistics/telemetry-generation.html [ Pass Failure ]
 http/tests/resourceLoadStatistics/prune-statistics.html [ Pass ]
-http/tests/storageAccess/request-storage-access-top-frame.html [ Pass ]
 http/tests/resourceLoadStatistics [ Pass ]
 # Cookie partitioning is only supported in macOS High Sierra and iOS 11.
 http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (226234 => 226235)


--- trunk/Source/WebCore/ChangeLog	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebCore/ChangeLog	2017-12-21 19:56:45 UTC (rev 226235)
@@ -1,3 +1,31 @@
+2017-12-21  John Wilander  <[email protected]>
+
+        Storage Access API: Make DocumentLoader::willSendRequest() and WebFrameLoaderClient::detachedFromParent2() tell the network process to get rid of any sub frame access entries
+        https://bugs.webkit.org/show_bug.cgi?id=180728
+        <rdar://problem/36009288>
+
+        Reviewed by Youenn Fablet.
+
+        Tests: http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html
+               http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html
+
+        This change calls the network process to clear any storage access
+        entries when a subframe navigates or is detached.
+
+        * dom/Document.cpp:
+        (WebCore::Document::hasStorageAccess):
+        (WebCore::Document::requestStorageAccess):
+        (WebCore::Document::hasFrameSpecificStorageAccess):
+        (WebCore::Document::setHasFrameSpecificStorageAccess):
+        * dom/Document.h:
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::willSendRequest):
+        * loader/EmptyFrameLoaderClient.h:
+        * loader/FrameLoaderClient.h:
+        * platform/network/NetworkStorageSession.h:
+        * platform/network/cf/NetworkStorageSessionCFNet.cpp:
+        (WebCore::NetworkStorageSession::removeStorageAccess):
+
 2017-12-21  Antoine Quint  <[email protected]>
 
         [Web Animations] Complete support for keyframe animations

Modified: trunk/Source/WebCore/dom/Document.cpp (226234 => 226235)


--- trunk/Source/WebCore/dom/Document.cpp	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-12-21 19:56:45 UTC (rev 226235)
@@ -7432,7 +7432,8 @@
 {
     ASSERT(settings().storageAccessAPIEnabled());
 
-    if (m_hasFrameSpecificStorageAccess) {
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+    if (hasFrameSpecificStorageAccess()) {
         promise->resolve<IDLBoolean>(true);
         return;
     }
@@ -7454,7 +7455,6 @@
         return;
     }
 
-    ASSERT(m_frame);
     auto frameID = m_frame->loader().client().frameID();
     auto pageID = m_frame->loader().client().pageID();
     if (!frameID || !pageID) {
@@ -7474,6 +7474,7 @@
         });
         return;
     }
+#endif
 
     promise->reject();
 }
@@ -7482,8 +7483,11 @@
 {
     ASSERT(settings().storageAccessAPIEnabled());
     
-    if (m_hasFrameSpecificStorageAccess)
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+    if (hasFrameSpecificStorageAccess()) {
         promise->resolve();
+        return;
+    }
     
     if (!m_frame || securityOrigin().isUnique()) {
         promise->reject();
@@ -7546,7 +7550,7 @@
                 return;
 
             if (wasGranted) {
-                document->m_hasFrameSpecificStorageAccess = true;
+                document->setHasFrameSpecificStorageAccess(true);
                 promise->resolve();
             } else
                 promise->reject();
@@ -7553,10 +7557,23 @@
         });
         return;
     }
-    
+#endif
+
     promise->reject();
 }
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+bool Document::hasFrameSpecificStorageAccess() const
+{
+    return m_frame->loader().client().hasFrameSpecificStorageAccess();
+}
+    
+void Document::setHasFrameSpecificStorageAccess(bool value)
+{
+    m_frame->loader().client().setHasFrameSpecificStorageAccess(value);
+}
+#endif
+
 void Document::setConsoleMessageListener(RefPtr<StringCallback>&& listener)
 {
     m_consoleMessageListener = listener;

Modified: trunk/Source/WebCore/dom/Document.h (226234 => 226235)


--- trunk/Source/WebCore/dom/Document.h	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebCore/dom/Document.h	2017-12-21 19:56:45 UTC (rev 226235)
@@ -1699,6 +1699,11 @@
 
     void didLogMessage(const WTFLogChannel&, WTFLogLevel, Vector<JSONLogValue>&&) final;
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+    bool hasFrameSpecificStorageAccess() const;
+    void setHasFrameSpecificStorageAccess(bool);
+#endif
+
 #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
     std::unique_ptr<DeviceMotionClient> m_deviceMotionClient;
     std::unique_ptr<DeviceMotionController> m_deviceMotionController;

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (226234 => 226235)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2017-12-21 19:56:45 UTC (rev 226235)
@@ -534,6 +534,9 @@
     if (m_frame->isMainFrame())
         newRequest.setFirstPartyForCookies(newRequest.url());
 
+    if (!didReceiveRedirectResponse)
+        frameLoader()->client().dispatchWillChangeDocument();
+
     // 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
     // just modified.

Modified: trunk/Source/WebCore/loader/EmptyFrameLoaderClient.h (226234 => 226235)


--- trunk/Source/WebCore/loader/EmptyFrameLoaderClient.h	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebCore/loader/EmptyFrameLoaderClient.h	2017-12-21 19:56:45 UTC (rev 226235)
@@ -200,6 +200,10 @@
 #if USE(QUICK_LOOK)
     RefPtr<PreviewLoaderClient> createPreviewLoaderClient(const String&, const String&) final { return nullptr; }
 #endif
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+    bool hasFrameSpecificStorageAccess() final { return false; }
+    void setHasFrameSpecificStorageAccess(bool) final { }
+#endif
 };
 
 }

Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (226234 => 226235)


--- trunk/Source/WebCore/loader/FrameLoaderClient.h	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h	2017-12-21 19:56:45 UTC (rev 226235)
@@ -161,6 +161,7 @@
     virtual void dispatchDidCancelClientRedirect() = 0;
     virtual void dispatchWillPerformClientRedirect(const URL&, double interval, double fireDate) = 0;
     virtual void dispatchDidChangeMainDocument() { }
+    virtual void dispatchWillChangeDocument() { }
     virtual void dispatchDidNavigateWithinPage() { }
     virtual void dispatchDidChangeLocationWithinPage() = 0;
     virtual void dispatchDidPushStateWithinPage() = 0;
@@ -364,6 +365,11 @@
 #if ENABLE(APPLICATION_MANIFEST)
     virtual void finishedLoadingApplicationManifest(uint64_t, const std::optional<ApplicationManifest>&) { }
 #endif
+
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+    virtual bool hasFrameSpecificStorageAccess() { return false; }
+    virtual void setHasFrameSpecificStorageAccess(bool) { }
+#endif
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (226234 => 226235)


--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h	2017-12-21 19:56:45 UTC (rev 226235)
@@ -100,6 +100,7 @@
     WEBCORE_EXPORT void removePrevalentDomains(const Vector<String>& domains);
     WEBCORE_EXPORT bool isStorageAccessGranted(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID) const;
     WEBCORE_EXPORT void setStorageAccessGranted(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, bool value);
+    WEBCORE_EXPORT void removeStorageAccess(uint64_t frameID, uint64_t pageID);
 #endif
 #elif USE(SOUP)
     NetworkStorageSession(PAL::SessionID, std::unique_ptr<SoupNetworkSession>&&);

Modified: trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp (226234 => 226235)


--- trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp	2017-12-21 19:56:45 UTC (rev 226235)
@@ -333,6 +333,15 @@
     }
 }
 
+void NetworkStorageSession::removeStorageAccess(uint64_t frameID, uint64_t pageID)
+{
+    auto iteration = m_framesGrantedStorageAccess.find(frameID);
+    if (iteration == m_framesGrantedStorageAccess.end())
+        return;
+    
+    iteration->value.remove(pageID);
+}
+    
 #endif // HAVE(CFNETWORK_STORAGE_PARTITIONING)
 
 #if !PLATFORM(COCOA)

Modified: trunk/Source/WebKit/ChangeLog (226234 => 226235)


--- trunk/Source/WebKit/ChangeLog	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/ChangeLog	2017-12-21 19:56:45 UTC (rev 226235)
@@ -1,3 +1,40 @@
+2017-12-21  John Wilander  <[email protected]>
+
+        Storage Access API: Make DocumentLoader::willSendRequest() and WebFrameLoaderClient::detachedFromParent2() tell the network process to get rid of any sub frame access entries
+        https://bugs.webkit.org/show_bug.cgi?id=180728
+        <rdar://problem/36009288>
+
+        Reviewed by Youenn Fablet.
+
+        This change calls the network process to clear any storage access
+        entries when a subframe navigates or is detached.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::removeStorageAccess):
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in:
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::removeStorageAccess):
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::removeStorageAccess):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::hasStorageAccess):
+        (WebKit::WebsiteDataStore::requestStorageAccess):
+        (WebKit::WebsiteDataStore::removeStorageAccess):
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::detachedFromParent2):
+        (WebKit::WebFrameLoaderClient::dispatchWillChangeDocument):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2017-12-21  Jeremy Jones  <[email protected]>
 
         Second Build fix after r226223

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (226234 => 226235)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2017-12-21 19:56:45 UTC (rev 226235)
@@ -360,6 +360,14 @@
     parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessRequestResult(isStorageGranted, contextId), 0);
 }
 
+void NetworkProcess::removeStorageAccess(PAL::SessionID sessionID, uint64_t frameID, uint64_t pageID)
+{
+    if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
+        networkStorageSession->removeStorageAccess(frameID, pageID);
+    else
+        ASSERT_NOT_REACHED();
+}
+
 void NetworkProcess::removePrevalentDomains(PAL::SessionID sessionID, const Vector<String>& domains)
 {
     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (226234 => 226235)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2017-12-21 19:56:45 UTC (rev 226235)
@@ -140,6 +140,7 @@
     void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool shouldClearFirst);
     void hasStorageAccessForPrevalentDomains(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId);
     void updateStorageAccessForPrevalentDomains(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, bool value, uint64_t contextId);
+    void removeStorageAccess(PAL::SessionID, uint64_t frameID, uint64_t pageID);
     void removePrevalentDomains(PAL::SessionID, const Vector<String>& domains);
 #endif
 

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (226234 => 226235)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2017-12-21 19:56:45 UTC (rev 226235)
@@ -85,6 +85,7 @@
     UpdatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID sessionID, Vector<String> domainsToPartition, Vector<String> domainsToBlock, Vector<String> domainsToNeitherPartitionNorBlock, bool shouldClearFirst)
     HasStorageAccessForPrevalentDomains(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
     UpdateStorageAccessForPrevalentDomains(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, bool shouldGrantAccess, uint64_t contextId)
+    RemoveStorageAccess(PAL::SessionID sessionID, uint64_t frameID, uint64_t pageID);
     RemovePrevalentDomains(PAL::SessionID sessionID, Vector<String> domainsWithInteraction);
 #endif
 }

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (226234 => 226235)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2017-12-21 19:56:45 UTC (rev 226235)
@@ -424,6 +424,11 @@
     send(Messages::NetworkProcess::UpdateStorageAccessForPrevalentDomains(sessionID, resourceDomain, firstPartyDomain, frameID, pageID, value, contextId), 0);
 }
 
+void NetworkProcessProxy::removeStorageAccess(PAL::SessionID sessionID, uint64_t frameID, uint64_t pageID)
+{
+    send(Messages::NetworkProcess::RemoveStorageAccess(sessionID, frameID, pageID), 0);
+}
+
 void NetworkProcessProxy::storageAccessRequestResult(bool wasGranted, uint64_t contextId)
 {
     auto callback = m_storageAccessResponseCallbackMap.take(contextId);

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (226234 => 226235)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2017-12-21 19:56:45 UTC (rev 226235)
@@ -80,6 +80,7 @@
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     void hasStorageAccessForPrevalentDomains(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
     void updateStorageAccessForPrevalentDomains(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, bool value, CompletionHandler<void(bool)>&& callback);
+    void removeStorageAccess(PAL::SessionID, uint64_t frameID, uint64_t pageID);
 #endif
 
     void processReadyToSuspend();

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (226234 => 226235)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2017-12-21 19:56:45 UTC (rev 226235)
@@ -7182,6 +7182,7 @@
     iterator->value->stopTask(*this, taskIdentifier);
 }
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
 void WebPageProxy::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, uint64_t webProcessContextId)
 {
     m_websiteDataStore->hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, [this, webProcessContextId] (bool hasAccess) {
@@ -7197,6 +7198,13 @@
     });
 }
 
+void WebPageProxy::removeStorageAccess(uint64_t frameID, uint64_t pageID)
+{
+    ASSERT(pageID == m_pageID);
+    m_websiteDataStore->removeStorageAccess(frameID, pageID);
+}
+#endif
+
 #if PLATFORM(COCOA)
 void WebPageProxy::touchBarMenuDataChanged(const TouchBarMenuData& touchBarMenuData)
 {

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp.orig (226234 => 226235)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp.orig	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp.orig	2017-12-21 19:56:45 UTC (rev 226235)
@@ -6928,11 +6928,6 @@
     m_uiClient->didClickAutoFillButton(*this, m_process->transformHandlesToObjects(userData.object()).get());
 }
 
-void WebPageProxy::handleAlternativePresentationButtonClick(const UserData& userData)
-{
-    m_uiClient->didClickAlternativePresentationButton(*this, m_process->transformHandlesToObjects(userData.object()).get());
-}
-
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
 void WebPageProxy::addPlaybackTargetPickerClient(uint64_t contextId)
 {

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (226234 => 226235)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2017-12-21 19:56:45 UTC (rev 226235)
@@ -1246,8 +1246,11 @@
     void touchBarMenuItemDataRemoved(const TouchBarMenuItemData&);
 #endif
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, uint64_t webProcessContextId);
     void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, uint64_t webProcessContextId);
+    void removeStorageAccess(uint64_t frameID, uint64_t pageID);
+#endif
 
 #if ENABLE(ATTACHMENT_ELEMENT)
     void insertAttachment(const String& identifier, const WebCore::AttachmentDisplayOptions&, const String& filename, std::optional<String> contentType, WebCore::SharedBuffer& data, Function<void(CallbackBase::Error)>&&);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (226234 => 226235)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2017-12-21 19:56:45 UTC (rev 226235)
@@ -505,8 +505,11 @@
     StartURLSchemeTask(struct WebKit::URLSchemeTaskParameters parameters)
     StopURLSchemeTask(uint64_t handlerIdentifier, uint64_t taskIdentifier)
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     HasStorageAccess(String subFrameHost, String topFrameHost, uint64_t frameID, uint64_t pageID, uint64_t contextID)
     RequestStorageAccess(String subFrameHost, String topFrameHost, uint64_t frameID, uint64_t pageID, uint64_t contextID)
+    RemoveStorageAccess(uint64_t frameID, uint64_t pageID)
+#endif
 
 #if ENABLE(ATTACHMENT_ELEMENT)
     DidInsertAttachment(String identifier)

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (226234 => 226235)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2017-12-21 19:56:45 UTC (rev 226235)
@@ -1193,6 +1193,32 @@
     for (auto& processPool : processPools())
         processPool->sendToNetworkingProcess(Messages::NetworkProcess::RemovePrevalentDomains(m_sessionID, domains));
 }
+
+void WebsiteDataStore::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback)
+{
+    if (!resourceLoadStatisticsEnabled()) {
+        callback(false);
+        return;
+    }
+    
+    m_resourceLoadStatistics->hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(callback));
+}
+
+void WebsiteDataStore::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback)
+{
+    if (!resourceLoadStatisticsEnabled()) {
+        callback(false);
+        return;
+    }
+    
+    m_resourceLoadStatistics->requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(callback));
+}
+
+void WebsiteDataStore::removeStorageAccess(uint64_t frameID, uint64_t pageID)
+{
+    for (auto& processPool : processPools())
+        processPool->networkProcess()->removeStorageAccess(m_sessionID, frameID, pageID);
+}
 #endif
 
 void WebsiteDataStore::networkProcessDidCrash()
@@ -1444,26 +1470,6 @@
     m_pendingCookies.remove(cookie);
 }
 
-void WebsiteDataStore::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback)
-{
-    if (!resourceLoadStatisticsEnabled()) {
-        callback(false);
-        return;
-    }
-    
-    m_resourceLoadStatistics->hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(callback));
-}
-    
-void WebsiteDataStore::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback)
-{
-    if (!resourceLoadStatisticsEnabled()) {
-        callback(false);
-        return;
-    }
-
-    m_resourceLoadStatistics->requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(callback));
-}
-
 #if !PLATFORM(COCOA)
 WebsiteDataStoreParameters WebsiteDataStore::parameters()
 {

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (226234 => 226235)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2017-12-21 19:56:45 UTC (rev 226235)
@@ -121,6 +121,9 @@
     void hasStorageAccessForPrevalentDomainsHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool hasAccess)>&& callback);
     void updateStorageAccessForPrevalentDomainsHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, bool value, WTF::CompletionHandler<void(bool wasGranted)>&& callback);
     void removePrevalentDomains(const Vector<String>& domains);
+    void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback);
+    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback);
+    void removeStorageAccess(uint64_t frameID, uint64_t pageID);
 #endif
     void networkProcessDidCrash();
     void resolveDirectoriesIfNecessary();
@@ -147,9 +150,6 @@
 
     void enableResourceLoadStatisticsAndSetTestingCallback(Function<void (const String&)>&& callback);
 
-    void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback);
-    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback);
-    
     void setBoundInterfaceIdentifier(String&& identifier) { m_boundInterfaceIdentifier = WTFMove(identifier); }
     const String& boundInterfaceIdentifier() { return m_boundInterfaceIdentifier; }
     

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (226234 => 226235)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2017-12-21 19:56:45 UTC (rev 226235)
@@ -1253,6 +1253,7 @@
     m_page.findController().didInvalidateDocumentMarkerRects();
 }
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
 void WebChromeClient::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback)
 {
     m_page.hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(callback));
@@ -1262,5 +1263,6 @@
 {
     m_page.requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(callback));
 }
+#endif
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (226234 => 226235)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2017-12-21 19:56:45 UTC (rev 226235)
@@ -348,8 +348,10 @@
 
     void didInvalidateDocumentMarkerRects() final;
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&&) final;
     void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&&) final;
+#endif
 
     String m_cachedToolTip;
     mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (226234 => 226235)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2017-12-21 19:56:45 UTC (rev 226235)
@@ -166,6 +166,13 @@
     if (!webPage)
         return;
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+    if (m_hasFrameSpecificStorageAccess) {
+        webPage->send(Messages::WebPageProxy::RemoveStorageAccess(frameID().value(), pageID().value()));
+        m_hasFrameSpecificStorageAccess = false;
+    }
+#endif
+
     RefPtr<API::Object> userData;
 
     // Notify the bundle client.
@@ -372,6 +379,23 @@
     webPage->send(Messages::WebPageProxy::DidChangeMainDocument(m_frame->frameID()));
 }
 
+void WebFrameLoaderClient::dispatchWillChangeDocument()
+{
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+    if (m_frame->isMainFrame())
+        return;
+
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    if (m_hasFrameSpecificStorageAccess) {
+        webPage->send(Messages::WebPageProxy::RemoveStorageAccess(frameID().value(), pageID().value()));
+        m_hasFrameSpecificStorageAccess = false;
+    }
+#endif
+}
+
 void WebFrameLoaderClient::dispatchDidPushStateWithinPage()
 {
     WebPage* webPage = m_frame->page();

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (226234 => 226235)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2017-12-21 19:56:45 UTC (rev 226235)
@@ -55,6 +55,11 @@
     std::optional<uint64_t> frameID() const final;
     PAL::SessionID sessionID() const final;
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+    bool hasFrameSpecificStorageAccess() { return m_hasFrameSpecificStorageAccess; }
+    void setHasFrameSpecificStorageAccess(bool value) { m_hasFrameSpecificStorageAccess = value; };
+#endif
+    
 private:
     void frameLoaderDestroyed() final;
 
@@ -92,6 +97,7 @@
     void dispatchDidFinishDataDetection(NSArray *detectionResults) final;
 #endif
     void dispatchDidChangeMainDocument() final;
+    void dispatchWillChangeDocument() final;
 
     void dispatchDidDispatchOnloadEvents() final;
     void dispatchDidReceiveServerRedirectForProvisionalLoad() final;
@@ -273,6 +279,9 @@
     bool m_frameHasCustomContentProvider;
     bool m_frameCameFromPageCache;
     bool m_useIconLoadingClient { false };
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+    bool m_hasFrameSpecificStorageAccess { false };
+#endif
 };
 
 // As long as EmptyFrameLoaderClient exists in WebCore, this can return 0.

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (226234 => 226235)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-12-21 19:56:45 UTC (rev 226235)
@@ -5798,6 +5798,7 @@
     handler->taskDidComplete(taskIdentifier, error);
 }
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
 static uint64_t nextRequestStorageAccessContextId()
 {
     static uint64_t nextContextId = 0;
@@ -5832,6 +5833,7 @@
     ASSERT(callback);
     callback(wasGranted);
 }
+#endif
 
 void WebPage::invokeSharedBufferCallback(RefPtr<SharedBuffer>&& buffer, CallbackID callbackID)
 {

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (226234 => 226235)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2017-12-21 19:56:45 UTC (rev 226235)
@@ -1032,9 +1032,11 @@
     void sendPartialEditorStateAndSchedulePostLayoutUpdate();
     void flushPendingEditorStateUpdate();
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback);
     void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback);
     void storageAccessResponse(bool wasGranted, uint64_t contextId);
+#endif
 
 #if ENABLE(ATTACHMENT_ELEMENT)
     void insertAttachment(const String& identifier, const WebCore::AttachmentDisplayOptions&, const String& filename, std::optional<String> contentType, const IPC::DataReference&, CallbackID);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (226234 => 226235)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2017-12-21 19:51:35 UTC (rev 226234)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2017-12-21 19:56:45 UTC (rev 226235)
@@ -488,7 +488,9 @@
     URLSchemeTaskDidReceiveData(uint64_t handlerIdentifier, uint64_t taskIdentifier, IPC::DataReference data)
     URLSchemeTaskDidComplete(uint64_t handlerIdentifier, uint64_t taskIdentifier, WebCore::ResourceError error)
 
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     StorageAccessResponse(bool wasGranted, uint64_t contextId)
+#endif
 
 #if ENABLE(ATTACHMENT_ELEMENT)
     InsertAttachment(String identifier, struct WebCore::AttachmentDisplayOptions options, String filename, std::optional<String> contentType, IPC::DataReference data, WebKit::CallbackID callbackID)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to