REGRESSION (r185111): Clicking phone numbers doesn't prompt to call sometimes
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Aug 2015 16:05:55 +0000 (16:05 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Aug 2015 16:05:55 +0000 (16:05 +0000)
commite0ed7a9b57ad6b4975d8778ffe13d35916bdb808
tree40b1f28742e663b13f19ec3ca7f08078f29a4fef
parenta5cc870dae1f715009acf0d9de2d05e478a58331
REGRESSION (r185111): Clicking phone numbers doesn't prompt to call sometimes
https://bugs.webkit.org/show_bug.cgi?id=147678
<rdar://problem/21827815>

Reviewed by Brady Eidson.

Source/WebCore:

Fixes an issue where a non-user-initiated navigation of the main frame to a phone link (tel URL)
may be ignored. The navigation is ignored if the page was reloaded as a result of a web content
process crash, its lifetime exceeded the back-forward cache expiration interval, or a person
quits and opens Safari again, among other scenarios.

* history/HistoryItem.cpp:
(WebCore::HistoryItem::setShouldOpenExternalURLsPolicy): Added.
(WebCore::HistoryItem::shouldOpenExternalURLsPolicy): Added.
* history/HistoryItem.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadDifferentDocumentItem): Apply the "should open external URLs" policy
from the history item, if applicable. Also, be more explicit when instantiating a NavigationAction
so as to help make it straightforward to reduce the number of NavigationAction constructors we have
in the future.
* loader/HistoryController.cpp:
(WebCore::HistoryController::saveDocumentState): Save the "should open external URLs" policy to
the history item.
(WebCore::HistoryController::restoreDocumentState): Apply the "should open external URLs" policy
from the history item to the document loader.
(WebCore::HistoryController::initializeItem): Update the "should open external URLs" policy of
the history item to reflect the policy of the document loader associated with the current frame.

Source/WebKit2:

Teach WebKit to save and restore the "should open external URLs" policy.

* Shared/SessionState.cpp:
(WebKit::isValidEnum): Added.
(WebKit::PageState::encode): Modified to encode the "should open external URLs" policy.
(WebKit::PageState::decode): Modified to decode the "should open external URLs" policy.
* Shared/SessionState.h: Added ShouldOpenExternalURLsPolicy to PageState (defaults to WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow).
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _killWebContentProcessAndResetState]): Added; used in the unit test TestWebKitAPI/Tests/WebKit2Cocoa/ShouldOpenExternalURLsInNewWindowActions.mm.
* UIProcess/API/Cocoa/WKWebViewPrivate.h: Declare -[WKWebView _killWebContentProcessAndResetState].
* UIProcess/mac/LegacySessionStateCoding.cpp: Defined constant sessionHistoryEntryShouldOpenExternalURLsPolicyKey.
(WebKit::encodeSessionHistory): Modified to encode the "should open external URLs" policy.
(WebKit::decodeSessionHistoryEntry): Modified to decode the "should open external URLs" policy.
* WebProcess/WebCoreSupport/SessionStateConversion.cpp:
(WebKit::toPageState): Copy "should open external URLs" policy from specified history item.
(WebKit::toHistoryItem): Apply "should open external URLs" policy from PageState to HistoryItem.

Tools:

Add a test to ensure that we restore the "should open external URLs" policy on
page reload after the web content process crashes.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/should-open-external-schemes.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/ShouldOpenExternalURLsInNewWindowActions.mm:
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/history/HistoryItem.cpp
Source/WebCore/history/HistoryItem.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/HistoryController.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/SessionState.cpp
Source/WebKit2/Shared/SessionState.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp
Source/WebKit2/WebProcess/WebCoreSupport/SessionStateConversion.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/should-open-external-schemes.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/ShouldOpenExternalURLsInNewWindowActions.mm