REGRESSION (r229831): CMD-clicking an iCloud web app link unexpectedly opens that...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Apr 2018 18:13:49 +0000 (18:13 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Apr 2018 18:13:49 +0000 (18:13 +0000)
commitb6315a966b08f126c55e3a1ef7e91557a37b2ac5
tree7160d07d35339f80563afeff1d09b2cb93a12ca4
parentc58390dc1e2379157f2cd4ccc36b330734c5df59
REGRESSION (r229831): CMD-clicking an iCloud web app link unexpectedly opens that link in a new tab and the current tab
https://bugs.webkit.org/show_bug.cgi?id=184678
<rdar://problem/39422122>

Reviewed by Alex Christensen.

Source/WebCore:

Frament navigations need to happen synchronously for Web-compatibility. Because of this,
r225657 added code to make sure that if the client does not make the navigation policy
decision synchronously for frament navigations, then we'll stop waiting for the client
and proceed with the navigation. However, r229831 make the navigation policy decision
IPC decision, meaning that even if the client responds synchronously, it would be
asynchronously from WebCore's point of view. As a result, we would always ignore the
client's policy decision when doing a fragment navigation.

This is an issue on iclould.com because the web-app links are fragment URLs. When you
CMD+click one of these link, we do the navigation policy check. As a result of this
check, Safari responds IGNORE to the policy decision and instead decides to load the
link in a new tab (because CMD key is pressed). Due to the bug mentioned above, we
would not obey the IGNORE policy decision from Safari and load the link in the current
tab, even though Safari would already be loading it in a new tab.

To address the issue, I reintroduced a synchronous code path for navigation policy
decision making, backed by synchronous IPC. This synchronous code path is now used for
fragment navigations to restore pre-r229831 behavior. If the client does not answer
synchronously, we'll proceed with the navigation anyway, as was happening pre-r229831.

Test: http/tests/navigation/fragment-navigation-policy-ignore.html

* loader/EmptyClients.cpp:
(WebCore::EmptyFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* loader/EmptyFrameLoaderClient.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURL):
(WebCore::FrameLoader::loadWithDocumentLoader):
* loader/FrameLoaderClient.h:
* loader/PolicyChecker.cpp:
(WebCore::PolicyChecker::checkNavigationPolicy):
* loader/PolicyChecker.h:

Source/WebKit:

Re-introduce synchronous code path which existed pre-r229831 and use it for fragment navigations.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::receivedPolicyDecision):
(WebKit::WebPageProxy::decidePolicyForNavigationActionSync):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:

Source/WebKitLegacy/mac:

Add new parameter to dispatchDecidePolicyForNavigationAction.

* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):

Source/WebKitLegacy/win:

Add new parameter to dispatchDecidePolicyForNavigationAction.

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* WebCoreSupport/WebFrameLoaderClient.h:

LayoutTests:

Add layout test coverage.

* http/tests/navigation/fragment-navigation-policy-ignore-expected.txt: Added.
* http/tests/navigation/fragment-navigation-policy-ignore.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230721 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/navigation/fragment-navigation-policy-ignore-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/fragment-navigation-policy-ignore.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/EmptyFrameLoaderClient.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoaderClient.h
Source/WebCore/loader/PolicyChecker.cpp
Source/WebCore/loader/PolicyChecker.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h