Title: [221976] trunk
Revision
221976
Author
wilan...@apple.com
Date
2017-09-13 10:47:52 -0700 (Wed, 13 Sep 2017)

Log Message

Introduce Storage Access API (document parts) as an experimental feature
https://bugs.webkit.org/show_bug.cgi?id=175759
<rdar://problem/33666847>

Reviewed by Alex Christensen.

Source/WebCore:

Storage Access API is an experimental feature which allows cross-origin,
sandboxed iframes to request access to their first-party storage (as
opposed to partitioned storage). This might be restricted to cookies or
might cover all stateful mechanisms.

It introduces the following three developer-facing things:
- A new readonly attribute, document.hasStorageAccess.
- A new function, document.requestStorageAccess().
- A new iframe sandbox token, allow-storage-access-by-user-activation.

Tests: http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe.html
       http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html
       http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe.html
       http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe.html
       http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html
       http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html
       http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe.html
       http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html
       http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe.html
       http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame.html

* dom/Document.cpp:
(WebCore::Document::requestStorageAccess):
* dom/Document.h:
(WebCore::Document::hasStorageAccess const):
(WebCore::Document::setUserGrantsStorageAccessOverride):
    See comments on WebCore::Internals below.
* dom/Document.idl:
* dom/SecurityContext.cpp:
(WebCore::SecurityContext::isSupportedSandboxPolicy):
(WebCore::SecurityContext::parseSandboxPolicy):
    Support for allow-storage-access-by-user-activation.
* dom/SecurityContext.h:
* loader/ResourceLoadObserver.cpp:
(WebCore::ResourceLoadObserver::registerStorageAccess):
    Newly granted storage access is reported to
    WebCore::ResourceLoadObserver.
* loader/ResourceLoadObserver.h:
* loader/ResourceLoadStatistics.cpp:
(WebCore::encodeHashSet):
(WebCore::ResourceLoadStatistics::encode const):
(WebCore::decodeHashSet):
(WebCore::ResourceLoadStatistics::decode):
(WebCore::appendHashSet):
(WebCore::ResourceLoadStatistics::toString const):
(WebCore::mergeHashSet):
(WebCore::ResourceLoadStatistics::merge):
    Storage of the new type of data.
* loader/ResourceLoadStatistics.h:
* page/Settings.in:
* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
(WebCore::Internals::setUserGrantsStorageAccess):
* testing/Internals.h:
* testing/Internals.idl:
    Added setUserGrantsStorageAccess(). It is used to
    override the eventSender's keyboard input which
    always results in a cancel action on the confirm()
    dialog.

Source/WebKit:

Storage Access API is an experimental feature which allows cross-origin,
sandboxed iframes to request access to their first-party storage (as
opposed to partitioned storage). This might be restricted to cookies or
might cover all stateful mechanisms.

It introduces the following three developer-facing things:
- A new readonly attribute, document.hasStorageAccess.
- A new function, document.requestStorageAccess().
- A new iframe sandbox token, allow-storage-access-by-user-activation.

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<ResourceLoadStatistics>::encode):
(IPC::ArgumentCoder<ResourceLoadStatistics>::decode):
    Storage handling of the new type of data.
* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetStorageAccessAPIEnabled):
(WKPreferencesGetStorageAccessAPIEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* UIProcess/WebResourceLoadStatisticsStore.cpp:
    Bumped the model version from 9 to 10.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

Tools:

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):
    Turns the feature on for tests.

LayoutTests:

Storage Access API is an experimental feature which allows cross-origin,
sandboxed iframes to request access to their first-party storage (as
opposed to partitioned storage). This might be restricted to cookies or
might cover all stateful mechanisms.

It introduces the following three developer-facing things:
- A new readonly attribute, document.hasStorageAccess.
- A new function, document.requestStorageAccess().
- A new iframe sandbox token, allow-storage-access-by-user-activation.

* http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe.html: Added.
* http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html: Added.
* http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe.html: Added.
* http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe.html: Added.
* http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html: Added.
* http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html: Added.
* http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe.html: Added.
* http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html: Added.
* http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe.html: Added.
* http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame.html: Added.
* http/tests/loading/resourceLoadStatistics/resources/request-storage-access-iframe.html: Added.
* platform/mac-wk2/TestExpectations:
    New test cases that require a user gesture marked as [ Pass ].
    Also removed reference to (now closed) https://bugs.webkit.org/show_bug.cgi?id=175170.
* platform/wk2/TestExpectations:
    New test case request-storage-access-top-frame.html marked as [ Pass ].

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (221975 => 221976)


--- trunk/LayoutTests/ChangeLog	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/LayoutTests/ChangeLog	2017-09-13 17:47:52 UTC (rev 221976)
@@ -1,3 +1,48 @@
+2017-09-13  John Wilander  <wilan...@apple.com>
+
+        Introduce Storage Access API (document parts) as an experimental feature
+        https://bugs.webkit.org/show_bug.cgi?id=175759
+        <rdar://problem/33666847>
+
+        Reviewed by Alex Christensen.
+
+        Storage Access API is an experimental feature which allows cross-origin,
+        sandboxed iframes to request access to their first-party storage (as
+        opposed to partitioned storage). This might be restricted to cookies or
+        might cover all stateful mechanisms.
+
+        It introduces the following three developer-facing things:
+        - A new readonly attribute, document.hasStorageAccess.
+        - A new function, document.requestStorageAccess().
+        - A new iframe sandbox token, allow-storage-access-by-user-activation.
+
+        * http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe.html: Added.
+        * http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html: Added.
+        * http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe.html: Added.
+        * http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe.html: Added.
+        * http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html: Added.
+        * http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html: Added.
+        * http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe.html: Added.
+        * http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html: Added.
+        * http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe.html: Added.
+        * http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame.html: Added.
+        * http/tests/loading/resourceLoadStatistics/resources/request-storage-access-iframe.html: Added.
+        * platform/mac-wk2/TestExpectations:
+            New test cases that require a user gesture marked as [ Pass ].
+            Also removed reference to (now closed) https://bugs.webkit.org/show_bug.cgi?id=175170.
+        * platform/wk2/TestExpectations:
+            New test case request-storage-access-top-frame.html marked as [ Pass ].
+
 2017-09-13  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [HarfBuzz] Wrong offset returned by HarfBuzzShaper::offsetForPosition in some cases

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe-expected.txt (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe-expected.txt	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,20 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+frame "theIframe" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "theIframe" - didCommitLoadForFrame
+frame "theIframe" - didFinishDocumentLoadForFrame
+CONSOLE MESSAGE: line 70: PASS document.hasStorageAccess was denied.
+frame "theIframe" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "theIframe" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+Tests that cross-origin iframe storage access is denied if the iframe is not sandboxed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe.html (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe.html	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script>
+        description("Tests that cross-origin iframe storage access is denied if the iframe is not sandboxed.");
+        jsTestIsAsync = true;
+
+        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");
+                    finishJSTest();
+                },
+                function () {
+                    testFailed("Promise rejected.");
+                    finishJSTest();
+                }
+            );
+        }
+
+        function runTest() {
+            activateElement("theIframe");
+        }
+    </script>
+</head>
+<body>
+    <iframe _onload_="runTest()" id="theIframe" src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe-expected.txt	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,22 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+frame "theIframe" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "theIframe" - didCommitLoadForFrame
+frame "theIframe" - didFinishDocumentLoadForFrame
+CONFIRM: Do you want to use your  ID on ?
+CONFIRM: Do you want to use your  ID on ?
+CONSOLE MESSAGE: line 70: PASS document.hasStorageAccess was denied.
+frame "theIframe" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "theIframe" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+Tests that cross-origin iframe storage access is denied if the iframe is sandboxed, has the allow token, but the user opts out.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,35 @@
+<!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 the user opts out.");
+        jsTestIsAsync = true;
+
+        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");
+                    finishJSTest();
+                },
+                function () {
+                    testFailed("Promise rejected.");
+                    finishJSTest();
+                }
+            );
+        }
+
+        function runTest() {
+            activateElement("theIframe");
+        }
+    </script>
+</head>
+<body>
+    <iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals" _onload_="runTest()" id="theIframe" src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe-expected.txt (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe-expected.txt	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,20 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+frame "theIframe" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "theIframe" - didCommitLoadForFrame
+frame "theIframe" - didFinishDocumentLoadForFrame
+CONSOLE MESSAGE: line 70: PASS document.hasStorageAccess was denied.
+frame "theIframe" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "theIframe" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+Tests that cross-origin iframe storage access is denied if the iframe is not sandboxed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe.html (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe.html	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script>
+        description("Tests that cross-origin iframe storage access is denied if the iframe is not sandboxed.");
+        jsTestIsAsync = true;
+
+        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");
+                        finishJSTest();
+                    },
+                function () {
+                    testFailed("Promise rejected.");
+                    finishJSTest();
+                }
+            );
+        }
+
+        function runTest() {
+            activateElement("theIframe");
+        }
+    </script>
+</head>
+<body>
+    <iframe _onload_="runTest()" id="theIframe" src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe-expected.txt (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe-expected.txt	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,21 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+frame "theIframe" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "theIframe" - didCommitLoadForFrame
+frame "theIframe" - didFinishDocumentLoadForFrame
+CONFIRM: Do you want to use your  ID on ?
+CONSOLE MESSAGE: line 66: PASS document.hasStorageAccess was granted.
+frame "theIframe" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "theIframe" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+Tests that cross-origin iframe storage access is granted if the iframe is sandboxed, has the allow token, and the user opts in.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe.html (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe.html	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script>
+        description("Tests that cross-origin iframe storage access is granted if the iframe is sandboxed, has the allow token, and the user opts in.");
+        jsTestIsAsync = true;
+
+        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");
+                    finishJSTest();
+                },
+                function () {
+                    testFailed("Promise rejected.");
+                    finishJSTest();
+                }
+            );
+        }
+
+        function runTest() {
+            activateElement("theIframe");
+        }
+    </script>
+</head>
+<body>
+    <iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals" _onload_="runTest()" id="theIframe" src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin-expected.txt (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin-expected.txt	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,20 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+frame "theIframe" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "theIframe" - didCommitLoadForFrame
+frame "theIframe" - didFinishDocumentLoadForFrame
+CONSOLE MESSAGE: line 70: PASS document.hasStorageAccess was denied.
+frame "theIframe" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "theIframe" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+Tests that cross-origin iframe storage access is denied if the iframe is sandboxed and has the unique origin because it lacks the allow-same-origin token.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script>
+        description("Tests that cross-origin iframe storage access is denied if the iframe is sandboxed and has the unique origin because it lacks the allow-same-origin token.");
+        jsTestIsAsync = true;
+
+        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");
+                    finishJSTest();
+                },
+                function () {
+                    testFailed("Promise rejected.");
+                    finishJSTest();
+                }
+            );
+        }
+
+        function runTest() {
+            activateElement("theIframe");
+        }
+    </script>
+</head>
+<body>
+    <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

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token-expected.txt (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token-expected.txt	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,20 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+frame "theIframe" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "theIframe" - didCommitLoadForFrame
+frame "theIframe" - didFinishDocumentLoadForFrame
+CONSOLE MESSAGE: line 70: PASS document.hasStorageAccess was denied.
+frame "theIframe" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "theIframe" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+Tests that cross-origin iframe storage access is denied if the iframe is sandboxed and doesn't have the allow token.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script>
+        description("Tests that cross-origin iframe storage access is denied if the iframe is sandboxed and doesn't have the allow token.");
+        jsTestIsAsync = true;
+
+        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");
+                    finishJSTest();
+                },
+                function () {
+                    testFailed("Promise rejected.");
+                    finishJSTest();
+                }
+            );
+        }
+
+        function runTest() {
+            activateElement("theIframe");
+        }
+    </script>
+</head>
+<body>
+    <iframe sandbox="allow-scripts allow-same-origin allow-modals" _onload_="runTest()" id="theIframe" src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe-expected.txt (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe-expected.txt	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,20 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+frame "theIframe" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "theIframe" - didCommitLoadForFrame
+frame "theIframe" - didFinishDocumentLoadForFrame
+CONSOLE MESSAGE: line 70: PASS document.hasStorageAccess was denied.
+frame "theIframe" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "theIframe" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+Tests that same-origin iframe storage access is denied if the iframe is not sandboxed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe.html (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe.html	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script>
+        description("Tests that same-origin iframe storage access is denied if the iframe is not sandboxed.");
+        jsTestIsAsync = true;
+
+        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");
+                    finishJSTest();
+                },
+                function () {
+                    testFailed("Promise rejected.");
+                    finishJSTest();
+                }
+            );
+        }
+
+        function runTest() {
+            activateElement("theIframe");
+        }
+    </script>
+</head>
+<body>
+    <iframe _onload_="runTest()" id="theIframe" src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-expected.txt (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-expected.txt	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,20 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+frame "theIframe" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "theIframe" - didCommitLoadForFrame
+frame "theIframe" - didFinishDocumentLoadForFrame
+CONSOLE MESSAGE: line 66: PASS document.hasStorageAccess was granted.
+frame "theIframe" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "theIframe" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+Tests that same-origin iframe storage access is granted if the iframe is sandboxed and has the allow token.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token-expected.txt (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token-expected.txt	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,20 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+frame "theIframe" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "theIframe" - didCommitLoadForFrame
+frame "theIframe" - didFinishDocumentLoadForFrame
+CONSOLE MESSAGE: line 70: PASS document.hasStorageAccess was denied.
+frame "theIframe" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "theIframe" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+Tests that same-origin iframe storage access is denied 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 successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <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.");
+        jsTestIsAsync = true;
+
+        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");
+                    finishJSTest();
+                },
+                function () {
+                    testFailed("Promise rejected.");
+                    finishJSTest();
+                }
+            );
+        }
+
+        function runTest() {
+            activateElement("theIframe");
+        }
+    </script>
+</head>
+<body>
+    <iframe sandbox="allow-scripts allow-same-origin allow-modals" _onload_="runTest()" id="theIframe" src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe.html (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe.html	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script>
+        description("Tests that same-origin iframe storage access is granted if the iframe is sandboxed and has the allow token.");
+        jsTestIsAsync = true;
+
+        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");
+                    finishJSTest();
+                },
+                function () {
+                    testFailed("Promise rejected.");
+                    finishJSTest();
+                }
+            );
+        }
+
+        function runTest() {
+            activateElement("theIframe");
+        }
+    </script>
+</head>
+<body>
+    <iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals" _onload_="runTest()" id="theIframe" src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame-expected.txt (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame-expected.txt	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,18 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+Tests that top frame storage access is always granted in case the page requests it.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS requestStorageAccessReturnValue is true
+PASS document.hasStorageAccess is true
+PASS requestStorageAccessReturnValue is true
+PASS document.hasStorageAccess is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Request Access

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame.html (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame.html	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<body _onload_="runTest()">
+<script src=""
+<script src=""
+<script>
+    description("Tests that top frame storage access is always granted in case the page requests it.");
+    jsTestIsAsync = true;
+
+    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() { },
+            function() {
+                testFailed("Promise rejected.");
+                finishJSTest();
+            }
+        );
+    }
+
+    var requestStorageAccessReturnValue;
+
+    function makeRequestWithoutUserGesture() {
+        document.requestStorageAccess();
+        var promise = document.requestStorageAccess();
+        promise.then(function (hasAccess) {
+            requestStorageAccessReturnValue = hasAccess;
+            shouldBe("requestStorageAccessReturnValue", "true");
+            shouldBe("document.hasStorageAccess", "true");
+            activateElement("theButton");
+        });
+    }
+
+    function makeRequestWithUserGesture() {
+        document.requestStorageAccess();
+        var promise = document.requestStorageAccess();
+        promise.then(function (hasAccess) {
+            requestStorageAccessReturnValue = hasAccess;
+            shouldBe("requestStorageAccessReturnValue", "true");
+            shouldBe("document.hasStorageAccess", "true");
+            finishJSTest();
+        });
+    }
+
+    function runTest() {
+        makeRequestWithoutUserGesture();
+    }
+</script>
+<button id="theButton" _onclick_="makeRequestWithUserGesture()">Request Access</button>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/resources/request-storage-access-iframe.html (0 => 221976)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/resources/request-storage-access-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/resources/request-storage-access-iframe.html	2017-09-13 17:47:52 UTC (rev 221976)
@@ -0,0 +1,84 @@
+<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";
+        const isSameOriginIframe = hashArguments[3] === "isSameOriginIframe";
+
+        if (internals && userShouldGrantAccess)
+                internals.setUserGrantsStorageAccess(true);
+
+        function storageAccessShouldBeFalse() {
+            if (document.hasStorageAccess)
+                console.log("FAIL document.hasStorageAccess was true when it was not supposed to.");
+            if (requestStorageAccessReturnValue)
+                console.log("FAIL requestStorageAccessReturnValue was true when it was not supposed to.");
+        }
+
+        function storageAccessShouldBeTrue() {
+            if (!document.hasStorageAccess)
+                console.log("FAIL document.hasStorageAccess was false when it was not supposed to.");
+            if (!requestStorageAccessReturnValue)
+                console.log("FAIL requestStorageAccessReturnValue was false when it was not supposed to.");
+        }
+
+        var requestStorageAccessReturnValue;
+
+        function makeRequestWithoutUserGesture() {
+            storageAccessShouldBeFalse();
+
+            document.requestStorageAccess();
+            var promise = document.requestStorageAccess();
+            promise.then(function (hasAccess) {
+                requestStorageAccessReturnValue = hasAccess;
+                continueAfterRequestWithoutUserGesture();
+            });
+        }
+
+        function continueAfterRequestWithoutUserGesture() {
+            if (isSameOriginIframe && policyShouldGrantAccess)
+                storageAccessShouldBeTrue();
+            else
+                storageAccessShouldBeFalse();
+        }
+
+        function makeRequestWithUserGesture() {
+            if (isSameOriginIframe && policyShouldGrantAccess)
+                storageAccessShouldBeTrue();
+            else
+                storageAccessShouldBeFalse();
+
+            document.requestStorageAccess();
+            var promise = document.requestStorageAccess();
+            promise.then(function (hasAccess) {
+                requestStorageAccessReturnValue = hasAccess;
+                continueAfterRequestWithUserGesture();
+            });
+        }
+
+        function continueAfterRequestWithUserGesture() {
+            if (requestStorageAccessReturnValue
+                && document.hasStorageAccess
+                && (userShouldGrantAccess || !userShouldBeConsulted)
+                && policyShouldGrantAccess)
+                console.log("PASS document.hasStorageAccess was granted.");
+            else if (!document.hasStorageAccess
+                    && !requestStorageAccessReturnValue
+                    && ((!userShouldGrantAccess && userShouldBeConsulted) || !policyShouldGrantAccess))
+                console.log("PASS document.hasStorageAccess was denied.");
+            else
+                console.log("FAIL document.hasStorageAccess was " +
+                    (document.hasStorageAccess ? "" : "not ") +
+                    "granted and requestStorageAccessReturnValue was " +
+                    (requestStorageAccessReturnValue ? "" : "not ") +
+                    "granted but should " +
+                    (userShouldGrantAccess && policyShouldGrantAccess ? "" : "not ") +
+                    "have been granted.");
+        }
+    </script>
+</head>
+<body _onload_="makeRequestWithoutUserGesture()" _onclick_="makeRequestWithUserGesture()">
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (221975 => 221976)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2017-09-13 17:47:52 UTC (rev 221976)
@@ -742,10 +742,19 @@
 
 webkit.org/b/172397 [ Sierra Debug ] animations/needs-layout.html [ Pass ImageOnlyFailure ]
 
-# Move to general wk2 expectations once webkit.org/b/175170 is resolved.
+# Touch events are not available on open source bots, thus only tested on Mac.
 http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html [ Pass ]
 http/tests/loading/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html [ Pass ]
 http/tests/loading/resourceLoadStatistics/user-interaction-reported-after-website-data-removal.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe.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 (221975 => 221976)


--- trunk/LayoutTests/platform/wk2/TestExpectations	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/LayoutTests/platform/wk2/TestExpectations	2017-09-13 17:47:52 UTC (rev 221976)
@@ -688,6 +688,7 @@
 webkit.org/b/172452 http/tests/loading/resourceLoadStatistics/grandfathering.html [ Pass Failure Timeout ]
 webkit.org/b/173499 http/tests/loading/resourceLoadStatistics/telemetry-generation.html [ Pass Failure ]
 http/tests/loading/resourceLoadStatistics/prune-statistics.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame.html [ Pass ]
 
 ### END OF (5) Progressions, expected successes that are expected failures in WebKit1.
 ########################################

Modified: trunk/Source/WebCore/ChangeLog (221975 => 221976)


--- trunk/Source/WebCore/ChangeLog	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/ChangeLog	2017-09-13 17:47:52 UTC (rev 221976)
@@ -1,3 +1,71 @@
+2017-09-13  John Wilander  <wilan...@apple.com>
+
+        Introduce Storage Access API (document parts) as an experimental feature
+        https://bugs.webkit.org/show_bug.cgi?id=175759
+        <rdar://problem/33666847>
+
+        Reviewed by Alex Christensen.
+
+        Storage Access API is an experimental feature which allows cross-origin,
+        sandboxed iframes to request access to their first-party storage (as
+        opposed to partitioned storage). This might be restricted to cookies or
+        might cover all stateful mechanisms.
+
+        It introduces the following three developer-facing things:
+        - A new readonly attribute, document.hasStorageAccess.
+        - A new function, document.requestStorageAccess().
+        - A new iframe sandbox token, allow-storage-access-by-user-activation.
+
+        Tests: http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-iframe.html
+               http/tests/loading/resourceLoadStatistics/request-and-deny-storage-access-cross-origin-sandboxed-iframe.html
+               http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-iframe.html
+               http/tests/loading/resourceLoadStatistics/request-and-grant-storage-access-cross-origin-sandboxed-iframe.html
+               http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html
+               http/tests/loading/resourceLoadStatistics/request-storage-access-cross-origin-sandboxed-iframe-without-allow-token.html
+               http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-iframe.html
+               http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe-without-allow-token.html
+               http/tests/loading/resourceLoadStatistics/request-storage-access-same-origin-sandboxed-iframe.html
+               http/tests/loading/resourceLoadStatistics/request-storage-access-top-frame.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::requestStorageAccess):
+        * dom/Document.h:
+        (WebCore::Document::hasStorageAccess const):
+        (WebCore::Document::setUserGrantsStorageAccessOverride):
+            See comments on WebCore::Internals below.
+        * dom/Document.idl:
+        * dom/SecurityContext.cpp:
+        (WebCore::SecurityContext::isSupportedSandboxPolicy):
+        (WebCore::SecurityContext::parseSandboxPolicy):
+            Support for allow-storage-access-by-user-activation.
+        * dom/SecurityContext.h:
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::ResourceLoadObserver::registerStorageAccess):
+            Newly granted storage access is reported to 
+            WebCore::ResourceLoadObserver.
+        * loader/ResourceLoadObserver.h:
+        * loader/ResourceLoadStatistics.cpp:
+        (WebCore::encodeHashSet):
+        (WebCore::ResourceLoadStatistics::encode const):
+        (WebCore::decodeHashSet):
+        (WebCore::ResourceLoadStatistics::decode):
+        (WebCore::appendHashSet):
+        (WebCore::ResourceLoadStatistics::toString const):
+        (WebCore::mergeHashSet):
+        (WebCore::ResourceLoadStatistics::merge):
+            Storage of the new type of data.
+        * loader/ResourceLoadStatistics.h:
+        * page/Settings.in:
+        * testing/Internals.cpp:
+        (WebCore::Internals::resetToConsistentState):
+        (WebCore::Internals::setUserGrantsStorageAccess):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+            Added setUserGrantsStorageAccess(). It is used to
+            override the eventSender's keyboard input which
+            always results in a cancel action on the confirm()
+            dialog.
+
 2017-09-13  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [HarfBuzz] Wrong offset returned by HarfBuzzShaper::offsetForPosition in some cases

Modified: trunk/Source/WebCore/dom/Document.cpp (221975 => 221976)


--- trunk/Source/WebCore/dom/Document.cpp	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-09-13 17:47:52 UTC (rev 221976)
@@ -103,6 +103,7 @@
 #include "ImageLoader.h"
 #include "InspectorInstrumentation.h"
 #include "JSCustomElementInterface.h"
+#include "JSDOMPromiseDeferred.h"
 #include "JSLazyEventListener.h"
 #include "KeyboardEvent.h"
 #include "LayoutDisallowedScope.h"
@@ -147,6 +148,7 @@
 #include "RenderView.h"
 #include "RenderWidget.h"
 #include "RequestAnimationFrameCallback.h"
+#include "ResourceLoadObserver.h"
 #include "RuntimeEnabledFeatures.h"
 #include "SVGDocumentExtensions.h"
 #include "SVGElement.h"
@@ -7285,4 +7287,65 @@
     return *m_logger;
 }
 
+void Document::requestStorageAccess(Ref<DeferredPromise>&& passedPromise)
+{
+    ASSERT(settings().storageAccessAPIEnabled());
+    
+    RefPtr<DeferredPromise> promise(WTFMove(passedPromise));
+    
+    if (m_hasStorageAccess) {
+        promise->resolve<IDLBoolean>(true);
+        return;
+    }
+    
+    if (!m_frame || securityOrigin().isUnique()) {
+        promise->resolve<IDLBoolean>(false);
+        return;
+    }
+    
+    if (m_frame->isMainFrame()) {
+        m_hasStorageAccess = true;
+        promise->resolve<IDLBoolean>(true);
+        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->resolve<IDLBoolean>(false);
+        return;
+    }
+    
+    auto& securityOrigin = this->securityOrigin();
+    auto& topSecurityOrigin = topDocument().securityOrigin();
+    if (securityOrigin.equal(&topSecurityOrigin)) {
+        m_hasStorageAccess = true;
+        promise->resolve<IDLBoolean>(true);
+        return;
+    }
+    
+    if (!UserGestureIndicator::processingUserGesture()) {
+        promise->resolve<IDLBoolean>(false);
+        return;
+    }
+    
+    auto partitionDomain = securityOrigin.domainForCachePartition();
+    auto topPartitionDomain = topSecurityOrigin.domainForCachePartition();
+    StringBuilder builder;
+    builder.appendLiteral("Do you want to use your ");
+    builder.append(partitionDomain);
+    builder.appendLiteral(" ID on ");
+    builder.append(topPartitionDomain);
+    builder.appendLiteral("?");
+    Page* page = this->page();
+    // FIXME: Don't use runJavaScriptConfirm because it responds synchronously.
+    if ((page && page->chrome().runJavaScriptConfirm(*m_frame, builder.toString())) || m_grantStorageAccessOverride) {
+        m_hasStorageAccess = true;
+        ResourceLoadObserver::shared().registerStorageAccess(partitionDomain, topPartitionDomain);
+        promise->resolve<IDLBoolean>(true);
+        return;
+    }
+    
+    promise->resolve<IDLBoolean>(false);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/Document.h (221975 => 221976)


--- trunk/Source/WebCore/dom/Document.h	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/dom/Document.h	2017-09-13 17:47:52 UTC (rev 221976)
@@ -103,6 +103,7 @@
 class DOMWrapperWorld;
 class Database;
 class DatabaseThread;
+class DeferredPromise;
 class DocumentFragment;
 class DocumentLoader;
 class DocumentMarkerController;
@@ -1361,6 +1362,10 @@
 
     PAL::Logger& logger() const;
 
+    bool hasStorageAccess() const { return m_hasStorageAccess; };
+    void requestStorageAccess(Ref<DeferredPromise>&& passedPromise);
+    void setUserGrantsStorageAccessOverride(bool value) { m_grantStorageAccessOverride = value; }
+
 protected:
     enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
     Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
@@ -1814,6 +1819,9 @@
     mutable RefPtr<PAL::Logger> m_logger;
 
     static bool hasEverCreatedAnAXObjectCache;
+
+    bool m_hasStorageAccess { false };
+    bool m_grantStorageAccessOverride { false };
 };
 
 Element* eventTargetElementForDocument(Document*);

Modified: trunk/Source/WebCore/dom/Document.idl (221975 => 221976)


--- trunk/Source/WebCore/dom/Document.idl	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/dom/Document.idl	2017-09-13 17:47:52 UTC (rev 221976)
@@ -192,6 +192,9 @@
     // Non standard (https://developer.apple.com/reference/webkitjs/document/1633863-webkitgetnamedflows).
     [Conditional=CSS_REGIONS] DOMNamedFlowCollection webkitGetNamedFlows();
 
+    // Non standard, to bring up with standards working group.
+    [EnabledBySetting=StorageAccessAPI] readonly attribute boolean hasStorageAccess;
+    [EnabledBySetting=StorageAccessAPI] Promise<boolean> requestStorageAccess();
 
     // Obsolete features from https://html.spec.whatwg.org/multipage/obsolete.html
 

Modified: trunk/Source/WebCore/dom/SecurityContext.cpp (221975 => 221976)


--- trunk/Source/WebCore/dom/SecurityContext.cpp	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/dom/SecurityContext.cpp	2017-09-13 17:47:52 UTC (rev 221976)
@@ -85,7 +85,7 @@
 bool SecurityContext::isSupportedSandboxPolicy(StringView policy)
 {
     static const char* const supportedPolicies[] = {
-        "allow-forms", "allow-same-origin", "allow-scripts", "allow-top-navigation", "allow-pointer-lock", "allow-popups", "allow-popups-to-escape-sandbox", "allow-top-navigation-by-user-activation", "allow-modals"
+        "allow-forms", "allow-same-origin", "allow-scripts", "allow-top-navigation", "allow-pointer-lock", "allow-popups", "allow-popups-to-escape-sandbox", "allow-top-navigation-by-user-activation", "allow-modals", "allow-storage-access-by-user-activation"
     };
 
     for (auto* supportedPolicy : supportedPolicies) {
@@ -136,6 +136,8 @@
             flags &= ~SandboxTopNavigationByUserActivation;
         else if (equalLettersIgnoringASCIICase(sandboxToken, "allow-modals"))
             flags &= ~SandboxModals;
+        else if (equalLettersIgnoringASCIICase(sandboxToken, "allow-storage-access-by-user-activation"))
+            flags &= ~SandboxStorageAccessByUserActivation;
         else {
             if (numberOfTokenErrors)
                 tokenErrors.appendLiteral(", '");

Modified: trunk/Source/WebCore/dom/SecurityContext.h (221975 => 221976)


--- trunk/Source/WebCore/dom/SecurityContext.h	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/dom/SecurityContext.h	2017-09-13 17:47:52 UTC (rev 221976)
@@ -54,6 +54,7 @@
     SandboxTopNavigationByUserActivation = 1 << 10,
     SandboxDocumentDomain       = 1 << 11,
     SandboxModals               = 1 << 12,
+    SandboxStorageAccessByUserActivation = 1 << 13,
     SandboxAll                  = -1 // Mask with all bits set to 1.
 };
 

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.cpp (221975 => 221976)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2017-09-13 17:47:52 UTC (rev 221976)
@@ -284,6 +284,23 @@
     notifyObserver();
 }
 
+void ResourceLoadObserver::registerStorageAccess(const String& subFrameTopPrivatelyControlledDomain, const String& topFrameTopPrivatelyControlledDomain)
+{
+    auto addResult = m_storageAccessMap.add(subFrameTopPrivatelyControlledDomain, HashSet<String> { });
+    if (!addResult.isNewEntry && addResult.iterator->value.contains(topFrameTopPrivatelyControlledDomain))
+        return;
+
+    if (addResult.isNewEntry)
+        addResult.iterator->value = HashSet<String> { topFrameTopPrivatelyControlledDomain };
+    else
+        m_storageAccessMap.get(subFrameTopPrivatelyControlledDomain).add(topFrameTopPrivatelyControlledDomain);
+
+    auto& statistics = ensureResourceStatisticsForPrimaryDomain(subFrameTopPrivatelyControlledDomain);
+    statistics.storageAccessUnderTopFrameOrigins.add(topFrameTopPrivatelyControlledDomain);
+    m_notificationTimer.stop();
+    notifyObserver();
+}
+
 ResourceLoadStatistics& ResourceLoadObserver::ensureResourceStatisticsForPrimaryDomain(const String& primaryDomain)
 {
     auto addResult = m_resourceStatisticsMap.ensure(primaryDomain, [&primaryDomain] {

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.h (221975 => 221976)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.h	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.h	2017-09-13 17:47:52 UTC (rev 221976)
@@ -27,6 +27,7 @@
 
 #include "Timer.h"
 #include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/text/WTFString.h>
 
@@ -59,6 +60,7 @@
     void logWebSocketLoading(const Frame*, const URL&);
     void logUserInteractionWithReducedTimeResolution(const Document&);
 
+    void registerStorageAccess(const String& subFrameTopPrivatelyControlledDomain, const String& topFrameTopPrivatelyControlledDomain);
     WEBCORE_EXPORT String statisticsForOrigin(const String&);
 
     WEBCORE_EXPORT void setNotificationCallback(WTF::Function<void (Vector<ResourceLoadStatistics>&&)>&&);
@@ -75,6 +77,7 @@
     Vector<ResourceLoadStatistics> takeStatistics();
 
     HashMap<String, ResourceLoadStatistics> m_resourceStatisticsMap;
+    HashMap<String, HashSet<String>> m_storageAccessMap;
     HashMap<String, WTF::WallTime> m_lastReportedUserInteractionMap;
     WTF::Function<void (Vector<ResourceLoadStatistics>&&)> m_notificationCallback;
     Timer m_notificationTimer;

Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp (221975 => 221976)


--- trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp	2017-09-13 17:47:52 UTC (rev 221976)
@@ -46,6 +46,16 @@
     });
 }
 
+static void encodeHashSet(KeyedEncoder& encoder, const String& label, const HashSet<String>& hashSet)
+{
+    if (hashSet.isEmpty())
+        return;
+    
+    encoder.encodeObjects(label, hashSet.begin(), hashSet.end(), [](KeyedEncoder& encoderInner, const String& origin) {
+        encoderInner.encodeString("origin", origin);
+    });
+}
+
 void ResourceLoadStatistics::encode(KeyedEncoder& encoder) const
 {
     encoder.encodeString("PrevalentResourceOrigin", highLevelDomain);
@@ -56,7 +66,10 @@
     encoder.encodeBool("hadUserInteraction", hadUserInteraction);
     encoder.encodeDouble("mostRecentUserInteraction", mostRecentUserInteractionTime.secondsSinceEpoch().value());
     encoder.encodeBool("grandfathered", grandfathered);
-    
+
+    // Storage access
+    encodeHashSet(encoder, "storageAccessUnderTopFrameOrigins", storageAccessUnderTopFrameOrigins);
+
     // Subframe stats
     encodeHashCountedSet(encoder, "subframeUnderTopFrameOrigins", subframeUnderTopFrameOrigins);
     
@@ -85,6 +98,18 @@
     });
 }
 
+static void decodeHashSet(KeyedDecoder& decoder, const String& label, HashSet<String>& hashSet)
+{
+    Vector<String> ignore;
+    decoder.decodeObjects(label, ignore, [&hashSet](KeyedDecoder& decoderInner, String& origin) {
+        if (!decoderInner.decodeString("origin", origin))
+            return false;
+        
+        hashSet.add(origin);
+        return true;
+    });
+}
+
 bool ResourceLoadStatistics::decode(KeyedDecoder& decoder)
 {
     if (!decoder.decodeString("PrevalentResourceOrigin", highLevelDomain))
@@ -93,7 +118,10 @@
     // User interaction
     if (!decoder.decodeBool("hadUserInteraction", hadUserInteraction))
         return false;
-    
+
+    // Storage access
+    decodeHashSet(decoder, "storageAccessUnderTopFrameOrigins", storageAccessUnderTopFrameOrigins);
+
     // Subframe stats
     decodeHashCountedSet(decoder, "subframeUnderTopFrameOrigins", subframeUnderTopFrameOrigins);
     
@@ -150,6 +178,22 @@
     }
 }
 
+static void appendHashSet(StringBuilder& builder, const String& label, const HashSet<String>& hashSet)
+{
+    if (hashSet.isEmpty())
+        return;
+    
+    builder.appendLiteral("    ");
+    builder.append(label);
+    builder.appendLiteral(":\n");
+    
+    for (auto& entry : hashSet) {
+        builder.appendLiteral("        ");
+        builder.append(entry);
+        builder.append('\n');
+    }
+}
+
 String ResourceLoadStatistics::toString() const
 {
     StringBuilder builder;
@@ -166,7 +210,10 @@
     builder.append('\n');
     appendBoolean(builder, "    grandfathered", grandfathered);
     builder.append('\n');
-    
+
+    // Storage access
+    appendHashSet(builder, "storageAccessUnderTopFrameOrigins", storageAccessUnderTopFrameOrigins);
+
     // Subframe stats
     appendHashCountedSet(builder, "subframeUnderTopFrameOrigins", subframeUnderTopFrameOrigins);
     
@@ -196,6 +243,13 @@
         to.add(entry.key, entry.value);
 }
 
+template <typename T>
+static void mergeHashSet(HashSet<T>& to, const HashSet<T>& from)
+{
+    for (auto& entry : from)
+        to.add(entry);
+}
+
 void ResourceLoadStatistics::merge(const ResourceLoadStatistics& other)
 {
     ASSERT(other.highLevelDomain == highLevelDomain);
@@ -216,7 +270,10 @@
             mostRecentUserInteractionTime = other.mostRecentUserInteractionTime;
     }
     grandfathered |= other.grandfathered;
-    
+
+    // Storage access
+    mergeHashSet(storageAccessUnderTopFrameOrigins, other.storageAccessUnderTopFrameOrigins);
+
     // Subframe stats
     mergeHashCountedSet(subframeUnderTopFrameOrigins, other.subframeUnderTopFrameOrigins);
     

Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.h (221975 => 221976)


--- trunk/Source/WebCore/loader/ResourceLoadStatistics.h	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.h	2017-09-13 17:47:52 UTC (rev 221976)
@@ -27,6 +27,7 @@
 
 #include "URL.h"
 #include <wtf/HashCountedSet.h>
+#include <wtf/HashSet.h>
 #include <wtf/WallTime.h>
 #include <wtf/text/StringHash.h>
 #include <wtf/text/WTFString.h>
@@ -68,7 +69,10 @@
     // Timestamp. Default value is negative, 0 means it was reset.
     WallTime mostRecentUserInteractionTime { WallTime::fromRawSeconds(-1) };
     bool grandfathered { false };
-    
+
+    // Storage access
+    HashSet<String> storageAccessUnderTopFrameOrigins;
+
     // Subframe stats
     HashCountedSet<String> subframeUnderTopFrameOrigins;
     

Modified: trunk/Source/WebCore/page/Settings.in (221975 => 221976)


--- trunk/Source/WebCore/page/Settings.in	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/page/Settings.in	2017-09-13 17:47:52 UTC (rev 221976)
@@ -300,3 +300,5 @@
 allowMediaContentTypesRequiringHardwareSupportAsFallback initial=false
 
 paymentRequestEnabled initial=false, conditional=PAYMENT_REQUEST
+
+storageAccessAPIEnabled initial=false

Modified: trunk/Source/WebCore/testing/Internals.cpp (221975 => 221976)


--- trunk/Source/WebCore/testing/Internals.cpp	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/testing/Internals.cpp	2017-09-13 17:47:52 UTC (rev 221976)
@@ -466,6 +466,8 @@
 #if USE(LIBWEBRTC)
     WebCore::useRealRTCPeerConnectionFactory();
 #endif
+
+    page.settings().setStorageAccessAPIEnabled(false);
 }
 
 Internals::Internals(Document& document)
@@ -3836,6 +3838,15 @@
     Settings::setResourceLoadStatisticsEnabled(enable);
 }
 
+void Internals::setUserGrantsStorageAccess(bool value)
+{
+    Document* document = contextDocument();
+    if (!document)
+        return;
+
+    document->setUserGrantsStorageAccessOverride(value);
+}
+
 String Internals::composedTreeAsText(Node& node)
 {
     if (!is<ContainerNode>(node))

Modified: trunk/Source/WebCore/testing/Internals.h (221975 => 221976)


--- trunk/Source/WebCore/testing/Internals.h	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/testing/Internals.h	2017-09-13 17:47:52 UTC (rev 221976)
@@ -538,6 +538,7 @@
 
     String resourceLoadStatisticsForOrigin(const String& origin);
     void setResourceLoadStatisticsEnabled(bool);
+    void setUserGrantsStorageAccess(bool);
 
 #if ENABLE(STREAMS_API)
     bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue);

Modified: trunk/Source/WebCore/testing/Internals.idl (221975 => 221976)


--- trunk/Source/WebCore/testing/Internals.idl	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebCore/testing/Internals.idl	2017-09-13 17:47:52 UTC (rev 221976)
@@ -496,6 +496,7 @@
 
     DOMString resourceLoadStatisticsForOrigin(DOMString domain);
     void setResourceLoadStatisticsEnabled(boolean enable);
+    [EnabledBySetting=StorageAccessAPI] void setUserGrantsStorageAccess(boolean value);
 
     [MayThrowException] void setCanShowModalDialogOverride(boolean allow);
 

Modified: trunk/Source/WebKit/ChangeLog (221975 => 221976)


--- trunk/Source/WebKit/ChangeLog	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebKit/ChangeLog	2017-09-13 17:47:52 UTC (rev 221976)
@@ -1,3 +1,35 @@
+2017-09-13  John Wilander  <wilan...@apple.com>
+
+        Introduce Storage Access API (document parts) as an experimental feature
+        https://bugs.webkit.org/show_bug.cgi?id=175759
+        <rdar://problem/33666847>
+
+        Reviewed by Alex Christensen.
+
+        Storage Access API is an experimental feature which allows cross-origin,
+        sandboxed iframes to request access to their first-party storage (as
+        opposed to partitioned storage). This might be restricted to cookies or
+        might cover all stateful mechanisms.
+
+        It introduces the following three developer-facing things:
+        - A new readonly attribute, document.hasStorageAccess.
+        - A new function, document.requestStorageAccess().
+        - A new iframe sandbox token, allow-storage-access-by-user-activation.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<ResourceLoadStatistics>::encode):
+        (IPC::ArgumentCoder<ResourceLoadStatistics>::decode):
+            Storage handling of the new type of data.
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetStorageAccessAPIEnabled):
+        (WKPreferencesGetStorageAccessAPIEnabled):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+            Bumped the model version from 9 to 10.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2017-09-13  Sergio Villar Senin  <svil...@igalia.com>
 
         [WebVR] Add IDLs and stubs

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (221975 => 221976)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2017-09-13 17:47:52 UTC (rev 221976)
@@ -2398,7 +2398,10 @@
     encoder << statistics.hadUserInteraction;
     encoder << statistics.mostRecentUserInteractionTime.secondsSinceEpoch().value();
     encoder << statistics.grandfathered;
-    
+
+    // Storage access
+    encoder << statistics.storageAccessUnderTopFrameOrigins;
+
     // Subframe stats
     encoder << statistics.subframeUnderTopFrameOrigins;
     
@@ -2432,7 +2435,11 @@
 
     if (!decoder.decode(statistics.grandfathered))
         return false;
-    
+
+    // Storage access
+    if (!decoder.decode(statistics.storageAccessUnderTopFrameOrigins))
+        return false;
+
     // Subframe stats
     if (!decoder.decode(statistics.subframeUnderTopFrameOrigins))
         return false;

Modified: trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h (221975 => 221976)


--- trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h	2017-09-13 17:47:52 UTC (rev 221976)
@@ -369,6 +369,7 @@
     macro(IsSecureContextAttributeEnabled, isSecureContextAttributeEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "Secure Contexts API", "Enable Secure Contexts API") \
     macro(ServiceWorkersEnabled, serviceWorkersEnabled, Bool, bool, false, "ServiceWorkers", "Enable ServiceWorkers") \
     macro(CacheAPIEnabled, cacheAPIEnabled, Bool, bool, false, "Cache API", "Enable Cache API") \
+    macro(StorageAccessAPIEnabled, storageAccessAPIEnabled, Bool, bool, false, "Storage Access API", "Enable Storage Access API") \
     macro(SubresourceIntegrityEnabled, subresourceIntegrityEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "SubresourceIntegrity", "Enable SubresourceIntegrity") \
     macro(ViewportFitEnabled, viewportFitEnabled, Bool, bool, true, "Viewport Fit", "Enable viewport-fit viewport parameter") \
     macro(WebAnimationsEnabled, webAnimationsEnabled, Bool, bool, false, "Web Animations", "Web Animations prototype") \

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp (221975 => 221976)


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2017-09-13 17:47:52 UTC (rev 221976)
@@ -1879,3 +1879,13 @@
 {
     return toImpl(preferencesRef)->paymentRequestEnabled();
 }
+
+void WKPreferencesSetStorageAccessAPIEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setStorageAccessAPIEnabled(flag);
+}
+
+bool WKPreferencesGetStorageAccessAPIEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->storageAccessAPIEnabled();
+}

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h (221975 => 221976)


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2017-09-13 17:47:52 UTC (rev 221976)
@@ -529,6 +529,10 @@
 WK_EXPORT void WKPreferencesSetPaymentRequestEnabled(WKPreferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetPaymentRequestEnabled(WKPreferencesRef);
 
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetStorageAccessAPIEnabled(WKPreferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetStorageAccessAPIEnabled(WKPreferencesRef);
+    
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (221975 => 221976)


--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2017-09-13 17:47:52 UTC (rev 221976)
@@ -45,7 +45,7 @@
 namespace WebKit {
 
 constexpr unsigned operatingDatesWindow { 30 };
-constexpr unsigned statisticsModelVersion { 9 };
+constexpr unsigned statisticsModelVersion { 10 };
 constexpr unsigned maxImportance { 3 };
 
 template<typename T> static inline String isolatedPrimaryDomain(const T& value)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (221975 => 221976)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-09-13 17:47:52 UTC (rev 221976)
@@ -3386,6 +3386,8 @@
     settings.setPaymentRequestEnabled(store.getBoolValueForKey(WebPreferencesKey::paymentRequestEnabledKey()));
 #endif
 
+    settings.setStorageAccessAPIEnabled(store.getBoolValueForKey(WebPreferencesKey::storageAccessAPIEnabledKey()));
+    
     platformPreferencesDidChange(store);
 
     if (m_drawingArea)

Modified: trunk/Tools/ChangeLog (221975 => 221976)


--- trunk/Tools/ChangeLog	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Tools/ChangeLog	2017-09-13 17:47:52 UTC (rev 221976)
@@ -1,3 +1,15 @@
+2017-09-13  John Wilander  <wilan...@apple.com>
+
+        Introduce Storage Access API (document parts) as an experimental feature
+        https://bugs.webkit.org/show_bug.cgi?id=175759
+        <rdar://problem/33666847>
+
+        Reviewed by Alex Christensen.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+            Turns the feature on for tests.
+
 2017-09-13  Per Arne Vollan  <pvol...@apple.com>
 
         [Win] DRT option --gc-between-tests is not implemented.

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (221975 => 221976)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2017-09-13 17:46:02 UTC (rev 221975)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2017-09-13 17:47:52 UTC (rev 221976)
@@ -741,6 +741,8 @@
     WKPreferencesSetPaymentRequestEnabled(preferences, true);
 #endif
 
+    WKPreferencesSetStorageAccessAPIEnabled(preferences, true);
+
     platformResetPreferencesToConsistentValues();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to