PSON: Don't create a new process when navigating to a blob URL, data URL, and about...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Apr 2018 20:48:03 +0000 (20:48 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Apr 2018 20:48:03 +0000 (20:48 +0000)
commitb22d18bdc1851bce01df844e4bd2d40bb7675f97
tree356a08afca13b431c4ccfe3be5e4be348a427a20
parente9a4beb52d5482a97fc9a17bb5ca29019f487e32
PSON: Don't create a new process when navigating to a blob URL, data URL, and about:blank
https://bugs.webkit.org/show_bug.cgi?id=184962

Reviewed by Youenn Fablet.

Source/WebCore:

Added NavigationAction::treatAsSameOriginNavigation, which signifies WebKit code to avoid creating
a new WebContent process when navigating to a blob URL, data URL, and about:blank.

Tests: ProcessSwap.SameOriginBlobNavigation
       ProcessSwap.CrossOriginBlobNavigation
       ProcessSwap.NavigateToAboutBlank
       ProcessSwap.NavigateToDataURL

* loader/NavigationAction.cpp:
(WebCore::treatAsSameOriginNavigation):
* loader/NavigationAction.h:
(WebCore::NavigationAction::treatAsSameOriginNavigation const):

Source/WebKit:

Don't create a new WebContent process when navigating to a blob object URL since doing so
can result in a race condition in which the blog URL is removed from the blob registry of
the network process by the time the navigation gets commited. This causes a failure in
fast/dom/HTMLAnchorElement/anchor-download-unset.html and oher layout tests.

In the future, the network process should verify that a given WebContent process has access
to a given blob URL. For now, we rely on WebContent process to tell us whether it can
navigate to a given blob URL or not.

* Shared/NavigationActionData.cpp:
(WebKit::NavigationActionData::encode const): Encode newly added treatAsSameOriginNavigation.
(WebKit::NavigationActionData::decode): Ditto for decoding.
* Shared/NavigationActionData.h:
(WebKit::NavigationActionData::treatAsSameOriginNavigation): Added.
* UIProcess/API/APINavigation.h:
(API::Navigation::setTreatAsSameOriginNavigation): Added.
(API::Navigation::treatAsSameOriginNavigation const): Added.
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::decidePolicyForNavigationAction): Use the current process when
treatAsSameOriginNavigation is set to true; i.e. when navigating to a blob URL the current
document has access.
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForNavigation):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):

Tools:

Added four test cases for navigating to a blob URL, data URL, and about:blank with process-swap-on-navigation turned on.

* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
(ProcessSwap.SameOriginBlobNavigation): Added.
(ProcessSwap.CrossOriginBlobNavigation): Added.
(ProcessSwap.NavigateToAboutBlank): Added.
(ProcessSwap.NavigateToDataURL): Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231019 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/NavigationAction.cpp
Source/WebCore/loader/NavigationAction.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/NavigationActionData.cpp
Source/WebKit/Shared/NavigationActionData.h
Source/WebKit/UIProcess/API/APINavigation.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm