Storage Access API: Make two changes requested by developers and complete refactoring...
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 May 2019 19:55:29 +0000 (19:55 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 May 2019 19:55:29 +0000 (19:55 +0000)
commit1dea385ec6ceb3df8917637996d7863417872f34
tree4e8b81a4cdc8913f7c46aa54bfa6b27869b347b0
parent02867f7af9244e40798baa28cb3d6c35cc3ae738
Storage Access API: Make two changes requested by developers and complete refactoring and cleanup
https://bugs.webkit.org/show_bug.cgi?id=197648
<rdar://problem/50527493>

Reviewed by Chris Dumez.

Source/WebCore:

Developers have requested two minor changes to the Storage Access API:
- Only consume the user gesture when the user explicitly denies access.
- Make document.hasStorageAccess() return true instead of false when the feature is off.

In addition to this, we have refactoring and cleanup to do. Namely:
- Make use of WebCore::RegistrableDomain all the way.
- Remove dead code in WebKit::NetworkProcess since the calls now go through NetworkConnectionToWebProcess.
- Introduce boolean enums for state handling.
- Break out the Storage Access API functionality into a supplement of WebCore::Document.

Reviewed by Chris Dumez.

Tests: http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture.html
       http/tests/storageAccess/deny-without-prompt-preserves-gesture.html
       http/tests/storageAccess/grant-with-prompt-preserves-gesture.html
       http/tests/storageAccess/has-storage-access-true-if-feature-off.html

* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Headers.cmake:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::Document::hasStorageAccess): Deleted.
(WebCore::Document::requestStorageAccess): Deleted.
(WebCore::Document::enableTemporaryTimeUserGesture): Deleted.
(WebCore::Document::consumeTemporaryTimeUserGesture): Deleted.
(WebCore::Document::hasFrameSpecificStorageAccess const): Deleted.
(WebCore::Document::setHasFrameSpecificStorageAccess): Deleted.
* dom/Document.h:
(WebCore::Document::setUserGrantsStorageAccessOverride): Deleted.
    All of this has been moved to the supplement WebCore::DocumentStorageAccess.
* dom/Document.idl:
    The Storage Access API has been moved to DocumentStorageAccess.idl.
* dom/DocumentStorageAccess.cpp: Added.
(WebCore::DocumentStorageAccess::from):
(WebCore::DocumentStorageAccess::supplementName):
(WebCore::DocumentStorageAccess::hasStorageAccess):
(WebCore::DocumentStorageAccess::requestStorageAccess):
(WebCore::DocumentStorageAccess::enableTemporaryTimeUserGesture):
(WebCore::DocumentStorageAccess::consumeTemporaryTimeUserGesture):
(WebCore::DocumentStorageAccess::hasFrameSpecificStorageAccess const):
(WebCore::DocumentStorageAccess::setHasFrameSpecificStorageAccess):
* dom/DocumentStorageAccess.h: Added.
* dom/DocumentStorageAccess.idl: Added.
* page/ChromeClient.h:
* testing/Internals.cpp:
(WebCore::Internals::setUserGrantsStorageAccess): Deleted.
    This was dead code.
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

Developers have requested two minor changes to the Storage Access API:
- Only consume the user gesture when the user explicitly denies access.
- Make document.hasStorageAccess() return true instead of false when the feature is off.

In addition to this, we have refactoring and cleanup to do. Namely:
- Make use of WebCore::RegistrableDomain all the way.
- Remove dead code in WebKit::NetworkProcess since the calls now go through NetworkConnectionToWebProcess.
- Introduce boolean enums for state handling.
- Break out the Storage Access API functionality into a supplement of WebCore::Document.

* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationships):
(WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess):
(WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccessUnderOpener):
(WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccess):
(WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal):
(WebKit::ResourceLoadStatisticsDatabaseStore::hasUserGrantedStorageAccessThroughPrompt const):
    These changes are due to the new enums WebCore::StorageAccessWasGranted and
    WebCore::StorageAccessPromptWasShown.
* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccess):
(WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener):
(WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccess):
(WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal):
(WebKit::ResourceLoadStatisticsMemoryStore::hasUserGrantedStorageAccessThroughPrompt):
    These changes are due to the new enums WebCore::StorageAccessWasGranted and
    WebCore::StorageAccessPromptWasShown.
* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
* NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
    These changes are due to the new enums WebCore::StorageAccessWasGranted and
    WebCore::StorageAccessPromptWasShown.
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
(WebKit::WebResourceLoadStatisticsStore::grantStorageAccess):
(WebKit::WebResourceLoadStatisticsStore::callGrantStorageAccessHandler):
    These changes are due to the new enums WebCore::StorageAccessWasGranted and
    WebCore::StorageAccessPromptWasShown.
(WebKit::WebResourceLoadStatisticsStore::requestStorageAccessGranted): Deleted.
    This function is now no longer exposed and its functionality could be folded into
    the existing WebResourceLoadStatisticsStore::requestStorageAccess() which is more
    clearly named.
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::hasStorageAccess):
(WebKit::NetworkConnectionToWebProcess::requestStorageAccess):
    These changes are due to the new enums WebCore::StorageAccessWasGranted and
    WebCore::StorageAccessPromptWasShown.
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::hasStorageAccessForFrame): Deleted.
(WebKit::NetworkProcess::hasStorageAccess): Deleted.
(WebKit::NetworkProcess::requestStorageAccess): Deleted.
(WebKit::NetworkProcess::requestStorageAccessGranted): Deleted.
(WebKit::NetworkProcess::grantStorageAccess): Deleted.
(WebKit::NetworkProcess::removeAllStorageAccess): Deleted.
    These functions were left behind in the move of ITP to the network process.
    This communication goes through WebKit::NetworkConnectionToWebProcess since a while back.
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* Scripts/webkit/messages.py:
    Instructions for derived IPC code on how to include the new enums
    WebCore::StorageAccessWasGranted and WebCore::StorageAccessPromptWasShown.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::hasStorageAccessForFrame): Deleted.
(WebKit::NetworkProcessProxy::hasStorageAccess): Deleted.
(WebKit::NetworkProcessProxy::requestStorageAccess): Deleted.
(WebKit::NetworkProcessProxy::grantStorageAccess): Deleted.
(WebKit::NetworkProcessProxy::removeAllStorageAccess): Deleted.
    These functions were left behind in the move of ITP to the network process.
    This communication goes through WebKit::NetworkConnectionToWebProcess since a while back.
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::hasStorageAccess): Deleted.
(WebKit::WebsiteDataStore::requestStorageAccess): Deleted.
(WebKit::WebsiteDataStore::grantStorageAccess): Deleted.
    These functions were left behind in the move of ITP to the network process.
    This communication goes through WebKit::NetworkConnectionToWebProcess since a while back.
* UIProcess/WebsiteData/WebsiteDataStore.h:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::hasStorageAccess):
(WebKit::WebChromeClient::requestStorageAccess):
    These changes are due to the new enums WebCore::StorageAccessWasGranted and
    WebCore::StorageAccessPromptWasShown. They also receive WebCore::RegistrableDomain
    objects instead of Strings now.
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::hasStorageAccess):
(WebKit::WebPage::requestStorageAccess):
    These changes are due to the new enums WebCore::StorageAccessWasGranted and
    WebCore::StorageAccessPromptWasShown. They also receive WebCore::RegistrableDomain
    objects instead of Strings now.
* WebProcess/WebPage/WebPage.h:

LayoutTests:

The changed test cases have had calls to WebCore::Internals::setUserGrantsStorageAccess() removed
since it was dead code.

One of the new tests, deny-with-prompt-does-not-preserve-gesture.html, is marked [ Skip ] for now since
we lack the ability to click "Don't allow" in the prompt. I wanted to include the test anyway so that
we have it. I have done a manual test to make sure the code does the right thing for this case.

* http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture-expected.txt: Added.
* http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture.html: Copied from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window.html.
* http/tests/storageAccess/deny-without-prompt-preserves-gesture-expected.txt: Added.
* http/tests/storageAccess/deny-without-prompt-preserves-gesture.html: Copied from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window.html.
* http/tests/storageAccess/grant-with-prompt-preserves-gesture-expected.txt: Renamed from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window-expected.txt.
* http/tests/storageAccess/grant-with-prompt-preserves-gesture.html: Renamed from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window.html.
* http/tests/storageAccess/has-storage-access-true-if-feature-off-expected.txt: Added.
* http/tests/storageAccess/has-storage-access-true-if-feature-off.html: Added.
* http/tests/storageAccess/resources/request-storage-access-and-immediately-postmessage-iframe.html:
* http/tests/storageAccess/resources/request-storage-access-iframe-and-pop-window.html:
* http/tests/storageAccess/resources/request-storage-access-iframe.html:
* http/tests/storageAccess/resources/request-storage-access-without-user-gesture-iframe.html:
* http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html:
* platform/mac-wk2/TestExpectations:
    Added expectations for the new tests.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245025 268f45cc-cd09-0410-ab3c-d52691b4dbfc
55 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/storageAccess/deny-with-prompt-does-not-preserve-gesture.html [new file with mode: 0644]
LayoutTests/http/tests/storageAccess/deny-without-prompt-preserves-gesture-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/storageAccess/deny-without-prompt-preserves-gesture.html [new file with mode: 0644]
LayoutTests/http/tests/storageAccess/grant-with-prompt-preserves-gesture-expected.txt [moved from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window-expected.txt with 100% similarity]
LayoutTests/http/tests/storageAccess/grant-with-prompt-preserves-gesture.html [moved from LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-pop-window.html with 97% similarity]
LayoutTests/http/tests/storageAccess/has-storage-access-true-if-feature-off-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/storageAccess/has-storage-access-true-if-feature-off.html [new file with mode: 0644]
LayoutTests/http/tests/storageAccess/resources/request-storage-access-and-immediately-postmessage-iframe.html
LayoutTests/http/tests/storageAccess/resources/request-storage-access-iframe-and-pop-window.html
LayoutTests/http/tests/storageAccess/resources/request-storage-access-iframe.html
LayoutTests/http/tests/storageAccess/resources/request-storage-access-without-user-gesture-iframe.html
LayoutTests/http/tests/storageAccess/resources/self-navigating-frame-after-granted-access.html
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources-input.xcfilelist
Source/WebCore/DerivedSources-output.xcfilelist
Source/WebCore/DerivedSources.make
Source/WebCore/Headers.cmake
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Document.idl
Source/WebCore/dom/DocumentStorageAccess.cpp [new file with mode: 0644]
Source/WebCore/dom/DocumentStorageAccess.h [new file with mode: 0644]
Source/WebCore/dom/DocumentStorageAccess.idl [new file with mode: 0644]
Source/WebCore/page/ChromeClient.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcess.messages.in
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h