Title: [225583] trunk
Revision
225583
Author
[email protected]
Date
2017-12-06 11:41:01 -0800 (Wed, 06 Dec 2017)

Log Message

Storage Access API: Make document.hasStorageAccess a function and always allow access for same-origin iframes
https://bugs.webkit.org/show_bug.cgi?id=176944
<rdar://problem/34440658>

Reviewed by Brent Fulgham.

Source/WebCore:

Test: http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture.html

This change introduces document.hasStorageAccess() as a function which
returns a promise instead of being a property. Since cookie access can
be due to both a granted request and recent user interaction as first
party, the WebKit::WebResourceLoadStatisticsStore needs to be consulted.

* dom/Document.cpp:
(WebCore::Document::hasStorageAccess):
(WebCore::Document::requestStorageAccess):
    Removed check of the previous m_hasStorageAccess member.
    Same-origin check done earlier. This was a request/suggestion
    from Mozilla.
* dom/Document.h:
(WebCore::Document::hasStorageAccess const): Deleted.
    Now uses a promise.
* dom/Document.idl:
* page/ChromeClient.h:

Source/WebKit:

This change introduces document.hasStorageAccess() as a function which
returns a promise instead of being a property. Since cookie access can
be due to both a granted request and recent user interaction as first
party, the WebKit::WebResourceLoadStatisticsStore needs to be consulted.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::hasStorageAccess):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::hasStorageAccess):
(WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
    Now adds an entry for granted access. A bug found through testing.
    Switched from WTF::Function to WTF::CompletionHandler.
* UIProcess/WebResourceLoadStatisticsStore.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::hasStorageAccess):
(WebKit::WebsiteDataStore::requestStorageAccess):
    Switched from WTF::Function to WTF::CompletionHandler.
* UIProcess/WebsiteData/WebsiteDataStore.h:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::hasStorageAccess):
(WebKit::WebChromeClient::requestStorageAccess):
    Switched from WTF::Function to WTF::CompletionHandler.
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::hasStorageAccess):
(WebKit::WebPage::requestStorageAccess):
    Switched from WTF::Function to WTF::CompletionHandler.
* WebProcess/WebPage/WebPage.h:

LayoutTests:

These tests now use the new document.hasStorageAccess() function
instead of the previous document.hasStorageAccess property.
The added test is a break out of the negative case of an iframe
calling the API when no user gesture is processed.

* http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe-expected.txt:
* http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe.html:
* http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt:
* http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html:
* 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-non-sandboxed-iframe.html:
* 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-expected.txt:
* http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction.html:
* 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-and-grant-storage-access-cross-origin-sandboxed-nested-iframe.html:
* 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-without-allow-token-expected.txt:
* http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html:
* http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture-expected.txt: Added.
* http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture.html: Added.
* http/tests/storageAccess/request-storage-access-same-origin-iframe-expected.txt:
* http/tests/storageAccess/request-storage-access-same-origin-iframe.html:
* 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/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html:
* http/tests/storageAccess/request-storage-access-top-frame-expected.txt:
* http/tests/storageAccess/request-storage-access-top-frame.html:
* http/tests/storageAccess/resources/request-storage-access-iframe.html:
* http/tests/storageAccess/resources/request-storage-access-without-user-gesture-iframe.html: Added.
* platform/mac-wk2/TestExpectations:
    Marked the new test case as [ Pass ]

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (225582 => 225583)


--- trunk/LayoutTests/ChangeLog	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/ChangeLog	2017-12-06 19:41:01 UTC (rev 225583)
@@ -1,3 +1,46 @@
+2017-12-06  John Wilander  <[email protected]>
+
+        Storage Access API: Make document.hasStorageAccess a function and always allow access for same-origin iframes
+        https://bugs.webkit.org/show_bug.cgi?id=176944
+        <rdar://problem/34440658>
+
+        Reviewed by Brent Fulgham.
+
+        These tests now use the new document.hasStorageAccess() function
+        instead of the previous document.hasStorageAccess property.
+        The added test is a break out of the negative case of an iframe
+        calling the API when no user gesture is processed.
+
+        * http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe-expected.txt:
+        * http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe.html:
+        * http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt:
+        * http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html:
+        * 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-non-sandboxed-iframe.html:
+        * 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-expected.txt:
+        * http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction.html:
+        * 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-and-grant-storage-access-cross-origin-sandboxed-nested-iframe.html:
+        * 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-without-allow-token-expected.txt:
+        * http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html:
+        * http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture-expected.txt: Added.
+        * http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture.html: Added.
+        * http/tests/storageAccess/request-storage-access-same-origin-iframe-expected.txt:
+        * http/tests/storageAccess/request-storage-access-same-origin-iframe.html:
+        * 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/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html:
+        * http/tests/storageAccess/request-storage-access-top-frame-expected.txt:
+        * http/tests/storageAccess/request-storage-access-top-frame.html:
+        * http/tests/storageAccess/resources/request-storage-access-iframe.html:
+        * http/tests/storageAccess/resources/request-storage-access-without-user-gesture-iframe.html: Added.
+        * platform/mac-wk2/TestExpectations:
+            Marked the new test case as [ Pass ]
+
 2017-12-06  Chris Dumez  <[email protected]>
 
         ServiceWorkers API should reject promises when calling objects inside detached frames

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


--- trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was denied.
+PASS Storage access was denied.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe.html (225582 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe.html	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-iframe.html	2017-12-06 19:41:01 UTC (rev 225583)
@@ -7,8 +7,19 @@
         description("Tests that cross-origin iframe storage access is denied if the iframe is not sandboxed.");
         jsTestIsAsync = true;
 
+        const hostUnderTest = "localhost:8000";
+        const statisticsUrl = "http://" + hostUnderTest + "/temp";
+
         window.addEventListener("message", receiveMessage, false);
 
+        function setEnableFeature(enable) {
+            if (!enable)
+                testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(enable);
+            testRunner.setCookieStoragePartitioningEnabled(enable);
+            testRunner.setStorageAccessAPIEnabled(enable);
+        }
+
         function receiveMessage(event) {
             if (event.origin === "http://localhost:8000") {
                 if (event.data.indexOf("PASS") !== -1)
@@ -17,6 +28,7 @@
                     testFailed(event.data.replace("FAIL ", ""));
             } else
                 testFailed("Received a message from an unexpected origin: " + event.origin);
+            setEnableFeature(false);
             finishJSTest();
         }
 
@@ -30,11 +42,13 @@
                         eventSender.keyDown("escape");
                     else {
                         testFailed("No eventSender.");
+                        setEnableFeature(false);
                         finishJSTest();
                     }
                 },
                 function () {
                     testFailed("Promise rejected.");
+                    setEnableFeature(false);
                     finishJSTest();
                 }
             );
@@ -41,6 +55,16 @@
         }
 
         function runTest() {
+            setEnableFeature(true);
+
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as prevalent resource.");
+            testRunner.setStatisticsHasHadNonRecentUserInteraction(statisticsUrl);
+            if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                testFailed("Host did not get logged for user interaction.");
+            testRunner.statisticsUpdateCookiePartitioning();
+
             activateElement("theIframe");
         }
     </script>

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


--- trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -4,7 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was denied.
+PASS Storage access was denied.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html (225582 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html	2017-12-06 19:41:01 UTC (rev 225583)
@@ -7,8 +7,19 @@
         description("Tests that cross-origin iframe storage access is denied if the iframe is sandboxed, has the allow token, but the user opts out.");
         jsTestIsAsync = true;
 
+        const hostUnderTest = "localhost:8000";
+        const statisticsUrl = "http://" + hostUnderTest + "/temp";
+
         window.addEventListener("message", receiveMessage, false);
 
+        function setEnableFeature(enable) {
+            if (!enable)
+                testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(enable);
+            testRunner.setCookieStoragePartitioningEnabled(enable);
+            testRunner.setStorageAccessAPIEnabled(enable);
+        }
+
         function receiveMessage(event) {
             if (event.origin === "http://localhost:8000") {
                 if (event.data.indexOf("PASS") !== -1)
@@ -18,6 +29,7 @@
             } else
                 testFailed("Received a message from an unexpected origin: " + event.origin);
             finishJSTest();
+            setEnableFeature(false);
         }
 
         function activateElement(elementId) {
@@ -31,17 +43,29 @@
                     else {
                         testFailed("No eventSender.");
                         finishJSTest();
+                        setEnableFeature(false);
                     }
                 },
                 function () {
                     testFailed("Promise rejected.");
                     finishJSTest();
+                    setEnableFeature(false);
                 }
             );
         }
 
         function runTest() {
-            setTimeout('activateElement("theIframe")', 500);
+            setEnableFeature(true);
+
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as prevalent resource.");
+            testRunner.setStatisticsHasHadNonRecentUserInteraction(statisticsUrl);
+            if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                testFailed("Host did not get logged for user interaction.");
+            testRunner.statisticsUpdateCookiePartitioning();
+
+            activateElement("theIframe");
         }
     </script>
 </head>

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


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-non-sandboxed-iframe-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-non-sandboxed-iframe-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was denied.
+PASS Storage access was denied.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-non-sandboxed-iframe.html (225582 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-non-sandboxed-iframe.html	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-non-sandboxed-iframe.html	2017-12-06 19:41:01 UTC (rev 225583)
@@ -7,8 +7,19 @@
         description("Tests that cross-origin iframe storage access is denied if the iframe is not sandboxed.");
         jsTestIsAsync = true;
 
+        const hostUnderTest = "localhost:8000";
+        const statisticsUrl = "http://" + hostUnderTest + "/temp";
+
         window.addEventListener("message", receiveMessage, false);
 
+        function setEnableFeature(enable) {
+            if (!enable)
+                testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(enable);
+            testRunner.setCookieStoragePartitioningEnabled(enable);
+            testRunner.setStorageAccessAPIEnabled(enable);
+        }
+
         function receiveMessage(event) {
             if (event.origin === "http://localhost:8000") {
                 if (event.data.indexOf("PASS ") !== -1)
@@ -18,6 +29,7 @@
             } else
                 testFailed("Received a message from an unexpected origin: " + event.origin);
             finishJSTest();
+            setEnableFeature(false);
         }
 
         function activateElement(elementId) {
@@ -31,16 +43,28 @@
                     else {
                         testFailed("No eventSender.");
                         finishJSTest();
+                        setEnableFeature(false);
                     }
                 },
                 function () {
                     testFailed("Promise rejected.");
                     finishJSTest();
+                    setEnableFeature(false);
                 }
             );
         }
 
         function runTest() {
+            setEnableFeature(true);
+
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as prevalent resource.");
+            testRunner.setStatisticsHasHadNonRecentUserInteraction(statisticsUrl);
+            if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                testFailed("Host did not get logged for user interaction.");
+            testRunner.statisticsUpdateCookiePartitioning();
+
             activateElement("theIframe");
         }
     </script>

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


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -4,7 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was granted.
+PASS Storage access was granted.
 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-expected.txt (225582 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -4,7 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was granted.
+PASS Storage access was granted.
 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.html (225582 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction.html	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction.html	2017-12-06 19:41:01 UTC (rev 225583)
@@ -59,11 +59,13 @@
                         eventSender.keyDown("escape");
                     else {
                         testFailed("No eventSender.");
+                        setEnableFeature(false);
                         finishJSTest();
                     }
                 },
                 function () {
                     testFailed("Promise rejected.");
+                    setEnableFeature(false);
                     finishJSTest();
                 }
             );

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


--- 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-06 19:38:23 UTC (rev 225582)
+++ 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-06 19:41:01 UTC (rev 225583)
@@ -4,7 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was granted.
+PASS Storage access was granted.
 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 (225582 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -4,7 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was denied.
+PASS Storage access was denied.
 PASS successfullyParsed is true
 
 TEST COMPLETE

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


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-nested-iframe-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-nested-iframe-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was denied.
+PASS Storage access was denied.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-nested-iframe.html (225582 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-nested-iframe.html	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-nested-iframe.html	2017-12-06 19:41:01 UTC (rev 225583)
@@ -7,8 +7,19 @@
         description("Tests that cross-origin iframe storage access is denied if the iframe is sandboxed, has the allow token, but is nested.");
         jsTestIsAsync = true;
 
+        const hostUnderTest = "localhost:8000";
+        const statisticsUrl = "http://" + hostUnderTest + "/temp";
+
         window.addEventListener("message", receiveMessage, false);
 
+        function setEnableFeature(enable) {
+            if (!enable)
+                testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(enable);
+            testRunner.setCookieStoragePartitioningEnabled(enable);
+            testRunner.setStorageAccessAPIEnabled(enable);
+        }
+
         function receiveMessage(event) {
             if (event.origin === "http://localhost:8000") {
                 if (event.data.indexOf("PASS") !== -1)
@@ -17,6 +28,7 @@
                     testFailed(event.data.replace("FAIL ", ""));
             } else
                 testFailed("Received a message from an unexpected origin: " + event.origin);
+            setEnableFeature(false);
             finishJSTest();
         }
 
@@ -30,11 +42,13 @@
                         eventSender.keyDown("escape");
                     else {
                         testFailed("No eventSender.");
+                        setEnableFeature(false);
                         finishJSTest();
                     }
                 },
                 function () {
                     testFailed("Promise rejected.");
+                    setEnableFeature(false);
                     finishJSTest();
                 }
             );
@@ -41,7 +55,17 @@
         }
 
         function runTest() {
-            setTimeout('activateElement("theIframe")', 500);
+            setEnableFeature(true);
+
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as prevalent resource.");
+            testRunner.setStatisticsHasHadNonRecentUserInteraction(statisticsUrl);
+            if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                testFailed("Host did not get logged for user interaction.");
+            testRunner.statisticsUpdateCookiePartitioning();
+
+            activateElement("theIframe");
         }
     </script>
 </head>

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


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was denied.
+PASS Storage access was denied.
 PASS successfullyParsed is true
 
 TEST COMPLETE

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


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was denied.
+PASS Storage access was denied.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html (225582 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html	2017-12-06 19:41:01 UTC (rev 225583)
@@ -7,8 +7,19 @@
         description("Tests that cross-origin iframe storage access is denied if the iframe is sandboxed and doesn't have the allow token.");
         jsTestIsAsync = true;
 
+        const hostUnderTest = "localhost:8000";
+        const statisticsUrl = "http://" + hostUnderTest + "/temp";
+
         window.addEventListener("message", receiveMessage, false);
 
+        function setEnableFeature(enable) {
+            if (!enable)
+                testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(enable);
+            testRunner.setCookieStoragePartitioningEnabled(enable);
+            testRunner.setStorageAccessAPIEnabled(enable);
+        }
+
         function receiveMessage(event) {
             if (event.origin === "http://localhost:8000") {
                 if (event.data.indexOf("PASS") !== -1)
@@ -17,6 +28,7 @@
                     testFailed(event.data.replace("FAIL ", ""));
             } else
                 testFailed("Received a message from an unexpected origin: " + event.origin);
+            setEnableFeature(false);
             finishJSTest();
         }
 
@@ -30,11 +42,13 @@
                         eventSender.keyDown("escape");
                     else {
                         testFailed("No eventSender.");
+                        setEnableFeature(false);
                         finishJSTest();
                     }
                 },
                 function () {
                     testFailed("Promise rejected.");
+                    setEnableFeature(false);
                     finishJSTest();
                 }
             );
@@ -41,6 +55,16 @@
         }
 
         function runTest() {
+            setEnableFeature(true);
+
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as prevalent resource.");
+            testRunner.setStatisticsHasHadNonRecentUserInteraction(statisticsUrl);
+            if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                testFailed("Host did not get logged for user interaction.");
+            testRunner.statisticsUpdateCookiePartitioning();
+
             activateElement("theIframe");
         }
     </script>

Copied: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture-expected.txt (from rev 225581, trunk/LayoutTests/http/tests/storageAccess/request-and-grant-storage-access-cross-origin-non-sandboxed-iframe-expected.txt) (0 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -0,0 +1,10 @@
+Tests that cross-origin iframe storage access is denied if the iframe is sandboxed, has the allow token, but calls the API without a user gesture being processed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Storage access was denied.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture.html (0 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture.html	2017-12-06 19:41:01 UTC (rev 225583)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script>
+        description("Tests that cross-origin iframe storage access is denied if the iframe is sandboxed, has the allow token, but calls the API without a user gesture being processed.");
+        jsTestIsAsync = true;
+
+        const hostUnderTest = "localhost:8000";
+        const statisticsUrl = "http://" + hostUnderTest + "/temp";
+
+        window.addEventListener("message", receiveMessage, false);
+
+        function setEnableFeature(enable) {
+            if (!enable)
+                testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(enable);
+            testRunner.setCookieStoragePartitioningEnabled(enable);
+            testRunner.setStorageAccessAPIEnabled(enable);
+        }
+
+        function receiveMessage(event) {
+            if (event.origin === "http://localhost:8000") {
+                if (event.data.indexOf("PASS") !== -1)
+                    testPassed(event.data.replace("PASS ", ""));
+                else
+                    testFailed(event.data.replace("FAIL ", ""));
+            } else
+                testFailed("Received a message from an unexpected origin: " + event.origin);
+            setEnableFeature(false);
+            finishJSTest();
+        }
+
+        setEnableFeature(true);
+
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as prevalent resource.");
+        testRunner.setStatisticsHasHadNonRecentUserInteraction(statisticsUrl);
+        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" id="theIframe" src=""
+</body>
+</html>
\ No newline at end of file

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


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-iframe-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-iframe-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -1,9 +1,9 @@
-Tests that same-origin iframe storage access is denied if the iframe is not sandboxed.
+Tests that same-origin iframe storage access is granted if the iframe is not sandboxed.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was denied.
+PASS Storage access was granted.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-iframe.html (225582 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-iframe.html	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-iframe.html	2017-12-06 19:41:01 UTC (rev 225583)
@@ -4,7 +4,7 @@
     <script src=""
     <script src=""
     <script>
-        description("Tests that same-origin iframe storage access is denied if the iframe is not sandboxed.");
+        description("Tests that same-origin iframe storage access is granted if the iframe is not sandboxed.");
         jsTestIsAsync = true;
 
         window.addEventListener("message", receiveMessage, false);
@@ -46,6 +46,6 @@
     </script>
 </head>
 <body>
-    <iframe _onload_="runTest()" id="theIframe" src=""
+    <iframe _onload_="runTest()" id="theIframe" src=""
 </body>
 </html>
\ No newline at end of file

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


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was granted.
+PASS Storage access was granted.
 PASS successfullyParsed is true
 
 TEST COMPLETE

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


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-without-allow-token-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-without-allow-token-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -1,9 +1,9 @@
-Tests that same-origin iframe storage access is denied if the iframe is sandboxed but doesn't have the allow token.
+Tests that same-origin iframe storage access is granted if the iframe is sandboxed but doesn't have the allow token.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.hasStorageAccess was denied.
+PASS Storage access was granted.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html (225582 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html	2017-12-06 19:41:01 UTC (rev 225583)
@@ -4,11 +4,22 @@
     <script src=""
     <script src=""
     <script>
-        description("Tests that same-origin iframe storage access is denied if the iframe is sandboxed but doesn't have the allow token.");
+        description("Tests that same-origin iframe storage access is granted if the iframe is sandboxed but doesn't have the allow token.");
         jsTestIsAsync = true;
 
+        const hostUnderTest = "localhost:8000";
+        const statisticsUrl = "http://" + hostUnderTest + "/temp";
+
         window.addEventListener("message", receiveMessage, false);
 
+        function setEnableFeature(enable) {
+            if (!enable)
+                testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(enable);
+            testRunner.setCookieStoragePartitioningEnabled(enable);
+            testRunner.setStorageAccessAPIEnabled(enable);
+        }
+
         function receiveMessage(event) {
             if (event.origin === "http://127.0.0.1:8000") {
                 if (event.data.indexOf("PASS") !== -1)
@@ -17,6 +28,7 @@
                     testFailed(event.data.replace("FAIL ", ""));
             } else
                 testFailed("Received a message from an unexpected origin: " + event.origin);
+            setEnableFeature(false);
             finishJSTest();
         }
 
@@ -30,11 +42,13 @@
                         eventSender.keyDown("escape");
                     else {
                         testFailed("No eventSender.");
+                        setEnableFeature(false);
                         finishJSTest();
                     }
                 },
                 function () {
                     testFailed("Promise rejected.");
+                    setEnableFeature(false);
                     finishJSTest();
                 }
             );
@@ -41,11 +55,21 @@
         }
 
         function runTest() {
+            setEnableFeature(true);
+
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host did not get set as prevalent resource.");
+            testRunner.setStatisticsHasHadNonRecentUserInteraction(statisticsUrl);
+            if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
+                testFailed("Host did not get logged for user interaction.");
+            testRunner.statisticsUpdateCookiePartitioning();
+
             activateElement("theIframe");
         }
     </script>
 </head>
 <body>
-    <iframe sandbox="allow-scripts allow-same-origin allow-modals" _onload_="runTest()" id="theIframe" src=""
+    <iframe sandbox="allow-scripts allow-same-origin allow-modals" _onload_="runTest()" id="theIframe" src=""
 </body>
 </html>
\ No newline at end of file

Modified: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-top-frame-expected.txt (225582 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-top-frame-expected.txt	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-top-frame-expected.txt	2017-12-06 19:41:01 UTC (rev 225583)
@@ -4,9 +4,7 @@
 
 
 PASS requestStorageAccessResolved is true
-PASS document.hasStorageAccess is true
-PASS requestStorageAccessResolved is true
-PASS document.hasStorageAccess is true
+PASS hasStorageAccess is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/storageAccess/request-storage-access-top-frame.html (225582 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/request-storage-access-top-frame.html	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/request-storage-access-top-frame.html	2017-12-06 19:41:01 UTC (rev 225583)
@@ -7,6 +7,14 @@
     description("Tests that top frame storage access is always granted in case the page requests it.");
     jsTestIsAsync = true;
 
+    function setEnableFeature(enable) {
+        if (!enable)
+            testRunner.statisticsResetToConsistentState();
+        internals.setResourceLoadStatisticsEnabled(enable);
+        testRunner.setCookieStoragePartitioningEnabled(enable);
+        testRunner.setStorageAccessAPIEnabled(enable);
+    }
+
     function activateElement(elementId) {
         var element = document.getElementById(elementId);
         var centerX = element.offsetLeft + element.offsetWidth / 2;
@@ -16,55 +24,49 @@
             },
             function () {
                 testFailed("Promise rejected.");
+                setEnableFeature(false);
                 finishJSTest();
             }
         );
     }
 
+    var hasStorageAccess;
     var requestStorageAccessResolved;
 
-    function makeRequestWithoutUserGesture() {
+    function makeRequestWithUserGesture() {
         var promise = document.requestStorageAccess();
         promise.then(
             function () {
                 requestStorageAccessResolved = true;
-                continueAfterRequestWithoutUserGesture();
+                continueAfterRequestWithUserGesture();
             },
             function () {
                 requestStorageAccessResolved = false;
-                continueAfterRequestWithoutUserGesture();
+                continueAfterRequestWithUserGesture();
             }
         );
     }
 
-    function continueAfterRequestWithoutUserGesture() {
-        shouldBe("requestStorageAccessResolved", "true");
-        shouldBe("document.hasStorageAccess", "true");
-        activateElement("theButton");
-    }
-
-    function makeRequestWithUserGesture() {
-        var promise = document.requestStorageAccess();
+    function continueAfterRequestWithUserGesture() {
+        var promise = document.hasStorageAccess();
         promise.then(
-            function () {
-                requestStorageAccessResolved = true;
-                continueAfterRequestWithUserGesture();
+            function (hasAccess) {
+                hasStorageAccess = hasAccess;
+                shouldBe("requestStorageAccessResolved", "true");
+                shouldBe("hasStorageAccess", "true");
+                setEnableFeature(false);
+                finishJSTest();
             },
-            function () {
-                requestStorageAccessResolved = false;
-                continueAfterRequestWithUserGesture();
+            function (reason) {
+                testFailed("document.hasStorageAccess() was rejected. Reason: " + reason);
+                setEnableFeature(false);
+                finishJSTest();
             }
         );
     }
 
-    function continueAfterRequestWithUserGesture() {
-        shouldBe("requestStorageAccessResolved", "true");
-        shouldBe("document.hasStorageAccess", "true");
-        finishJSTest();
-    }
-
     function runTest() {
-        makeRequestWithoutUserGesture();
+        activateElement("theButton");
     }
 </script>
 <button id="theButton" _onclick_="makeRequestWithUserGesture()">Request Access</button>

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


--- trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-iframe.html	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-iframe.html	2017-12-06 19:41:01 UTC (rev 225583)
@@ -5,90 +5,55 @@
         const userShouldGrantAccess = hashArguments[0] === "userShouldGrantAccess";
         const userShouldBeConsulted = hashArguments[1] === "userShouldBeConsulted";
         const policyShouldGrantAccess = hashArguments[2] === "policyShouldGrantAccess";
-        const isSameOriginIframe = hashArguments[3] === "isSameOriginIframe";
 
         if (internals && userShouldGrantAccess)
                 internals.setUserGrantsStorageAccess(true);
 
-        function storageAccessShouldBeFalse() {
-            if (document.hasStorageAccess)
-                top.postMessage("FAIL document.hasStorageAccess was true when it was not supposed to.", "http://127.0.0.1:8000");
-            if (requestStorageAccessResolved)
-                top.postMessage("FAIL requestStorageAccessResolved was true when it was not supposed to.", "http://127.0.0.1:8000");
-        }
-
-        function storageAccessShouldBeTrue() {
-            if (!document.hasStorageAccess)
-                top.postMessage("FAIL document.hasStorageAccess was false when it was not supposed to.", "http://127.0.0.1:8000");
-            if (!requestStorageAccessResolved)
-                top.postMessage("FAIL requestStorageAccessResolved was false when it was not supposed to.", "http://127.0.0.1:8000");
-        }
-
         var requestStorageAccessResolved;
 
-        function makeRequestWithoutUserGesture() {
-            storageAccessShouldBeFalse();
-
+        function makeRequestWithUserGesture() {
             var promise = document.requestStorageAccess();
             promise.then(
                 function () {
                     requestStorageAccessResolved = true;
-                    continueAfterRequestWithoutUserGesture();
+                    continueAfterRequestWithUserGesture();
                 },
                 function () {
                     requestStorageAccessResolved = false;
-                    continueAfterRequestWithoutUserGesture();
+                    continueAfterRequestWithUserGesture();
                 }
             );
         }
 
-        function continueAfterRequestWithoutUserGesture() {
-            if (isSameOriginIframe && policyShouldGrantAccess)
-                storageAccessShouldBeTrue();
-            else
-                storageAccessShouldBeFalse();
-        }
-
-        function makeRequestWithUserGesture() {
-            if (isSameOriginIframe && policyShouldGrantAccess)
-                storageAccessShouldBeTrue();
-            else
-                storageAccessShouldBeFalse();
-
-            var promise = document.requestStorageAccess();
+        function continueAfterRequestWithUserGesture() {
+            var promise = document.hasStorageAccess();
             promise.then(
-                function () {
-                    requestStorageAccessResolved = true;
-                    continueAfterRequestWithUserGesture();
+                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");
                 },
-                function () {
-                    requestStorageAccessResolved = false;
-                    continueAfterRequestWithUserGesture();
+                function (reason) {
+                    top.postMessage("FAIL document.hasStorageAccess() was rejected. Reason: " + reason, "http://127.0.0.1:8000");
                 }
             );
         }
-
-        function continueAfterRequestWithUserGesture() {
-            if (requestStorageAccessResolved
-                && document.hasStorageAccess
-                && (userShouldGrantAccess || !userShouldBeConsulted)
-                && policyShouldGrantAccess)
-                top.postMessage("PASS document.hasStorageAccess was granted.", "http://127.0.0.1:8000");
-            else if (!document.hasStorageAccess
-                    && !requestStorageAccessResolved
-                    && ((!userShouldGrantAccess && userShouldBeConsulted) || !policyShouldGrantAccess))
-                top.postMessage("PASS document.hasStorageAccess was denied.", "http://127.0.0.1:8000");
-            else
-                top.postMessage("FAIL document.hasStorageAccess was " +
-                    (document.hasStorageAccess ? "" : "not ") +
-                    "granted and requestStorageAccessResolved was " +
-                    (requestStorageAccessResolved ? "" : "not ") +
-                    "granted but should " +
-                    (userShouldGrantAccess && policyShouldGrantAccess ? "" : "not ") +
-                    "have been granted.", "http://127.0.0.1:8000");
-        }
     </script>
 </head>
-<body _onload_="makeRequestWithoutUserGesture()" _onclick_="makeRequestWithUserGesture()">
+<body _onclick_="makeRequestWithUserGesture()">
 </body>
 </html>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-without-user-gesture-iframe.html (0 => 225583)


--- trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-without-user-gesture-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-without-user-gesture-iframe.html	2017-12-06 19:41:01 UTC (rev 225583)
@@ -0,0 +1,59 @@
+<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 makeRequestWithoutUserGesture() {
+            var promise = document.requestStorageAccess();
+            promise.then(
+                function () {
+                    requestStorageAccessResolved = true;
+                    continueAfterRequestWithoutUserGesture();
+                },
+                function () {
+                    requestStorageAccessResolved = false;
+                    continueAfterRequestWithoutUserGesture();
+                }
+            );
+        }
+
+        function continueAfterRequestWithoutUserGesture() {
+            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");
+                },
+                function (reason) {
+                    top.postMessage("FAIL document.hasStorageAccess() was rejected. Reason: " + reason, "http://127.0.0.1:8000");
+                }
+            );
+        }
+    </script>
+</head>
+<body _onload_="makeRequestWithoutUserGesture()">
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (225582 => 225583)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2017-12-06 19:41:01 UTC (rev 225583)
@@ -759,6 +759,7 @@
 [ HighSierra+ ] http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction.html [ Pass ]
 http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction.html [ Pass ]
 http/tests/storageAccess/request-storage-access-top-frame.html [ Pass ]
+http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture.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/Source/WebCore/ChangeLog (225582 => 225583)


--- trunk/Source/WebCore/ChangeLog	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebCore/ChangeLog	2017-12-06 19:41:01 UTC (rev 225583)
@@ -1,3 +1,30 @@
+2017-12-06  John Wilander  <[email protected]>
+
+        Storage Access API: Make document.hasStorageAccess a function and always allow access for same-origin iframes
+        https://bugs.webkit.org/show_bug.cgi?id=176944
+        <rdar://problem/34440658>
+
+        Reviewed by Brent Fulgham.
+
+        Test: http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture.html
+
+        This change introduces document.hasStorageAccess() as a function which
+        returns a promise instead of being a property. Since cookie access can
+        be due to both a granted request and recent user interaction as first
+        party, the WebKit::WebResourceLoadStatisticsStore needs to be consulted.
+
+        * dom/Document.cpp:
+        (WebCore::Document::hasStorageAccess):
+        (WebCore::Document::requestStorageAccess):
+            Removed check of the previous m_hasStorageAccess member.
+            Same-origin check done earlier. This was a request/suggestion
+            from Mozilla.
+        * dom/Document.h:
+        (WebCore::Document::hasStorageAccess const): Deleted.
+            Now uses a promise.
+        * dom/Document.idl:
+        * page/ChromeClient.h:
+
 2017-12-06  Youenn Fablet  <[email protected]>
 
         REGRESSION (r225537): Crash in WebCore::SWServerWorker::setHasPendingEvents(bool) + 68

Modified: trunk/Source/WebCore/dom/Document.cpp (225582 => 225583)


--- trunk/Source/WebCore/dom/Document.cpp	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-12-06 19:41:01 UTC (rev 225583)
@@ -7397,17 +7397,51 @@
     return *m_logger;
 }
 
-void Document::requestStorageAccess(Ref<DeferredPromise>&& passedPromise)
+void Document::hasStorageAccess(Ref<DeferredPromise>&& passedPromise)
 {
     ASSERT(settings().storageAccessAPIEnabled());
-    
+
     RefPtr<DeferredPromise> promise(WTFMove(passedPromise));
+
+    if (!m_frame || securityOrigin().isUnique()) {
+        promise->resolve<IDLBoolean>(false);
+        return;
+    }
     
-    if (m_hasStorageAccess) {
-        promise->resolve();
+    if (m_frame->isMainFrame()) {
+        promise->resolve<IDLBoolean>(true);
         return;
     }
     
+    auto& securityOrigin = this->securityOrigin();
+    auto& topSecurityOrigin = topDocument().securityOrigin();
+    if (securityOrigin.equal(&topSecurityOrigin)) {
+        promise->resolve<IDLBoolean>(true);
+        return;
+    }
+
+    if (Page* page = this->page()) {
+        auto iframeHost = securityOrigin.host();
+        auto topHost = topSecurityOrigin.host();
+        page->chrome().client().hasStorageAccess(WTFMove(iframeHost), WTFMove(topHost), [documentReference = m_weakFactory.createWeakPtr(*this), promise] (bool hasAccess) {
+            Document* document = documentReference.get();
+            if (!document)
+                return;
+            
+            promise->resolve<IDLBoolean>(hasAccess);
+        });
+        return;
+    }
+
+    promise->reject();
+}
+
+void Document::requestStorageAccess(Ref<DeferredPromise>&& passedPromise)
+{
+    ASSERT(settings().storageAccessAPIEnabled());
+    
+    RefPtr<DeferredPromise> promise(WTFMove(passedPromise));
+    
     if (!m_frame || securityOrigin().isUnique()) {
         promise->reject();
         return;
@@ -7414,11 +7448,18 @@
     }
     
     if (m_frame->isMainFrame()) {
-        m_hasStorageAccess = true;
         promise->resolve();
         return;
     }
     
+    auto& topDocument = this->topDocument();
+    auto& topSecurityOrigin = topDocument.securityOrigin();
+    auto& securityOrigin = this->securityOrigin();
+    if (securityOrigin.equal(&topSecurityOrigin)) {
+        promise->resolve();
+        return;
+    }
+    
     // There has to be a sandbox and it has to allow the storage access API to be called.
     if (sandboxFlags() == SandboxNone || isSandboxed(SandboxStorageAccessByUserActivation)) {
         promise->reject();
@@ -7426,20 +7467,11 @@
     }
 
     // The iframe has to be a direct child of the top document.
-    auto& topDocument = this->topDocument();
     if (&topDocument != parentDocument()) {
         promise->reject();
         return;
     }
 
-    auto& securityOrigin = this->securityOrigin();
-    auto& topSecurityOrigin = topDocument.securityOrigin();
-    if (securityOrigin.equal(&topSecurityOrigin)) {
-        m_hasStorageAccess = true;
-        promise->resolve();
-        return;
-    }
-    
     if (!UserGestureIndicator::processingUserGesture()) {
         promise->reject();
         return;
@@ -7461,10 +7493,9 @@
             if (!document)
                 return;
 
-            if (wasGranted) {
-                document->m_hasStorageAccess = true;
+            if (wasGranted)
                 promise->resolve();
-            } else
+            else
                 promise->reject();
         });
         return;

Modified: trunk/Source/WebCore/dom/Document.h (225582 => 225583)


--- trunk/Source/WebCore/dom/Document.h	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebCore/dom/Document.h	2017-12-06 19:41:01 UTC (rev 225583)
@@ -1373,7 +1373,7 @@
 
     PAL::Logger& logger();
 
-    bool hasStorageAccess() const { return m_hasStorageAccess; };
+    void hasStorageAccess(Ref<DeferredPromise>&& passedPromise);
     void requestStorageAccess(Ref<DeferredPromise>&& passedPromise);
     void setUserGrantsStorageAccessOverride(bool value) { m_grantStorageAccessOverride = value; }
 
@@ -1860,7 +1860,6 @@
 
     static bool hasEverCreatedAnAXObjectCache;
 
-    bool m_hasStorageAccess { false };
     bool m_grantStorageAccessOverride { false };
 
     RefPtr<DocumentTimeline> m_timeline;

Modified: trunk/Source/WebCore/dom/Document.idl (225582 => 225583)


--- trunk/Source/WebCore/dom/Document.idl	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebCore/dom/Document.idl	2017-12-06 19:41:01 UTC (rev 225583)
@@ -191,7 +191,7 @@
     RenderingContext? getCSSCanvasContext(DOMString contextId, DOMString name, long width, long height);
 
     // Non standard, to bring up with standards working group.
-    [EnabledBySetting=StorageAccessAPI] readonly attribute boolean hasStorageAccess;
+    [EnabledBySetting=StorageAccessAPI] Promise<bool> hasStorageAccess();
     [EnabledBySetting=StorageAccessAPI] Promise<void> requestStorageAccess();
 
     // Obsolete features from https://html.spec.whatwg.org/multipage/obsolete.html

Modified: trunk/Source/WebCore/page/ChromeClient.h (225582 => 225583)


--- trunk/Source/WebCore/page/ChromeClient.h	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebCore/page/ChromeClient.h	2017-12-06 19:41:01 UTC (rev 225583)
@@ -42,6 +42,7 @@
 #include "SearchPopupMenu.h"
 #include "WebCoreKeyboardUIMode.h"
 #include <runtime/ConsoleTypes.h>
+#include <wtf/CompletionHandler.h>
 #include <wtf/Forward.h>
 #include <wtf/Seconds.h>
 
@@ -466,7 +467,8 @@
     virtual void reportProcessCPUTime(Seconds, ActivityStateForCPUSampling) { }
     virtual RefPtr<Icon> createIconForFiles(const Vector<String>& /* filenames */) = 0;
 
-    virtual void requestStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, WTF::Function<void (bool)>&& callback) { callback(false); }
+    virtual void hasStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, WTF::CompletionHandler<void (bool)>&& callback) { callback(false); }
+    virtual void requestStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, WTF::CompletionHandler<void (bool)>&& callback) { callback(false); }
 
     virtual void didInsertMenuElement(HTMLMenuElement&) { }
     virtual void didRemoveMenuElement(HTMLMenuElement&) { }

Modified: trunk/Source/WebKit/ChangeLog (225582 => 225583)


--- trunk/Source/WebKit/ChangeLog	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebKit/ChangeLog	2017-12-06 19:41:01 UTC (rev 225583)
@@ -1,3 +1,42 @@
+2017-12-06  John Wilander  <[email protected]>
+
+        Storage Access API: Make document.hasStorageAccess a function and always allow access for same-origin iframes
+        https://bugs.webkit.org/show_bug.cgi?id=176944
+        <rdar://problem/34440658>
+
+        Reviewed by Brent Fulgham.
+
+        This change introduces document.hasStorageAccess() as a function which
+        returns a promise instead of being a property. Since cookie access can
+        be due to both a granted request and recent user interaction as first
+        party, the WebKit::WebResourceLoadStatisticsStore needs to be consulted.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::hasStorageAccess):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess):
+        (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
+            Now adds an entry for granted access. A bug found through testing.
+            Switched from WTF::Function to WTF::CompletionHandler.
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::hasStorageAccess):
+        (WebKit::WebsiteDataStore::requestStorageAccess):
+            Switched from WTF::Function to WTF::CompletionHandler.
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::hasStorageAccess):
+        (WebKit::WebChromeClient::requestStorageAccess):
+            Switched from WTF::Function to WTF::CompletionHandler.
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::hasStorageAccess):
+        (WebKit::WebPage::requestStorageAccess):
+            Switched from WTF::Function to WTF::CompletionHandler.
+        * WebProcess/WebPage/WebPage.h:
+
 2017-12-06  Youenn Fablet  <[email protected]>
 
         CacheStorageEngineConnection should protect its IPC Connection when doing asynchronous tasks

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (225582 => 225583)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2017-12-06 19:41:01 UTC (rev 225583)
@@ -7142,6 +7142,13 @@
     iterator->value->stopTask(*this, taskIdentifier);
 }
 
+void WebPageProxy::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t webProcessContextId)
+{
+    m_websiteDataStore->hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), [this, webProcessContextId] (bool hasAccess) {
+        m_process->send(Messages::WebPage::StorageAccessResponse(hasAccess, webProcessContextId), m_pageID);
+    });
+}
+
 void WebPageProxy::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t webProcessContextId)
 {
     m_websiteDataStore->requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), [this, webProcessContextId] (bool wasGranted) {

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (225582 => 225583)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2017-12-06 19:41:01 UTC (rev 225583)
@@ -82,6 +82,7 @@
 #include <WebCore/URL.h>
 #include <WebCore/UserInterfaceLayoutDirection.h>
 #include <memory>
+#include <wtf/CompletionHandler.h>
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
 #include <wtf/MonotonicTime.h>
@@ -1233,6 +1234,7 @@
     void touchBarMenuItemDataRemoved(const TouchBarMenuItemData&);
 #endif
 
+    void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t webProcessContextId);
     void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t webProcessContextId);
 
 #if ENABLE(ATTACHMENT_ELEMENT)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (225582 => 225583)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2017-12-06 19:41:01 UTC (rev 225583)
@@ -505,6 +505,7 @@
     StartURLSchemeTask(struct WebKit::URLSchemeTaskParameters parameters)
     StopURLSchemeTask(uint64_t handlerIdentifier, uint64_t taskIdentifier)
 
+    HasStorageAccess(String subFrameHost, String topFrameHost, uint64_t contextID)
     RequestStorageAccess(String subFrameHost, String topFrameHost, uint64_t contextID)
 
 #if ENABLE(ATTACHMENT_ELEMENT)

Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (225582 => 225583)


--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2017-12-06 19:41:01 UTC (rev 225583)
@@ -245,11 +245,34 @@
     processStatisticsAndDataRecords();
 }
 
-void WebResourceLoadStatisticsStore::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::Function<void (bool)>&& callback)
+void WebResourceLoadStatisticsStore::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback)
 {
     ASSERT(subFrameHost != topFrameHost);
     ASSERT(RunLoop::isMain());
+    
+    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost), callback = WTFMove(callback)] () mutable {
+        
+        auto& topFrameStatistic = ensureResourceStatisticsForPrimaryDomain(topFramePrimaryDomain);
+        if (topFrameStatistic.storageAccessUnderTopFrameOrigins.contains(subFramePrimaryDomain)) {
+            callback(true);
+            return;
+        }
+        
+        auto& subFrameStatistic = ensureResourceStatisticsForPrimaryDomain(subFramePrimaryDomain);
+        if (shouldBlockCookies(subFrameStatistic)) {
+            callback(false);
+            return;
+        }
+        
+        callback(!shouldPartitionCookies(subFrameStatistic));
+    });
+}
 
+void WebResourceLoadStatisticsStore::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback)
+{
+    ASSERT(subFrameHost != topFrameHost);
+    ASSERT(RunLoop::isMain());
+
     m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost), callback = WTFMove(callback)] () mutable {
 
         auto& topFrameStatistic = ensureResourceStatisticsForPrimaryDomain(topFramePrimaryDomain);
@@ -270,6 +293,7 @@
         }
         
         m_updateStorageAccessForPrevalentDomainsHandler(subFramePrimaryDomain, topFramePrimaryDomain, true, WTFMove(callback));
+        topFrameStatistic.storageAccessUnderTopFrameOrigins.add(subFramePrimaryDomain);
     });
 }
     

Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (225582 => 225583)


--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h	2017-12-06 19:41:01 UTC (rev 225583)
@@ -29,6 +29,7 @@
 #include "ResourceLoadStatisticsClassifier.h"
 #include "ResourceLoadStatisticsPersistentStorage.h"
 #include "WebsiteDataType.h"
+#include <wtf/CompletionHandler.h>
 #include <wtf/MonotonicTime.h>
 #include <wtf/RunLoop.h>
 #include <wtf/Vector.h>
@@ -80,7 +81,8 @@
 
     void resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&& origins);
 
-    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::Function<void (bool)>&& callback);
+    void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback);
+    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback);
     void requestStorageAccessCallback(bool wasGranted, uint64_t contextId);
 
     void processWillOpenConnection(WebProcessProxy&, IPC::Connection&);

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (225582 => 225583)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2017-12-06 19:41:01 UTC (rev 225583)
@@ -1401,12 +1401,22 @@
     m_pendingCookies.remove(cookie);
 }
 
-void WebsiteDataStore::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::Function<void (bool)>&& callback)
+void WebsiteDataStore::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback)
 {
     if (!resourceLoadStatisticsEnabled()) {
         callback(false);
         return;
     }
+    
+    m_resourceLoadStatistics->hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), WTFMove(callback));
+}
+    
+void WebsiteDataStore::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback)
+{
+    if (!resourceLoadStatisticsEnabled()) {
+        callback(false);
+        return;
+    }
 
     m_resourceLoadStatistics->requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), WTFMove(callback));
 }

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (225582 => 225583)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2017-12-06 19:41:01 UTC (rev 225583)
@@ -144,7 +144,8 @@
 
     void enableResourceLoadStatisticsAndSetTestingCallback(Function<void (const String&)>&& callback);
 
-    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::Function<void (bool)>&& callback);
+    void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback);
+    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, 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 (225582 => 225583)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2017-12-06 19:41:01 UTC (rev 225583)
@@ -1256,8 +1256,13 @@
     m_page.findController().didInvalidateDocumentMarkerRects();
 }
 
-void WebChromeClient::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::Function<void (bool)>&& callback)
+void WebChromeClient::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback)
 {
+    m_page.hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), WTFMove(callback));
+}
+
+void WebChromeClient::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback)
+{
     m_page.requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), WTFMove(callback));
 }
 

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (225582 => 225583)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2017-12-06 19:41:01 UTC (rev 225583)
@@ -349,7 +349,8 @@
 
     void didInvalidateDocumentMarkerRects() final;
 
-    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::Function<void (bool)>&&) final;
+    void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&&) final;
+    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&&) final;
 
     String m_cachedToolTip;
     mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (225582 => 225583)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-12-06 19:41:01 UTC (rev 225583)
@@ -5806,12 +5806,23 @@
     return ++nextContextId;
 }
 
-void WebPage::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::Function<void (bool)>&& callback)
+void WebPage::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback)
 {
     auto contextId = nextRequestStorageAccessContextId();
     auto addResult = m_storageAccessResponseCallbackMap.add(contextId, WTFMove(callback));
     ASSERT(addResult.isNewEntry);
     if (addResult.iterator->value)
+        send(Messages::WebPageProxy::HasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), contextId));
+    else
+        callback(false);
+}
+    
+void WebPage::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback)
+{
+    auto contextId = nextRequestStorageAccessContextId();
+    auto addResult = m_storageAccessResponseCallbackMap.add(contextId, WTFMove(callback));
+    ASSERT(addResult.isNewEntry);
+    if (addResult.iterator->value)
         send(Messages::WebPageProxy::RequestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), contextId));
     else
         callback(false);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (225582 => 225583)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2017-12-06 19:38:23 UTC (rev 225582)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2017-12-06 19:41:01 UTC (rev 225583)
@@ -1020,7 +1020,8 @@
     void sendPartialEditorStateAndSchedulePostLayoutUpdate();
     void flushPendingEditorStateUpdate();
 
-    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::Function<void (bool)>&& callback);
+    void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback);
+    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::CompletionHandler<void (bool)>&& callback);
     void storageAccessResponse(bool wasGranted, uint64_t contextId);
 
 #if ENABLE(ATTACHMENT_ELEMENT)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to