Storage Access API: Call completion handlers in NetworkConnectionToWebProcess::hasSto...
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 May 2019 23:33:39 +0000 (23:33 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 May 2019 23:33:39 +0000 (23:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197967
<rdar://problem/50753129>

Reviewed by Brent Fulgham.

Source/WebKit:

NetworkConnectionToWebProcess::hasStorageAccess() and NetworkConnectionToWebProcess::requestStorageAccess()
should call their completion handlers when there is no Resource Load Statistics object, i.e. when Resource
Load Statistics is off. This happens for ephemeral sessions which made code for federated login providers
hang, waiting for the result to document.hasStorageAccess().

The existing layout test case was augmented to use an ephemeral session.

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::hasStorageAccess):
(WebKit::NetworkConnectionToWebProcess::requestStorageAccess):

LayoutTests:

* http/tests/storageAccess/has-storage-access-true-if-feature-off.html:
* platform/mac-wk2/TestExpectations:
    Test case marked as [ Pass ].

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

LayoutTests/ChangeLog
LayoutTests/http/tests/storageAccess/has-storage-access-true-if-feature-off.html
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp

index 5386f04..776cb3f 100644 (file)
@@ -1,3 +1,15 @@
+2019-05-16  John Wilander  <wilander@apple.com>
+
+        Storage Access API: Call completion handlers in NetworkConnectionToWebProcess::hasStorageAccess() and NetworkConnectionToWebProcess::requestStorageAccess() when feature is off
+        https://bugs.webkit.org/show_bug.cgi?id=197967
+        <rdar://problem/50753129>
+
+        Reviewed by Brent Fulgham.
+
+        * http/tests/storageAccess/has-storage-access-true-if-feature-off.html:
+        * platform/mac-wk2/TestExpectations:
+            Test case marked as [ Pass ].
+
 2019-05-16  Ross Kirsling  <ross.kirsling@sony.com>
 
         [JSC] Invalid AssignmentTargetType should be an early error.
index d3fcb52..acaf052 100644 (file)
@@ -8,6 +8,9 @@
         description("Tests that document.hasStorageAccess() returns true for a 3rd-party iframe if there is no way to request access (feature off).");
         jsTestIsAsync = true;
 
+        if (window.testRunner)
+            testRunner.setPrivateBrowsingEnabled(true);
+
         window.addEventListener("message", receiveMessage, false);
 
         function receiveMessage(event) {
index 82a6890..24e66d3 100644 (file)
@@ -731,6 +731,7 @@ http/tests/resourceLoadStatistics/user-interaction-reported-after-website-data-r
 [ HighSierra+ ] http/tests/storageAccess/grant-with-prompt-preserves-gesture.html [ Pass ]
 [ HighSierra+ ] http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture.html [ Skip ]
 [ HighSierra+ ] http/tests/storageAccess/deny-without-prompt-preserves-gesture.html [ Pass ]
+[ HighSierra+ ] http/tests/storageAccess/has-storage-access-true-if-feature-off.html [ Pass ]
 
 # As of https://trac.webkit.org/changeset/227762 the timestampResolution is just 5 seconds which makes this test flaky
 http/tests/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html [ Skip ]
index f843850..d6247a9 100644 (file)
@@ -1,3 +1,22 @@
+2019-05-16  John Wilander  <wilander@apple.com>
+
+        Storage Access API: Call completion handlers in NetworkConnectionToWebProcess::hasStorageAccess() and NetworkConnectionToWebProcess::requestStorageAccess() when feature is off
+        https://bugs.webkit.org/show_bug.cgi?id=197967
+        <rdar://problem/50753129>
+
+        Reviewed by Brent Fulgham.
+
+        NetworkConnectionToWebProcess::hasStorageAccess() and NetworkConnectionToWebProcess::requestStorageAccess()
+        should call their completion handlers when there is no Resource Load Statistics object, i.e. when Resource
+        Load Statistics is off. This happens for ephemeral sessions which made code for federated login providers
+        hang, waiting for the result to document.hasStorageAccess().
+
+        The existing layout test case was augmented to use an ephemeral session.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::hasStorageAccess):
+        (WebKit::NetworkConnectionToWebProcess::requestStorageAccess):
+
 2019-05-16  Alex Christensen  <achristensen@webkit.org>
 
         Add a unit test for client certificate authentication
index e9c98f2..36acb17 100644 (file)
@@ -682,17 +682,25 @@ void NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated(Vector<WebCore
 void NetworkConnectionToWebProcess::hasStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
 {
     if (auto networkSession = networkProcess().networkSession(sessionID)) {
-        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
+        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) {
             resourceLoadStatistics->hasStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID, WTFMove(completionHandler));
+            return;
+        }
     }
+
+    completionHandler(true);
 }
 
 void NetworkConnectionToWebProcess::requestStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(WebCore::StorageAccessWasGranted wasGranted, WebCore::StorageAccessPromptWasShown promptWasShown)>&& completionHandler)
 {
     if (auto networkSession = networkProcess().networkSession(sessionID)) {
-        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
+        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) {
             resourceLoadStatistics->requestStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID, WTFMove(completionHandler));
+            return;
+        }
     }
+
+    completionHandler(WebCore::StorageAccessWasGranted::Yes, WebCore::StorageAccessPromptWasShown::No);
 }
 
 void NetworkConnectionToWebProcess::requestStorageAccessUnderOpener(PAL::SessionID sessionID, WebCore::RegistrableDomain&& domainInNeedOfStorageAccess, uint64_t openerPageID, WebCore::RegistrableDomain&& openerDomain)