Title: [255522] trunk
Revision
255522
Author
[email protected]
Date
2020-01-31 15:16:47 -0800 (Fri, 31 Jan 2020)

Log Message

Add KVO SPI WKWebView._negotiatedLegacyTLS
https://bugs.webkit.org/show_bug.cgi?id=207067

Patch by Alex Christensen <[email protected]> on 2020-01-31
Reviewed by Andy Estes.

Source/WebKit:

Covered by API tests.

* NetworkProcess/NetworkDataTask.cpp:
(WebKit::NetworkDataTask::negotiatedLegacyTLS const):
* NetworkProcess/NetworkDataTask.h:
(WebKit::NetworkDataTaskClient::negotiatedLegacyTLS const):
* NetworkProcess/NetworkLoad.cpp:
(WebKit::NetworkLoad::negotiatedLegacyTLS const):
* NetworkProcess/NetworkLoad.h:
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]):
* Shared/Authentication/AuthenticationManager.cpp:
(WebKit::AuthenticationManager::negotiatedLegacyTLS const):
* Shared/Authentication/AuthenticationManager.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _negotiatedLegacyTLS]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::willChangeNegotiatedLegacyTLS):
(WebKit::NavigationState::didChangeNegotiatedLegacyTLS):
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::negotiatedLegacyTLS):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.messages.in:
* UIProcess/PageLoadState.cpp:
(WebKit::PageLoadState::commitChanges):
(WebKit::PageLoadState::hasNegotiatedLegacyTLS const):
(WebKit::PageLoadState::negotiatedLegacyTLS):
(WebKit::PageLoadState::didCommitLoad):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Observer::willChangeNegotiatedLegacyTLS):
(WebKit::PageLoadState::Observer::didChangeNegotiatedLegacyTLS):
(WebKit::PageLoadState::Data::Data): Deleted.
* UIProcess/WebPageProxy.cpp:
* UIProcess/WebPageProxy.h:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm:
(-[TLSObserver observeValueForKeyPath:ofObject:change:context:]):
(-[TLSObserver waitUntilNegotiatedLegacyTLSChanged]):
(TestWebKitAPI::TEST):
* TestWebKitAPI/config.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (255521 => 255522)


--- trunk/Source/WebKit/ChangeLog	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/ChangeLog	2020-01-31 23:16:47 UTC (rev 255522)
@@ -1,3 +1,47 @@
+2020-01-31  Alex Christensen  <[email protected]>
+
+        Add KVO SPI WKWebView._negotiatedLegacyTLS
+        https://bugs.webkit.org/show_bug.cgi?id=207067
+
+        Reviewed by Andy Estes.
+
+        Covered by API tests.
+
+        * NetworkProcess/NetworkDataTask.cpp:
+        (WebKit::NetworkDataTask::negotiatedLegacyTLS const):
+        * NetworkProcess/NetworkDataTask.h:
+        (WebKit::NetworkDataTaskClient::negotiatedLegacyTLS const):
+        * NetworkProcess/NetworkLoad.cpp:
+        (WebKit::NetworkLoad::negotiatedLegacyTLS const):
+        * NetworkProcess/NetworkLoad.h:
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]):
+        * Shared/Authentication/AuthenticationManager.cpp:
+        (WebKit::AuthenticationManager::negotiatedLegacyTLS const):
+        * Shared/Authentication/AuthenticationManager.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _negotiatedLegacyTLS]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/Cocoa/NavigationState.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::willChangeNegotiatedLegacyTLS):
+        (WebKit::NavigationState::didChangeNegotiatedLegacyTLS):
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::negotiatedLegacyTLS):
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/Network/NetworkProcessProxy.messages.in:
+        * UIProcess/PageLoadState.cpp:
+        (WebKit::PageLoadState::commitChanges):
+        (WebKit::PageLoadState::hasNegotiatedLegacyTLS const):
+        (WebKit::PageLoadState::negotiatedLegacyTLS):
+        (WebKit::PageLoadState::didCommitLoad):
+        * UIProcess/PageLoadState.h:
+        (WebKit::PageLoadState::Observer::willChangeNegotiatedLegacyTLS):
+        (WebKit::PageLoadState::Observer::didChangeNegotiatedLegacyTLS):
+        (WebKit::PageLoadState::Data::Data): Deleted.
+        * UIProcess/WebPageProxy.cpp:
+        * UIProcess/WebPageProxy.h:
+
 2020-01-31  Chris Dumez  <[email protected]>
 
         Unreviewed macOS build fix after r255518

Modified: trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp (255521 => 255522)


--- trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp	2020-01-31 23:16:47 UTC (rev 255522)
@@ -116,6 +116,12 @@
         completionHandler(PolicyAction::Ignore);
 }
 
+void NetworkDataTask::negotiatedLegacyTLS() const
+{
+    if (m_client)
+        m_client->negotiatedLegacyTLS();
+}
+
 bool NetworkDataTask::shouldCaptureExtraNetworkLoadMetrics() const
 {
     return m_client ? m_client->shouldCaptureExtraNetworkLoadMetrics() : false;

Modified: trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h (255521 => 255522)


--- trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h	2020-01-31 23:16:47 UTC (rev 255522)
@@ -70,6 +70,7 @@
     virtual void cannotShowURL() = 0;
     virtual void wasBlockedByRestrictions() = 0;
 
+    virtual void negotiatedLegacyTLS() const { }
     virtual bool shouldCaptureExtraNetworkLoadMetrics() const { return false; }
 
     void didCompleteWithError(const WebCore::ResourceError& error)
@@ -92,6 +93,7 @@
     virtual void invalidateAndCancel() = 0;
 
     void didReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&);
+    void negotiatedLegacyTLS() const;
     bool shouldCaptureExtraNetworkLoadMetrics() const;
 
     enum class State {

Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp (255521 => 255522)


--- trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp	2020-01-31 23:16:47 UTC (rev 255522)
@@ -206,6 +206,11 @@
         m_networkProcess->authenticationManager().didReceiveAuthenticationChallenge(m_task->sessionID(), m_parameters.webPageProxyID, m_parameters.topOrigin ? &m_parameters.topOrigin->data() : nullptr, challenge, negotiatedLegacyTLS, WTFMove(completionHandler));
 }
 
+void NetworkLoad::negotiatedLegacyTLS() const
+{
+    m_networkProcess->authenticationManager().negotiatedLegacyTLS(m_parameters.webPageProxyID);
+}
+
 void NetworkLoad::didReceiveResponse(ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)
 {
     ASSERT(RunLoop::isMain());

Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoad.h (255521 => 255522)


--- trunk/Source/WebKit/NetworkProcess/NetworkLoad.h	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoad.h	2020-01-31 23:16:47 UTC (rev 255522)
@@ -81,6 +81,7 @@
     void wasBlocked() final;
     void cannotShowURL() final;
     void wasBlockedByRestrictions() final;
+    void negotiatedLegacyTLS() const final;
 
     void notifyDidReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&);
     void throttleDelayCompleted();

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (255521 => 255522)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2020-01-31 23:16:47 UTC (rev 255522)
@@ -813,6 +813,25 @@
     LOG(NetworkSession, "%llu didReceiveResponse", taskIdentifier);
     if (auto* networkDataTask = [self existingTask:dataTask]) {
         ASSERT(RunLoop::isMain());
+
+        bool negotiatedLegacyTLS = false;
+#if HAVE(TLS_PROTOCOL_VERSION_T)
+        NSURLSessionTaskTransactionMetrics *metrics = dataTask._incompleteTaskMetrics.transactionMetrics.lastObject;
+        auto tlsVersion = reinterpret_cast<tls_protocol_version_t>(metrics.negotiatedTLSProtocolVersion.unsignedShortValue);
+        if (tlsVersion == tls_protocol_version_TLSv10 || tlsVersion == tls_protocol_version_TLSv11)
+            negotiatedLegacyTLS = true;
+        UNUSED_PARAM(metrics);
+#else // We do not need to check _TLSNegotiatedProtocolVersion if we have metrics.negotiatedTLSProtocolVersion because it works at response time even before rdar://problem/56522601
+        ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+        if ([dataTask respondsToSelector:@selector(_TLSNegotiatedProtocolVersion)]) {
+            SSLProtocol tlsVersion = [dataTask _TLSNegotiatedProtocolVersion];
+            if (tlsVersion == kTLSProtocol11 || tlsVersion == kTLSProtocol1)
+                negotiatedLegacyTLS = true;
+        }
+        ALLOW_DEPRECATED_DECLARATIONS_END
+#endif
+        if (negotiatedLegacyTLS)
+            networkDataTask->negotiatedLegacyTLS();
         
         // Avoid MIME type sniffing if the response comes back as 304 Not Modified.
         int statusCode = [response isKindOfClass:NSHTTPURLResponse.class] ? [(NSHTTPURLResponse *)response statusCode] : 0;

Modified: trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.cpp (255521 => 255522)


--- trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.cpp	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.cpp	2020-01-31 23:16:47 UTC (rev 255522)
@@ -149,4 +149,9 @@
     }
 }
 
+void AuthenticationManager::negotiatedLegacyTLS(WebPageProxyIdentifier pageID) const
+{
+    m_process.send(Messages::NetworkProcessProxy::NegotiatedLegacyTLS(pageID));
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.h (255521 => 255522)


--- trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.h	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.h	2020-01-31 23:16:47 UTC (rev 255522)
@@ -75,6 +75,8 @@
 
     void completeAuthenticationChallenge(uint64_t challengeID, AuthenticationChallengeDisposition, WebCore::Credential&&);
 
+    void negotiatedLegacyTLS(WebPageProxyIdentifier) const;
+
 private:
     struct Challenge {
         WebPageProxyIdentifier pageID;

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (255521 => 255522)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-01-31 23:16:47 UTC (rev 255522)
@@ -1550,6 +1550,11 @@
     return nil;
 }
 
+- (BOOL)_negotiatedLegacyTLS
+{
+    return _page->pageLoadState().hasNegotiatedLegacyTLS();
+}
+
 - (BOOL)_isEditable
 {
     return _page && _page->isEditable();

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (255521 => 255522)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2020-01-31 23:16:47 UTC (rev 255522)
@@ -164,6 +164,13 @@
 
 @property (nonatomic, getter=_isEditable, setter=_setEditable:) BOOL _editable WK_API_AVAILABLE(macos(10.11), ios(9.0));
 
+/*! @abstract A Boolean value indicating whether any resource on the page
+has been loaded over a connection using TLS 1.0 or TLS 1.1.
+@discussion @link WKWebView @/link is key-value observing (KVO) compliant
+for this property.
+*/
+@property (nonatomic, readonly) BOOL _negotiatedLegacyTLS WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 // FIXME: Remove these once nobody is using them.
 @property (nonatomic, readonly) NSData *_sessionStateData;
 - (void)_restoreFromSessionStateData:(NSData *)sessionStateData;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h (255521 => 255522)


--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h	2020-01-31 23:16:47 UTC (rev 255522)
@@ -170,6 +170,8 @@
     void didChangeActiveURL() override;
     void willChangeHasOnlySecureContent() override;
     void didChangeHasOnlySecureContent() override;
+    void willChangeNegotiatedLegacyTLS() override;
+    void didChangeNegotiatedLegacyTLS() override;
     void willChangeEstimatedProgress() override;
     void didChangeEstimatedProgress() override;
     void willChangeCanGoBack() override;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (255521 => 255522)


--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2020-01-31 23:16:47 UTC (rev 255522)
@@ -1321,6 +1321,16 @@
     [m_webView didChangeValueForKey:@"hasOnlySecureContent"];
 }
 
+void NavigationState::willChangeNegotiatedLegacyTLS()
+{
+    [m_webView willChangeValueForKey:@"_negotiatedLegacyTLS"];
+}
+
+void NavigationState::didChangeNegotiatedLegacyTLS()
+{
+    [m_webView didChangeValueForKey:@"_negotiatedLegacyTLS"];
+}
+
 void NavigationState::willChangeEstimatedProgress()
 {
     [m_webView willChangeValueForKey:@"estimatedProgress"];

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (255521 => 255522)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2020-01-31 23:16:47 UTC (rev 255522)
@@ -369,6 +369,15 @@
     });
 }
 
+void NetworkProcessProxy::negotiatedLegacyTLS(WebPageProxyIdentifier pageID)
+{
+    WebPageProxy* page = nullptr;
+    if (pageID)
+        page = WebProcessProxy::webPage(pageID);
+    if (page)
+        page->negotiatedLegacyTLS();
+}
+
 void NetworkProcessProxy::didFetchWebsiteData(uint64_t callbackID, const WebsiteData& websiteData)
 {
     MESSAGE_CHECK(m_pendingFetchWebsiteDataCallbacks.isValidKey(callbackID));

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (255521 => 255522)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2020-01-31 23:16:47 UTC (rev 255522)
@@ -236,6 +236,7 @@
     // Message handlers
     void didReceiveNetworkProcessProxyMessage(IPC::Connection&, IPC::Decoder&);
     void didReceiveAuthenticationChallenge(PAL::SessionID, WebPageProxyIdentifier, const Optional<WebCore::SecurityOriginData>&, WebCore::AuthenticationChallenge&&, bool, uint64_t challengeID);
+    void negotiatedLegacyTLS(WebPageProxyIdentifier);
     void didFetchWebsiteData(uint64_t callbackID, const WebsiteData&);
     void didDeleteWebsiteData(uint64_t callbackID);
     void didDeleteWebsiteDataForOrigins(uint64_t callbackID);

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (255521 => 255522)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2020-01-31 23:16:47 UTC (rev 255522)
@@ -22,6 +22,7 @@
 
 messages -> NetworkProcessProxy LegacyReceiver NotRefCounted {
     DidReceiveAuthenticationChallenge(PAL::SessionID sessionID, WebKit::WebPageProxyIdentifier pageID, Optional<WebCore::SecurityOriginData> topOrigin, WebCore::AuthenticationChallenge challenge, bool negotiatedLegacyTLS, uint64_t challengeID)
+    NegotiatedLegacyTLS(WebKit::WebPageProxyIdentifier pageID)
 
     DidFetchWebsiteData(uint64_t callbackID, struct WebKit::WebsiteData websiteData)
     DidDeleteWebsiteData(uint64_t callbackID)

Modified: trunk/Source/WebKit/UIProcess/PageLoadState.cpp (255521 => 255522)


--- trunk/Source/WebKit/UIProcess/PageLoadState.cpp	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/UIProcess/PageLoadState.cpp	2020-01-31 23:16:47 UTC (rev 255522)
@@ -99,6 +99,7 @@
     bool isLoadingChanged = isLoading(m_committedState) != isLoading(m_uncommittedState);
     bool activeURLChanged = activeURL(m_committedState) != activeURL(m_uncommittedState);
     bool hasOnlySecureContentChanged = hasOnlySecureContent(m_committedState) != hasOnlySecureContent(m_uncommittedState);
+    bool negotiatedLegacyTLSChanged = m_committedState.negotiatedLegacyTLS != m_uncommittedState.negotiatedLegacyTLS;
     bool estimatedProgressChanged = estimatedProgress(m_committedState) != estimatedProgress(m_uncommittedState);
     bool networkRequestsInProgressChanged = m_committedState.networkRequestsInProgress != m_uncommittedState.networkRequestsInProgress;
     bool certificateInfoChanged = m_committedState.certificateInfo != m_uncommittedState.certificateInfo;
@@ -115,6 +116,8 @@
         callObserverCallback(&Observer::willChangeActiveURL);
     if (hasOnlySecureContentChanged)
         callObserverCallback(&Observer::willChangeHasOnlySecureContent);
+    if (negotiatedLegacyTLSChanged)
+        callObserverCallback(&Observer::willChangeNegotiatedLegacyTLS);
     if (estimatedProgressChanged)
         callObserverCallback(&Observer::willChangeEstimatedProgress);
     if (networkRequestsInProgressChanged)
@@ -135,6 +138,8 @@
         callObserverCallback(&Observer::didChangeEstimatedProgress);
     if (hasOnlySecureContentChanged)
         callObserverCallback(&Observer::didChangeHasOnlySecureContent);
+    if (negotiatedLegacyTLSChanged)
+        callObserverCallback(&Observer::didChangeNegotiatedLegacyTLS);
     if (activeURLChanged)
         callObserverCallback(&Observer::didChangeActiveURL);
     if (isLoadingChanged)
@@ -221,6 +226,17 @@
     return hasOnlySecureContent(m_committedState);
 }
 
+bool PageLoadState::hasNegotiatedLegacyTLS() const
+{
+    return m_committedState.negotiatedLegacyTLS;
+}
+
+void PageLoadState::negotiatedLegacyTLS(const Transaction::Token& token)
+{
+    ASSERT_UNUSED(token, &token.m_pageLoadState == this);
+    m_uncommittedState.negotiatedLegacyTLS = true;
+}
+
 double PageLoadState::estimatedProgress(const Data& data)
 {
     if (!data.pendingAPIRequest.url.isNull())
@@ -312,6 +328,7 @@
 
     m_uncommittedState.url = ""
     m_uncommittedState.provisionalURL = String();
+    m_uncommittedState.negotiatedLegacyTLS = false;
 
     m_uncommittedState.title = String();
 }

Modified: trunk/Source/WebKit/UIProcess/PageLoadState.h (255521 => 255522)


--- trunk/Source/WebKit/UIProcess/PageLoadState.h	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/UIProcess/PageLoadState.h	2020-01-31 23:16:47 UTC (rev 255522)
@@ -62,6 +62,9 @@
         virtual void willChangeHasOnlySecureContent() = 0;
         virtual void didChangeHasOnlySecureContent() = 0;
 
+        virtual void willChangeNegotiatedLegacyTLS() { };
+        virtual void didChangeNegotiatedLegacyTLS() { };
+
         virtual void willChangeEstimatedProgress() = 0;
         virtual void didChangeEstimatedProgress() = 0;
 
@@ -140,6 +143,8 @@
     String activeURL() const;
 
     bool hasOnlySecureContent() const;
+    bool hasNegotiatedLegacyTLS() const;
+    void negotiatedLegacyTLS(const Transaction::Token&);
 
     double estimatedProgress() const;
     bool networkRequestsInProgress() const { return m_committedState.networkRequestsInProgress; }
@@ -200,19 +205,10 @@
     Vector<Observer*> m_observers;
 
     struct Data {
-        Data()
-            : state(State::Finished)
-            , hasInsecureContent(false)
-            , canGoBack(false)
-            , canGoForward(false)
-            , estimatedProgress(0)
-            , networkRequestsInProgress(false)
-        {
-        }
+        State state { State::Finished };
+        bool hasInsecureContent { false };
+        bool negotiatedLegacyTLS { false };
 
-        State state;
-        bool hasInsecureContent;
-
         PendingAPIRequest pendingAPIRequest;
 
         String provisionalURL;
@@ -224,11 +220,11 @@
 
         URL resourceDirectoryURL;
 
-        bool canGoBack;
-        bool canGoForward;
+        bool canGoBack { false };
+        bool canGoForward { false };
 
-        double estimatedProgress;
-        bool networkRequestsInProgress;
+        double estimatedProgress { 0 };
+        bool networkRequestsInProgress { false };
 
         RefPtr<WebCertificateInfo> certificateInfo;
     };

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (255521 => 255522)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-01-31 23:16:47 UTC (rev 255522)
@@ -7713,6 +7713,12 @@
     m_navigationClient->didReceiveAuthenticationChallenge(*this, authenticationChallenge.get());
 }
 
+void WebPageProxy::negotiatedLegacyTLS()
+{
+    auto transaction = m_pageLoadState.transaction();
+    m_pageLoadState.negotiatedLegacyTLS(transaction);
+}
+
 void WebPageProxy::exceededDatabaseQuota(FrameIdentifier frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply&& reply)
 {
     requestStorageSpace(frameID, originIdentifier, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage, [reply = WTFMove(reply)](auto quota) mutable {

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (255521 => 255522)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-01-31 23:16:47 UTC (rev 255522)
@@ -1335,6 +1335,7 @@
     WebCore::IntSize viewportSizeForCSSViewportUnits() const { return m_viewportSizeForCSSViewportUnits.valueOr(WebCore::IntSize()); }
 
     void didReceiveAuthenticationChallengeProxy(Ref<AuthenticationChallengeProxy>&&, NegotiatedLegacyTLS);
+    void negotiatedLegacyTLS();
 
     SpellDocumentTag spellDocumentTag();
 

Modified: trunk/Tools/ChangeLog (255521 => 255522)


--- trunk/Tools/ChangeLog	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Tools/ChangeLog	2020-01-31 23:16:47 UTC (rev 255522)
@@ -1,3 +1,16 @@
+2020-01-31  Alex Christensen  <[email protected]>
+
+        Add KVO SPI WKWebView._negotiatedLegacyTLS
+        https://bugs.webkit.org/show_bug.cgi?id=207067
+
+        Reviewed by Andy Estes.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm:
+        (-[TLSObserver observeValueForKeyPath:ofObject:change:context:]):
+        (-[TLSObserver waitUntilNegotiatedLegacyTLSChanged]):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/config.h:
+
 2020-01-31  Aakash Jain  <[email protected]>
 
         [ews] Display flaky test names in build summary when ReRunWebKitTests passes

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm (255521 => 255522)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm	2020-01-31 23:16:47 UTC (rev 255522)
@@ -43,6 +43,31 @@
 #import <WebKit/WebCoreThread.h>
 #endif
 
+#if HAVE(TLS_PROTOCOL_VERSION_T)
+@interface TLSObserver : NSObject
+- (void)waitUntilNegotiatedLegacyTLSChanged;
+@end
+
+@implementation TLSObserver {
+    bool _negotiatedLegacyTLSChanged;
+}
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+    EXPECT_WK_STREQ(keyPath, "_negotiatedLegacyTLS");
+    _negotiatedLegacyTLSChanged = true;
+}
+
+- (void)waitUntilNegotiatedLegacyTLSChanged
+{
+    _negotiatedLegacyTLSChanged = false;
+    while (!_negotiatedLegacyTLSChanged)
+        TestWebKitAPI::Util::spinRunLoop();
+}
+
+@end
+#endif
+
 @interface TLSNavigationDelegate : NSObject <WKNavigationDelegate>
 - (void)waitForDidFinishNavigation;
 - (void)waitForDidFailProvisionalNavigation;
@@ -202,6 +227,43 @@
     }
 }
 
+#if HAVE(TLS_PROTOCOL_VERSION_T)
+TEST(TLSVersion, NegotiatedLegacyTLS)
+{
+    TCPServer server(TCPServer::Protocol::HTTPS, [] (SSL *ssl) {
+        TCPServer::respondWithOK(ssl);
+        TCPServer::respondWithOK(ssl);
+    }, tls1_1);
+
+    auto delegate = adoptNS([TestNavigationDelegate new]);
+    auto webView = adoptNS([WKWebView new]);
+    [webView setNavigationDelegate:delegate.get()];
+    [delegate setDidReceiveAuthenticationChallenge:^(WKWebView *, NSURLAuthenticationChallenge *challenge, void (^callback)(NSURLSessionAuthChallengeDisposition, NSURLCredential *)) {
+        EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodServerTrust);
+        callback(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
+    }];
+    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]];
+    [webView loadRequest:request];
+
+    auto observer = adoptNS([TLSObserver new]);
+    [webView addObserver:observer.get() forKeyPath:@"_negotiatedLegacyTLS" options:NSKeyValueObservingOptionNew context:nil];
+    
+    EXPECT_FALSE([webView _negotiatedLegacyTLS]);
+    [observer waitUntilNegotiatedLegacyTLSChanged];
+    EXPECT_TRUE([webView _negotiatedLegacyTLS]);
+
+    [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+    [observer waitUntilNegotiatedLegacyTLSChanged];
+    EXPECT_FALSE([webView _negotiatedLegacyTLS]);
+
+    [webView loadRequest:request];
+    [observer waitUntilNegotiatedLegacyTLSChanged];
+    EXPECT_TRUE([webView _negotiatedLegacyTLS]);
+
+    [webView removeObserver:observer.get() forKeyPath:@"_negotiatedLegacyTLS"];
+}
+#endif
+
 // FIXME: Add some tests for WKWebView.hasOnlySecureContent
 
 }

Modified: trunk/Tools/TestWebKitAPI/config.h (255521 => 255522)


--- trunk/Tools/TestWebKitAPI/config.h	2020-01-31 21:45:57 UTC (rev 255521)
+++ trunk/Tools/TestWebKitAPI/config.h	2020-01-31 23:16:47 UTC (rev 255522)
@@ -122,3 +122,7 @@
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || PLATFORM(IOS)
 #define HAVE_NETWORK_FRAMEWORK 1
 #endif
+
+#if PLATFORM(COCOA) && !(PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500)
+#define HAVE_TLS_PROTOCOL_VERSION_T 1
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to