Regression(AsyncPolicyDelegates): Box.app login Window is blank
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2018 22:41:06 +0000 (22:41 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2018 22:41:06 +0000 (22:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185832
<rdar://problem/40307871>

Reviewed by Geoffrey Garen.

Source/WebKit:

Moved WeakObjCPtr.h header from WebKit/ to wtf/ so that it can be used in
WebKitLegacy code.

* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
* UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h:
* UIProcess/API/Cocoa/WKConnection.mm:
* UIProcess/API/Cocoa/WKHTTPCookieStore.mm:
* UIProcess/API/Cocoa/WKProcessGroup.mm:
* UIProcess/API/Cocoa/WKProcessPool.mm:
* UIProcess/API/Cocoa/WKScriptMessage.mm:
* UIProcess/API/Cocoa/WKWebView.mm:
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
* UIProcess/API/Cocoa/_WKAutomationSession.mm:
* UIProcess/API/Cocoa/_WKDownload.mm:
* UIProcess/API/Cocoa/_WKElementAction.mm:
* UIProcess/ApplicationStateTracker.h:
* UIProcess/Cocoa/AutomationClient.h:
* UIProcess/Cocoa/AutomationSessionClient.h:
* UIProcess/Cocoa/DiagnosticLoggingClient.h:
* UIProcess/Cocoa/DownloadClient.h:
* UIProcess/Cocoa/FindClient.h:
* UIProcess/Cocoa/FullscreenClient.h:
* UIProcess/Cocoa/IconLoadingDelegate.h:
* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/UIDelegate.h:
* UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
* UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm:
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/ios/ViewGestureControllerIOS.mm:
* UIProcess/ios/WKActionSheetAssistant.mm:
* UIProcess/ios/WKContentViewInteraction.mm:
* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView web_setContentProviderData:suggestedFilename:]):
* UIProcess/ios/WKScrollView.mm:
* UIProcess/mac/WKInspectorViewController.mm:
* UIProcess/mac/WKInspectorWKWebView.mm:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:

Source/WebKitLegacy/mac:

We used to have a bug where where we would fail to wait for the policy decision for
the navigation response from the client and the load would keep going, racing with
the client's policy decision. If the client did not respond in time, the behavior
would be the same as "Use" policy action.

Box.app fails to make any policy decision in its decidePolicyForMIMEType delegate
but the load happened to proceed anyway due to our bug. Now that we've fixed the
WebKit bug, however, the load would hang because the completion handler for the
decidePolicyForNavigationResponse would never get called.

To work around the issue, I made the policy listener weak on the WebFrameLoaderClient
instead of retaining it. If the policy listener object gets destroyed because getting
resolved, we now use "Use" policy action in its dealloc function to maintain previous
behavior.

* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::cancelPolicyCheck):
(WebFrameLoaderClient::setUpPolicyListener):
(-[WebFramePolicyListener dealloc]):

Source/WTF:

Moved WeakObjCPtr.h from WebKit2 to WTF with RetainPtr.h, so that it can be used
in WebKitLegacy code.

* WTF.xcodeproj/project.pbxproj:
* wtf/WeakObjCPtr.h: Renamed from Source/WebKit/Shared/mac/WeakObjCPtr.h.

Tools:

Add API test coverage.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/cocoa/WeakObjCPtr.mm:
* TestWebKitAPI/Tests/mac/NoPolicyDelegateResponse.mm: Added.
(-[NoPolicyDelegateDecisionDelegate webView:decidePolicyForNavigationAction:request:frame:decisionListener:]):
(-[NoPolicyDelegateDecisionDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]):
(-[NoPolicyDelegateDecisionDelegate webView:didFinishLoadForFrame:]):
(TestWebKitAPI::TEST):
* TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[WKWebView _isBackground]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232082 268f45cc-cd09-0410-ab3c-d52691b4dbfc

48 files changed:
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/WeakObjCPtr.h [moved from Source/WebKit/Shared/mac/WeakObjCPtr.h with 94% similarity]
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKBrowsingContextController.mm
Source/WebKit/UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h
Source/WebKit/UIProcess/API/Cocoa/WKConnection.mm
Source/WebKit/UIProcess/API/Cocoa/WKHTTPCookieStore.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessGroup.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
Source/WebKit/UIProcess/API/Cocoa/WKScriptMessage.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSession.mm
Source/WebKit/UIProcess/API/Cocoa/_WKDownload.mm
Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm
Source/WebKit/UIProcess/ApplicationStateTracker.h
Source/WebKit/UIProcess/Cocoa/AutomationClient.h
Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.h
Source/WebKit/UIProcess/Cocoa/DiagnosticLoggingClient.h
Source/WebKit/UIProcess/Cocoa/DownloadClient.h
Source/WebKit/UIProcess/Cocoa/FindClient.h
Source/WebKit/UIProcess/Cocoa/FullscreenClient.h
Source/WebKit/UIProcess/Cocoa/IconLoadingDelegate.h
Source/WebKit/UIProcess/Cocoa/NavigationState.h
Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm
Source/WebKit/UIProcess/Cocoa/UIDelegate.h
Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm
Source/WebKit/UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm
Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm
Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm
Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/WKLegacyPDFView.mm
Source/WebKit/UIProcess/ios/WKPDFView.mm
Source/WebKit/UIProcess/ios/WKScrollView.mm
Source/WebKit/UIProcess/mac/WKInspectorViewController.mm
Source/WebKit/UIProcess/mac/WKInspectorWKWebView.mm
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit/cocoa/WeakObjCPtr.mm
Tools/TestWebKitAPI/Tests/mac/NoPolicyDelegateResponse.mm [new file with mode: 0644]

index 2c565e4..266efe2 100644 (file)
@@ -1,3 +1,17 @@
+2018-05-22  Chris Dumez  <cdumez@apple.com>
+
+        Regression(AsyncPolicyDelegates): Box.app login Window is blank
+        https://bugs.webkit.org/show_bug.cgi?id=185832
+        <rdar://problem/40307871>
+
+        Reviewed by Geoffrey Garen.
+
+        Moved WeakObjCPtr.h from WebKit2 to WTF with RetainPtr.h, so that it can be used
+        in WebKitLegacy code.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/WeakObjCPtr.h: Renamed from Source/WebKit/Shared/mac/WeakObjCPtr.h.
+
 2018-05-22  Filip Pizlo  <fpizlo@apple.com>
 
         Get rid of TLCs
index 55a4c60..aa77fbf 100644 (file)
                8134013615B092FD001FF0B8 /* Base64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Base64.cpp; sourceTree = "<group>"; };
                8134013715B092FD001FF0B8 /* Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base64.h; sourceTree = "<group>"; };
                83A8AC3D1FABBE94002064AC /* ObjectIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectIdentifier.h; sourceTree = "<group>"; };
+               83ABB3C020B3823200BA3306 /* WeakObjCPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakObjCPtr.h; sourceTree = "<group>"; };
                83F2BADE1CF9524E003E99C3 /* Function.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Function.h; sourceTree = "<group>"; };
                83FBA93119DF459700F30ADB /* TypeCasts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeCasts.h; sourceTree = "<group>"; };
                86F46F5F1A2840EE00CCBF22 /* RefCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefCounter.h; sourceTree = "<group>"; };
                                A8A47372151A825B004123FF /* VMTags.h */,
                                0F66B2881DC97BAB004A1D3F /* WallTime.cpp */,
                                0F66B2891DC97BAB004A1D3F /* WallTime.h */,
+                               83ABB3C020B3823200BA3306 /* WeakObjCPtr.h */,
                                974CFC8D16A4F327006D5404 /* WeakPtr.h */,
                                0F3501631BB258C800F0A2A3 /* WeakRandom.h */,
                                0FE4479A1B7AAA03009498EB /* WordLock.cpp */,
similarity index 94%
rename from Source/WebKit/Shared/mac/WeakObjCPtr.h
rename to Source/WTF/wtf/WeakObjCPtr.h
index 7cf000c..f910830 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WeakObjCPtr_h
-#define WeakObjCPtr_h
+#pragma once
 
 #include <objc/runtime.h>
 #include <type_traits>
@@ -42,7 +41,7 @@ void objc_moveWeak(id*, id*);
 }
 #endif
 
-namespace WebKit {
+namespace WTF {
 
 template<typename T> class WeakObjCPtr {
 public:
@@ -101,6 +100,6 @@ private:
     id m_weakReference;
 };
 
-} // namespace WebKit
+} // namespace WTF
 
-#endif // WeakObjCPtr_h
+using WTF::WeakObjCPtr;
index 26766b3..2f3c4cc 100644 (file)
@@ -1,3 +1,50 @@
+2018-05-22  Chris Dumez  <cdumez@apple.com>
+
+        Regression(AsyncPolicyDelegates): Box.app login Window is blank
+        https://bugs.webkit.org/show_bug.cgi?id=185832
+        <rdar://problem/40307871>
+
+        Reviewed by Geoffrey Garen.
+
+        Moved WeakObjCPtr.h header from WebKit/ to wtf/ so that it can be used in
+        WebKitLegacy code.
+
+        * UIProcess/API/Cocoa/WKBrowsingContextController.mm:
+        * UIProcess/API/Cocoa/WKBrowsingContextControllerInternal.h:
+        * UIProcess/API/Cocoa/WKConnection.mm:
+        * UIProcess/API/Cocoa/WKHTTPCookieStore.mm:
+        * UIProcess/API/Cocoa/WKProcessGroup.mm:
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        * UIProcess/API/Cocoa/WKScriptMessage.mm:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        * UIProcess/API/Cocoa/_WKAutomationSession.mm:
+        * UIProcess/API/Cocoa/_WKDownload.mm:
+        * UIProcess/API/Cocoa/_WKElementAction.mm:
+        * UIProcess/ApplicationStateTracker.h:
+        * UIProcess/Cocoa/AutomationClient.h:
+        * UIProcess/Cocoa/AutomationSessionClient.h:
+        * UIProcess/Cocoa/DiagnosticLoggingClient.h:
+        * UIProcess/Cocoa/DownloadClient.h:
+        * UIProcess/Cocoa/FindClient.h:
+        * UIProcess/Cocoa/FullscreenClient.h:
+        * UIProcess/Cocoa/IconLoadingDelegate.h:
+        * UIProcess/Cocoa/NavigationState.h:
+        * UIProcess/Cocoa/UIDelegate.h:
+        * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
+        * UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm:
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/ios/ViewGestureControllerIOS.mm:
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        * UIProcess/ios/WKPDFView.mm:
+        (-[WKPDFView web_setContentProviderData:suggestedFilename:]):
+        * UIProcess/ios/WKScrollView.mm:
+        * UIProcess/mac/WKInspectorViewController.mm:
+        * UIProcess/mac/WKInspectorWKWebView.mm:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
+
 2018-05-22  Sihui Liu  <sihui_liu@apple.com>
 
         Conversion between SecurityOriginData and DatabaseIdentifier is asymmetric when port is null
index 81e4e52..bb6be7e 100644 (file)
 #import "WKURLRequestNS.h"
 #import "WKURLResponseNS.h"
 #import "WKViewInternal.h"
-#import "WeakObjCPtr.h"
 #import "WebCertificateInfo.h"
 #import "WebPageProxy.h"
 #import "WebProcessPool.h"
 #import "WebProtectionSpace.h"
 #import "_WKRemoteObjectRegistryInternal.h"
 #import <wtf/NeverDestroyed.h>
+#import <wtf/WeakObjCPtr.h>
 
 using namespace WebCore;
 using namespace WebKit;
index 0271f5c..220d0fb 100644 (file)
 
 #if WK_API_ENABLED
 
-#import "WeakObjCPtr.h"
 #import "WebPageProxy.h"
+#import <wtf/WeakObjCPtr.h>
 
 @interface WKBrowsingContextController () {
 @package
-    WebKit::WeakObjCPtr<id <WKBrowsingContextHistoryDelegate>> _historyDelegate;
+    WeakObjCPtr<id <WKBrowsingContextHistoryDelegate>> _historyDelegate;
 }
 
 + (NSMutableSet *)customSchemes;
index 736ce9d..21d316f 100644 (file)
@@ -32,8 +32,8 @@
 #import "WKRetainPtr.h"
 #import "WKSharedAPICast.h"
 #import "WKStringCF.h"
-#import "WeakObjCPtr.h"
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 #import <wtf/text/WTFString.h>
 
 using namespace WebKit;
index d0cd5d8..0a0863a 100644 (file)
 #if WK_API_ENABLED
 
 #import "HTTPCookieAcceptPolicy.h"
-#import "WeakObjCPtr.h"
 #import <WebCore/Cookie.h>
 #import <WebCore/URL.h>
 #import <pal/spi/cf/CFNetworkSPI.h>
 #import <wtf/HashMap.h>
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 
 static NSArray<NSHTTPCookie *> *coreCookiesToNSCookies(const Vector<WebCore::Cookie>& coreCookies)
 {
@@ -59,7 +59,7 @@ private:
         [m_observer.get() cookiesDidChangeInCookieStore:WebKit::wrapper(cookieStore)];
     }
 
-    WebKit::WeakObjCPtr<id<WKHTTPCookieStoreObserver>> m_observer;
+    WeakObjCPtr<id<WKHTTPCookieStoreObserver>> m_observer;
 };
 
 @implementation WKHTTPCookieStore {
index e29fc31..fb5859a 100644 (file)
 #import "WKNavigationDataInternal.h"
 #import "WKRetainPtr.h"
 #import "WKStringCF.h"
-#import "WeakObjCPtr.h"
 #import "WebCertificateInfo.h"
 #import "WebFrameProxy.h"
 #import "WebProcessPool.h"
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 
 #if PLATFORM(IOS)
 #import "WKAPICast.h"
index a27a7b5..807a7c5 100644 (file)
@@ -36,7 +36,6 @@
 #import "SandboxUtilities.h"
 #import "UIGamepadProvider.h"
 #import "WKObject.h"
-#import "WeakObjCPtr.h"
 #import "WebCertificateInfo.h"
 #import "WebCookieManagerProxy.h"
 #import "WebProcessMessages.h"
@@ -50,6 +49,7 @@
 #import <pal/spi/cf/CFNetworkSPI.h>
 #import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 
 #if PLATFORM(IOS)
 #import <WebCore/WebCoreThreadSystemInterface.h>
@@ -59,8 +59,8 @@
 static WKProcessPool *sharedProcessPool;
 
 @implementation WKProcessPool {
-    WebKit::WeakObjCPtr<id <_WKAutomationDelegate>> _automationDelegate;
-    WebKit::WeakObjCPtr<id <_WKDownloadDelegate>> _downloadDelegate;
+    WeakObjCPtr<id <_WKAutomationDelegate>> _automationDelegate;
+    WeakObjCPtr<id <_WKDownloadDelegate>> _downloadDelegate;
 
     RetainPtr<_WKAutomationSession> _automationSession;
 #if PLATFORM(IOS)
index cd5f910..63b0e8e 100644 (file)
 #if WK_API_ENABLED
 
 #import "WKFrameInfo.h"
-#import "WeakObjCPtr.h"
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 
 @implementation WKScriptMessage {
     RetainPtr<id> _body;
-    WebKit::WeakObjCPtr<WKWebView> _webView;
+    WeakObjCPtr<WKWebView> _webView;
     RetainPtr<WKFrameInfo> _frameInfo;
     RetainPtr<NSString> _name;
 }
index 3a4df7d..e988f9a 100644 (file)
@@ -266,7 +266,7 @@ static std::optional<WebCore::ScrollbarOverlayStyle> toCoreScrollbarStyle(_WKOve
 
     _WKRenderingProgressEvents _observedRenderingProgressEvents;
 
-    WebKit::WeakObjCPtr<id <_WKInputDelegate>> _inputDelegate;
+    WeakObjCPtr<id <_WKInputDelegate>> _inputDelegate;
 
 #if PLATFORM(IOS)
     RetainPtr<_WKRemoteObjectRegistry> _remoteObjectRegistry;
index 9406897..14562c4 100644 (file)
@@ -37,7 +37,6 @@
 #import "WKUserContentController.h"
 #import "WKWebView.h"
 #import "WKWebViewContentProviderRegistry.h"
-#import "WeakObjCPtr.h"
 #import "WebKit2Initialize.h"
 #import "_WKVisitedLinkStore.h"
 #import "_WKWebsiteDataStoreInternal.h"
@@ -45,6 +44,7 @@
 #import <WebCore/Settings.h>
 #import <WebCore/URLParser.h>
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 
 #if PLATFORM(IOS)
 #import "UIKitSPI.h"
@@ -109,8 +109,8 @@ static _WKDragLiftDelay toDragLiftDelay(NSUInteger value)
     LazyInitialized<RetainPtr<WKUserContentController>> _userContentController;
     LazyInitialized<RetainPtr<_WKVisitedLinkStore>> _visitedLinkStore;
     LazyInitialized<RetainPtr<WKWebsiteDataStore>> _websiteDataStore;
-    WebKit::WeakObjCPtr<WKWebView> _relatedWebView;
-    WebKit::WeakObjCPtr<WKWebView> _alternateWebViewForNavigationGestures;
+    WeakObjCPtr<WKWebView> _relatedWebView;
+    WeakObjCPtr<WKWebView> _alternateWebViewForNavigationGestures;
     RetainPtr<NSString> _groupIdentifier;
     LazyInitialized<RetainPtr<NSString>> _applicationNameForUserAgent;
     LazyInitialized<RetainPtr<NSMutableDictionary<NSString *, id <WKURLSchemeHandler>>>> _urlSchemeHandlers;
index eab108d..5bc0fea 100644 (file)
 #import "AutomationSessionClient.h"
 #import "WKAPICast.h"
 #import "WKProcessPool.h"
-#import "WeakObjCPtr.h"
 #import "WebAutomationSession.h"
 #import "_WKAutomationSessionConfiguration.h"
 #import "_WKAutomationSessionDelegate.h"
+#import <wtf/WeakObjCPtr.h>
 
 @implementation _WKAutomationSession {
     RetainPtr<_WKAutomationSessionConfiguration> _configuration;
-    WebKit::WeakObjCPtr<id <_WKAutomationSessionDelegate>> _delegate;
+    WeakObjCPtr<id <_WKAutomationSessionDelegate>> _delegate;
 }
 
 - (instancetype)init
index 152e36e..38bb7da 100644 (file)
@@ -30,7 +30,7 @@
 
 #import "DownloadProxy.h"
 #import "WKWebViewInternal.h"
-#import "WeakObjCPtr.h"
+#import <wtf/WeakObjCPtr.h>
 
 @implementation _WKDownload {
     API::ObjectStorage<WebKit::DownloadProxy> _download;
index ad81d66..7fdd6ff 100644 (file)
 #import "GestureTypes.h"
 #import "WKActionSheetAssistant.h"
 #import "WKContentViewInteraction.h"
-#import "WeakObjCPtr.h"
 #import "_WKActivatedElementInfoInternal.h"
 #import <WebCore/LocalizedStrings.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/SoftLinking.h>
+#import <wtf/WeakObjCPtr.h>
 #import <wtf/text/WTFString.h>
 
 #if HAVE(SAFARI_SERVICES_FRAMEWORK)
@@ -52,7 +52,7 @@ typedef void (^WKElementActionHandlerInternal)(WKActionSheetAssistant *, _WKActi
     RetainPtr<NSString> _title;
     WKElementActionHandlerInternal _actionHandler;
     WKElementActionDismissalHandler _dismissalHandler;
-    WebKit::WeakObjCPtr<WKActionSheetAssistant> _defaultActionSheetAssistant;
+    WeakObjCPtr<WKActionSheetAssistant> _defaultActionSheetAssistant;
 }
 
 - (id)_initWithTitle:(NSString *)title actionHandler:(WKElementActionHandlerInternal)handler type:(_WKElementActionType)type assistant:(WKActionSheetAssistant *)assistant
index 696e290..a0e93bd 100644 (file)
@@ -28,8 +28,8 @@
 
 #if PLATFORM(IOS)
 
-#import "WeakObjCPtr.h"
 #import <wtf/Forward.h>
+#import <wtf/WeakObjCPtr.h>
 #import <wtf/WeakPtr.h>
 
 OBJC_CLASS BKSApplicationStateMonitor;
index 0e3e764..4f64b42 100644 (file)
@@ -30,8 +30,8 @@
 #if ENABLE(REMOTE_INSPECTOR)
 
 #import "APIAutomationClient.h"
-#import "WeakObjCPtr.h"
 #import <JavaScriptCore/RemoteInspector.h>
+#import <wtf/WeakObjCPtr.h>
 
 @class WKProcessPool;
 
index b2b9d44..7b0f220 100644 (file)
@@ -31,7 +31,7 @@
 #if WK_API_ENABLED
 
 #import "APIAutomationSessionClient.h"
-#import "WeakObjCPtr.h"
+#import <wtf/WeakObjCPtr.h>
 
 @protocol _WKAutomationSessionDelegate;
 
index 8b0937c..f074b7b 100644 (file)
@@ -31,8 +31,8 @@
 #if WK_API_ENABLED
 
 #import "APIDiagnosticLoggingClient.h"
-#import "WeakObjCPtr.h"
 #import <WebCore/DiagnosticLoggingResultType.h>
+#import <wtf/WeakObjCPtr.h>
 
 @class WKWebView;
 @protocol _WKDiagnosticLoggingDelegate;
index 57179ac..1dfe803 100644 (file)
@@ -31,7 +31,7 @@
 
 #import "APIDownloadClient.h"
 #import "ProcessThrottler.h"
-#import "WeakObjCPtr.h"
+#import <wtf/WeakObjCPtr.h>
 
 @protocol _WKDownloadDelegate;
 
index 6d46936..4fca562 100644 (file)
@@ -31,7 +31,7 @@
 #if WK_API_ENABLED
 
 #import "APIFindClient.h"
-#import "WeakObjCPtr.h"
+#import <wtf/WeakObjCPtr.h>
 
 @class WKWebView;
 @protocol _WKFindDelegate;
index 2ae5294..a525564 100644 (file)
@@ -30,8 +30,8 @@
 #if WK_API_ENABLED
 
 #import "APIFullscreenClient.h"
-#import "WeakObjCPtr.h"
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 
 #if PLATFORM(MAC)
 @class NSView;
index 5a0cc1a..f89fa0c 100644 (file)
@@ -30,8 +30,8 @@
 #if WK_API_ENABLED
 
 #import "APIIconLoadingClient.h"
-#import "WeakObjCPtr.h"
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 
 @class WKWebView;
 @protocol _WKIconLoadingDelegate;
index 4a9c1cd..f8f2855 100644 (file)
@@ -34,9 +34,9 @@
 #import "PageLoadState.h"
 #import "ProcessTerminationReason.h"
 #import "ProcessThrottler.h"
-#import "WeakObjCPtr.h"
 #import <wtf/RetainPtr.h>
 #import <wtf/RunLoop.h>
+#import <wtf/WeakObjCPtr.h>
 
 @class WKWebView;
 @protocol WKHistoryDelegatePrivate;
index 3f4e9d5..6477754 100644 (file)
 #if USE(SYSTEM_PREVIEW)
 
 #import "APIUIClient.h"
-#import "WeakObjCPtr.h"
 #import "WebPageProxy.h"
 #import <MobileCoreServices/MobileCoreServices.h>
 #import <QuickLook/QuickLook.h>
 #import <UIKit/UIViewController.h>
 #import <pal/spi/ios/QuickLookSPI.h>
 #import <wtf/SoftLinking.h>
+#import <wtf/WeakObjCPtr.h>
 
 #if USE(APPLE_INTERNAL_SDK)
 #import <WebKitAdditions/SystemPreviewTypes.cpp>
@@ -87,7 +87,7 @@ SOFT_LINK_CLASS(QuickLook, QLItem);
     _item = adoptNS([allocQLItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0)]);
     [_item setUseLoadingTimeout:NO];
 
-    WebKit::WeakObjCPtr<_WKPreviewControllerDataSource> weakSelf { self };
+    WeakObjCPtr<_WKPreviewControllerDataSource> weakSelf { self };
     [_itemProvider registerItemForTypeIdentifier:contentType loadHandler:[weakSelf = WTFMove(weakSelf)] (NSItemProviderCompletionHandler completionHandler, Class expectedValueClass, NSDictionary * options) {
         if (auto strongSelf = weakSelf.get())
             [strongSelf setCompletionHandler:completionHandler];
index 2ab5623..c9d2133 100644 (file)
@@ -31,8 +31,8 @@
 
 #import "APIContextMenuClient.h"
 #import "APIUIClient.h"
-#import "WeakObjCPtr.h"
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 
 @class _WKActivatedElementInfo;
 @class WKWebView;
index 59886da..ec08b3f 100644 (file)
@@ -33,7 +33,6 @@
 #import "PlaybackSessionManagerProxy.h"
 #import "VideoFullscreenManagerMessages.h"
 #import "VideoFullscreenManagerProxyMessages.h"
-#import "WeakObjCPtr.h"
 #import "WebPageProxy.h"
 #import "WebProcessProxy.h"
 #import <QuartzCore/CoreAnimation.h>
@@ -41,6 +40,7 @@
 #import <WebCore/TimeRanges.h>
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
 #import <wtf/MachSendRight.h>
+#import <wtf/WeakObjCPtr.h>
 
 #if PLATFORM(IOS)
 #import "RemoteLayerTreeDrawingAreaProxy.h"
index 8018156..5f99aec 100644 (file)
 #import "_WKErrorRecoveryAttempting.h"
 #import "_WKFrameHandleInternal.h"
 #import "WKWebViewInternal.h"
-#import "WeakObjCPtr.h"
 #import "WebFrameProxy.h"
 #import "WebPageProxy.h"
 #import "WebProcessProxy.h"
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 
 @interface WKReloadFrameErrorRecoveryAttempter () <_WKErrorRecoveryAttempting>
 @end
 
 @implementation WKReloadFrameErrorRecoveryAttempter {
-    WebKit::WeakObjCPtr<WKWebView> _webView;
+    WeakObjCPtr<WKWebView> _webView;
     RetainPtr<_WKFrameHandle> _frameHandle;
     String _urlString;
 }
index bf1d95f..16f5390 100644 (file)
@@ -30,7 +30,6 @@
 #include "PluginComplexTextInputState.h"
 #include "WKDragDestinationAction.h"
 #include "WKLayoutMode.h"
-#include "WeakObjCPtr.h"
 #include "WebPageProxy.h"
 #include "_WKOverlayScrollbarStyle.h"
 #include <WebCore/TextIndicatorWindow.h>
@@ -38,6 +37,7 @@
 #include <pal/spi/cocoa/AVKitSPI.h>
 #include <wtf/BlockPtr.h>
 #include <wtf/RetainPtr.h>
+#include <wtf/WeakObjCPtr.h>
 #include <wtf/WeakPtr.h>
 #include <wtf/text/WTFString.h>
 
index 7498382..4b97e32 100644 (file)
@@ -35,7 +35,6 @@
 #import "ViewSnapshotStore.h"
 #import "WKBackForwardListItemInternal.h"
 #import "WKWebViewInternal.h"
-#import "WeakObjCPtr.h"
 #import "WebBackForwardList.h"
 #import "WebPageGroup.h"
 #import "WebPageMessages.h"
@@ -44,6 +43,7 @@
 #import <UIKit/UIScreenEdgePanGestureRecognizer.h>
 #import <WebCore/IOSurface.h>
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
+#import <wtf/WeakObjCPtr.h>
 
 using namespace WebCore;
 
@@ -63,7 +63,7 @@ using namespace WebCore;
     WebKit::ViewGestureController *_gestureController;
     RetainPtr<_UINavigationInteractiveTransitionBase> _backTransitionController;
     RetainPtr<_UINavigationInteractiveTransitionBase> _forwardTransitionController;
-    WebKit::WeakObjCPtr<UIView> _gestureRecognizerView;
+    WeakObjCPtr<UIView> _gestureRecognizerView;
 }
 
 static const float swipeSnapshotRemovalRenderTreeSizeTargetFraction = 0.5;
index 81e1412..d4557ec 100644 (file)
@@ -35,7 +35,6 @@
 #import "WKActionSheet.h"
 #import "WKContentViewInteraction.h"
 #import "WKNSURLExtras.h"
-#import "WeakObjCPtr.h"
 #import "WebPageProxy.h"
 #import "_WKActivatedElementInfoInternal.h"
 #import "_WKElementActionInternal.h"
@@ -45,6 +44,7 @@
 #import <WebCore/PathUtilities.h>
 #import <WebCore/WebCoreNSURLExtras.h>
 #import <wtf/SoftLinking.h>
+#import <wtf/WeakObjCPtr.h>
 #import <wtf/text/WTFString.h>
 
 #if HAVE(APP_LINKS)
index e04b258..793a2cd 100644 (file)
 
 #import "ApplicationStateTracker.h"
 #import "WKWebViewInternal.h"
-#import "WeakObjCPtr.h"
 #import "WebPageProxy.h"
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 
 @implementation WKApplicationStateTrackingView {
-    WebKit::WeakObjCPtr<WKWebView> _webView;
+    WeakObjCPtr<WKWebView> _webView;
     std::unique_ptr<WebKit::ApplicationStateTracker> _applicationStateTracker;
 }
 
index 7710f0d..3f60531 100644 (file)
@@ -60,7 +60,6 @@
 #import "WKWebViewConfigurationPrivate.h"
 #import "WKWebViewInternal.h"
 #import "WKWebViewPrivate.h"
-#import "WeakObjCPtr.h"
 #import "WebEvent.h"
 #import "WebIOSEventFactory.h"
 #import "WebPageMessages.h"
@@ -96,6 +95,7 @@
 #import <wtf/RetainPtr.h>
 #import <wtf/SetForScope.h>
 #import <wtf/SoftLinking.h>
+#import <wtf/WeakObjCPtr.h>
 #import <wtf/text/TextStream.h>
 
 #if ENABLE(DRAG_SUPPORT)
index ec19b29..30bf99d 100644 (file)
@@ -37,7 +37,6 @@
 #import "WKPDFPageNumberIndicator.h"
 #import "WKPasswordView.h"
 #import "WKWebViewInternal.h"
-#import "WeakObjCPtr.h"
 #import "WebPageProxy.h"
 #import "_WKFindDelegate.h"
 #import "_WKWebViewPrintFormatterInternal.h"
@@ -48,6 +47,7 @@
 #import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/Vector.h>
+#import <wtf/WeakObjCPtr.h>
 
 // All of UIPDFPage* are deprecated, so just ignore deprecated declarations
 // in this file until we switch off them.
index bc9b203..a90613e 100644 (file)
@@ -32,7 +32,6 @@
 #import "FindClient.h"
 #import "WKActionSheetAssistant.h"
 #import "WKWebViewInternal.h"
-#import "WeakObjCPtr.h"
 #import "WebPageProxy.h"
 #import "_WKWebViewPrintFormatterInternal.h"
 #import <PDFKit/PDFHostViewController.h>
@@ -40,6 +39,7 @@
 #import <wtf/BlockPtr.h>
 #import <wtf/MainThread.h>
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 
 @interface WKPDFView () <PDFHostViewControllerDelegate, WKActionSheetAssistantDelegate>
 @end
@@ -61,7 +61,7 @@
     RetainPtr<NSString> _password;
     WebKit::InteractionInformationAtPosition _positionInformation;
     RetainPtr<NSString> _suggestedFilename;
-    WebKit::WeakObjCPtr<WKWebView> _webView;
+    WeakObjCPtr<WKWebView> _webView;
 }
 
 - (void)dealloc
@@ -96,7 +96,7 @@
     _data = adoptNS([data copy]);
     _suggestedFilename = adoptNS([filename copy]);
 
-    WebKit::WeakObjCPtr<WKPDFView> weakSelf = self;
+    WeakObjCPtr<WKPDFView> weakSelf = self;
     [PDFHostViewController createHostView:[self, weakSelf = WTFMove(weakSelf)](PDFHostViewController * _Nullable hostViewController) {
         ASSERT(isMainThread());
 
index 88203e6..373107b 100644 (file)
@@ -29,8 +29,8 @@
 #if PLATFORM(IOS)
 
 #import "WKWebViewInternal.h"
-#import "WeakObjCPtr.h"
 #import <pal/spi/cg/CoreGraphicsSPI.h>
+#import <wtf/WeakObjCPtr.h>
 
 using namespace WebKit;
 
index 05ffc79..f2ad7f8 100644 (file)
 #import "WKUIDelegatePrivate.h"
 #import "WKWebViewConfigurationPrivate.h"
 #import "WKWebViewPrivate.h"
-#import "WeakObjCPtr.h"
 #import "WebInspectorProxy.h"
 #import "WebInspectorUtilities.h"
 #import "WebPageProxy.h"
+#import <wtf/WeakObjCPtr.h>
 
 using namespace WebKit;
 
@@ -52,7 +52,7 @@ using namespace WebKit;
 @implementation WKInspectorViewController {
     WebPageProxy* _inspectedPage;
     RetainPtr<WKInspectorWKWebView> _webView;
-    WebKit::WeakObjCPtr<id <WKInspectorViewControllerDelegate>> _delegate;
+    WeakObjCPtr<id <WKInspectorViewControllerDelegate>> _delegate;
 }
 
 - (instancetype)initWithInspectedPage:(WebKit::WebPageProxy* _Nullable)inspectedPage
index 3cee2c0..cb7bb91 100644 (file)
 #if PLATFORM(MAC) && WK_API_ENABLED
 
 #import "WKInspectorPrivateMac.h"
-#import "WeakObjCPtr.h"
+#import <wtf/WeakObjCPtr.h>
 
 @implementation WKInspectorWKWebView {
-    WebKit::WeakObjCPtr<id <WKInspectorWKWebViewDelegate>> _inspectorWKWebViewDelegate;
+    WeakObjCPtr<id <WKInspectorWKWebViewDelegate>> _inspectorWKWebViewDelegate;
 }
 
 - (NSInteger)tag
index f175622..a5ecb33 100644 (file)
                1AA654D11B14F71400BF1D3E /* WKWebsiteDataRecordPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA654D01B14F71400BF1D3E /* WKWebsiteDataRecordPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1AA83F6C1A5B63FF00026EC6 /* WebDatabaseProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA83F6A1A5B63FF00026EC6 /* WebDatabaseProvider.cpp */; };
                1AA83F6D1A5B63FF00026EC6 /* WebDatabaseProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA83F6B1A5B63FF00026EC6 /* WebDatabaseProvider.h */; };
-               1AA9BAE1184FFAC7003B6BC6 /* WeakObjCPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA9BAE0184FFAC7003B6BC6 /* WeakObjCPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1AAB0379185A7C6A00EDF501 /* MessageSender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAB0377185A7C6A00EDF501 /* MessageSender.cpp */; };
                1AAB037A185A7C6A00EDF501 /* MessageSender.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAB0378185A7C6A00EDF501 /* MessageSender.h */; };
                1AAB037C185F99D800EDF501 /* APIData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAB037B185F99D800EDF501 /* APIData.cpp */; };
                1AA654D01B14F71400BF1D3E /* WKWebsiteDataRecordPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebsiteDataRecordPrivate.h; sourceTree = "<group>"; };
                1AA83F6A1A5B63FF00026EC6 /* WebDatabaseProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebDatabaseProvider.cpp; sourceTree = "<group>"; };
                1AA83F6B1A5B63FF00026EC6 /* WebDatabaseProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDatabaseProvider.h; sourceTree = "<group>"; };
-               1AA9BAE0184FFAC7003B6BC6 /* WeakObjCPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakObjCPtr.h; sourceTree = "<group>"; };
                1AAB0377185A7C6A00EDF501 /* MessageSender.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MessageSender.cpp; sourceTree = "<group>"; };
                1AAB0378185A7C6A00EDF501 /* MessageSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageSender.h; sourceTree = "<group>"; };
                1AAB037B185F99D800EDF501 /* APIData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIData.cpp; sourceTree = "<group>"; };
                                E18E6948169B77C8009B6670 /* SecItemShim.h */,
                                511F8A77138B460900A95F44 /* SecItemShimLibrary.h */,
                                511F8A78138B460900A95F44 /* SecItemShimLibrary.mm */,
-                               1AA9BAE0184FFAC7003B6BC6 /* WeakObjCPtr.h */,
                                BCE23262122C6CF300D5C35A /* WebCoreArgumentCodersMac.mm */,
                                BC111B5B112F629800337BAB /* WebEventFactory.h */,
                                BC111B5C112F629800337BAB /* WebEventFactory.mm */,
                                1A60224D18C16B9F00C3E8C9 /* VisitedLinkStoreMessages.h in Headers */,
                                1AF4CEF018BC481800BC2D34 /* VisitedLinkTableController.h in Headers */,
                                1A8E7D3D18C15149005A702A /* VisitedLinkTableControllerMessages.h in Headers */,
-                               1AA9BAE1184FFAC7003B6BC6 /* WeakObjCPtr.h in Headers */,
                                CEDA12E3152CD1B300D9E08D /* WebAlternativeTextClient.h in Headers */,
                                9955A6EC1C7980C200EB6A93 /* WebAutomationSession.h in Headers */,
                                99C3AE2D1DADA6AD00AF5C16 /* WebAutomationSessionMacros.h in Headers */,
index 98796e9..866db45 100644 (file)
@@ -53,7 +53,6 @@
 #import "WKWebProcessPlugInPageGroupInternal.h"
 #import "WKWebProcessPlugInRangeHandleInternal.h"
 #import "WKWebProcessPlugInScriptWorldInternal.h"
-#import "WeakObjCPtr.h"
 #import "WebPage.h"
 #import "WebProcess.h"
 #import "_WKRemoteObjectRegistryInternal.h"
@@ -65,6 +64,7 @@
 #import <WebCore/HTMLFormElement.h>
 #import <WebCore/HTMLInputElement.h>
 #import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
+#import <wtf/WeakObjCPtr.h>
 
 using namespace WebCore;
 using namespace WebKit;
index ddba732..8d12e46 100644 (file)
@@ -1,3 +1,32 @@
+2018-05-22  Chris Dumez  <cdumez@apple.com>
+
+        Regression(AsyncPolicyDelegates): Box.app login Window is blank
+        https://bugs.webkit.org/show_bug.cgi?id=185832
+        <rdar://problem/40307871>
+
+        Reviewed by Geoffrey Garen.
+
+        We used to have a bug where where we would fail to wait for the policy decision for
+        the navigation response from the client and the load would keep going, racing with
+        the client's policy decision. If the client did not respond in time, the behavior
+        would be the same as "Use" policy action.
+
+        Box.app fails to make any policy decision in its decidePolicyForMIMEType delegate
+        but the load happened to proceed anyway due to our bug. Now that we've fixed the
+        WebKit bug, however, the load would hang because the completion handler for the
+        decidePolicyForNavigationResponse would never get called.
+
+        To work around the issue, I made the policy listener weak on the WebFrameLoaderClient
+        instead of retaining it. If the policy listener object gets destroyed because getting
+        resolved, we now use "Use" policy action in its dealloc function to maintain previous
+        behavior.
+
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::cancelPolicyCheck):
+        (WebFrameLoaderClient::setUpPolicyListener):
+        (-[WebFramePolicyListener dealloc]):
+
 2018-05-22  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r232052.
index a2c7932..4c9d41f 100644 (file)
@@ -31,6 +31,7 @@
 #import <wtf/Forward.h>
 #import <wtf/HashMap.h>
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 
 @class WebDownload;
 @class WebFrame;
@@ -260,5 +261,5 @@ private:
 
     RetainPtr<WebFrame> m_webFrame;
 
-    RetainPtr<WebFramePolicyListener> m_policyListener;
+    WeakObjCPtr<WebFramePolicyListener> m_policyListener;
 };
index 1a41134..5e465d7 100644 (file)
@@ -914,8 +914,11 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat
 
 void WebFrameLoaderClient::cancelPolicyCheck()
 {
+    if (!m_policyListener)
+        return;
+
     [m_policyListener invalidate];
-    m_policyListener = nullptr;
+    m_policyListener = nil;
 }
 
 void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError& error)
@@ -1524,14 +1527,17 @@ RetainPtr<WebFramePolicyListener> WebFrameLoaderClient::setUpPolicyListener(Fram
     // FIXME: <rdar://5634381> We need to support multiple active policy listeners.
     [m_policyListener invalidate];
 
+    RetainPtr<WebFramePolicyListener> policyListener;
 #if HAVE(APP_LINKS)
     if (appLinkURL)
-        m_policyListener = adoptNS([[WebFramePolicyListener alloc] initWithFrame:core(m_webFrame.get()) policyFunction:WTFMove(function) appLinkURL:appLinkURL]);
+        policyListener = adoptNS([[WebFramePolicyListener alloc] initWithFrame:core(m_webFrame.get()) policyFunction:WTFMove(function) appLinkURL:appLinkURL]);
     else
 #endif
-        m_policyListener = adoptNS([[WebFramePolicyListener alloc] initWithFrame:core(m_webFrame.get()) policyFunction:WTFMove(function)]);
+        policyListener = adoptNS([[WebFramePolicyListener alloc] initWithFrame:core(m_webFrame.get()) policyFunction:WTFMove(function)]);
+
+    m_policyListener = policyListener.get();
 
-    return m_policyListener;
+    return policyListener;
 }
 
 String WebFrameLoaderClient::userAgent(const URL& url)
@@ -2426,6 +2432,14 @@ void WebFrameLoaderClient::finishedLoadingIcon(uint64_t callbackID, SharedBuffer
     if (WebCoreObjCScheduleDeallocateOnMainThread([WebFramePolicyListener class], self))
         return;
 
+    // If the app did not respond before the listener is destroyed, then we let the load
+    // proceed with policy "Use".
+    _frame = nullptr;
+    if (auto policyFunction = std::exchange(_policyFunction, nullptr)) {
+        RELEASE_LOG_ERROR(Loading, "Client application failed to make a policy decision via WebPolicyDecisionListener, letting the load proceed");
+        policyFunction(PolicyAction::Use);
+    }
+
     [super dealloc];
 }
 
index 12cd205..39eb3c0 100644 (file)
@@ -1,3 +1,23 @@
+2018-05-22  Chris Dumez  <cdumez@apple.com>
+
+        Regression(AsyncPolicyDelegates): Box.app login Window is blank
+        https://bugs.webkit.org/show_bug.cgi?id=185832
+        <rdar://problem/40307871>
+
+        Reviewed by Geoffrey Garen.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit/cocoa/WeakObjCPtr.mm:
+        * TestWebKitAPI/Tests/mac/NoPolicyDelegateResponse.mm: Added.
+        (-[NoPolicyDelegateDecisionDelegate webView:decidePolicyForNavigationAction:request:frame:decisionListener:]):
+        (-[NoPolicyDelegateDecisionDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]):
+        (-[NoPolicyDelegateDecisionDelegate webView:didFinishLoadForFrame:]):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/cocoa/TestWKWebView.mm:
+        (-[WKWebView _isBackground]):
+
 2018-05-22  Sihui Liu  <sihui_liu@apple.com>
 
         Conversion between SecurityOriginData and DatabaseIdentifier is asymmetric when port is null
index 766a5d2..d00694c 100644 (file)
                83BAEE8D1EF4625500DDE894 /* PluginLoadClientPolicies.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83BAEE8C1EF4625500DDE894 /* PluginLoadClientPolicies.mm */; };
                83DB79691EF63B3C00BFA5E5 /* Function.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83DB79671EF63B3C00BFA5E5 /* Function.cpp */; };
                83DE134D1EF1C50800C1B355 /* ResponsivenessTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83DE134C1EF1C4FE00C1B355 /* ResponsivenessTimer.cpp */; };
+               83F22C6420B355F80034277E /* NoPolicyDelegateResponse.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83F22C6320B355EB0034277E /* NoPolicyDelegateResponse.mm */; };
                8C10AF98206467920018FD90 /* localstorage-empty-string-value.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 8C10AF97206467830018FD90 /* localstorage-empty-string-value.html */; };
                8C10AF99206467A90018FD90 /* LocalStoragePersistence.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8C10AF96206467770018FD90 /* LocalStoragePersistence.mm */; };
                8E4A85371E1D1AB200F53B0F /* GridPosition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8E4A85361E1D1AA100F53B0F /* GridPosition.cpp */; };
                83BAEE8C1EF4625500DDE894 /* PluginLoadClientPolicies.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginLoadClientPolicies.mm; sourceTree = "<group>"; };
                83DB79671EF63B3C00BFA5E5 /* Function.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Function.cpp; sourceTree = "<group>"; };
                83DE134C1EF1C4FE00C1B355 /* ResponsivenessTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimer.cpp; sourceTree = "<group>"; };
+               83F22C6320B355EB0034277E /* NoPolicyDelegateResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NoPolicyDelegateResponse.mm; sourceTree = "<group>"; };
                86BD19971A2DB05B006DCF0A /* RefCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefCounter.cpp; sourceTree = "<group>"; };
                8A2C750D16CED9550024F352 /* ResizeWindowAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResizeWindowAfterCrash.cpp; sourceTree = "<group>"; };
                8A3AF93A16C9ED2700D248C1 /* ReloadPageAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReloadPageAfterCrash.cpp; sourceTree = "<group>"; };
                                5C0BF88C1DD5957400B00328 /* MemoryPressureHandler.mm */,
                                7A99D9931AD4A29D00373141 /* MenuTypesForMouseEvents.mm */,
                                E19DB9781B32137C00DB38D4 /* NavigatorLanguage.mm */,
+                               83F22C6320B355EB0034277E /* NoPolicyDelegateResponse.mm */,
                                A57A34EF16AF677200C2501F /* PageVisibilityStateWithWindowChanges.mm */,
                                00BC16851680FE810065F1E5 /* PublicSuffix.mm */,
                                37C784DE197C8F2E0010A496 /* RenderedImageFromDOMNode.mm */,
                                7CCE7F041A411AE600447C4C /* NewFirstVisuallyNonEmptyLayoutForImages.cpp in Sources */,
                                7CCE7F051A411AE600447C4C /* NewFirstVisuallyNonEmptyLayoutFrames.cpp in Sources */,
                                0F5651F71FCE4DDC00310FBC /* NoHistoryItemScrollToFragment.mm in Sources */,
+                               83F22C6420B355F80034277E /* NoPolicyDelegateResponse.mm in Sources */,
                                2ECFF5551D9B12F800B55394 /* NowPlayingControlsTests.mm in Sources */,
                                A10F047E1E3AD29C00C95E19 /* NSFileManagerExtras.mm in Sources */,
                                37A22AA71DCAA27200AFBFC4 /* ObservedRenderingProgressEventsAfterCrash.mm in Sources */,
index 4835419..3fc1f7f 100644 (file)
@@ -25,9 +25,7 @@
 
 #import "config.h"
 
-#import <WebKit/WeakObjCPtr.h>
-
-using WebKit::WeakObjCPtr;
+#import <wtf/WeakObjCPtr.h>
 
 TEST(WebKit2_WeakObjCPtr, Construction)
 {
diff --git a/Tools/TestWebKitAPI/Tests/mac/NoPolicyDelegateResponse.mm b/Tools/TestWebKitAPI/Tests/mac/NoPolicyDelegateResponse.mm
new file mode 100644 (file)
index 0000000..cbc3ac6
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "PlatformUtilities.h"
+#import <WebKit/WebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+@interface NoPolicyDelegateDecisionDelegate : NSObject <WebPolicyDelegate, WebFrameLoadDelegate> {
+}
+@end
+
+static bool didFinishLoad;
+static bool didNavigationActionCheck;
+static bool didNavigationResponseCheck;
+
+@implementation NoPolicyDelegateDecisionDelegate
+
+- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener
+{
+    // Implements decidePolicyForNavigationAction but fails to call the decision listener.
+    didNavigationActionCheck = YES;
+}
+
+- (void)webView:(WebView *)webView decidePolicyForMIMEType:(NSString *)type request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener
+{
+    // Implements decidePolicyForMIMEType but fails to call the decision listener.
+    didNavigationResponseCheck = YES;
+}
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+    didFinishLoad = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKitLegacy, NoPolicyDelegateDecision)
+{
+    auto webView = adoptNS([[WebView alloc] initWithFrame:NSZeroRect frameName:nil groupName:nil]);
+    auto delegate = adoptNS([NoPolicyDelegateDecisionDelegate new]);
+
+    webView.get().frameLoadDelegate = delegate.get();
+    webView.get().policyDelegate = delegate.get();
+    [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"verboseMarkup" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+
+    Util::run(&didFinishLoad);
+
+    EXPECT_TRUE(didNavigationActionCheck);
+    EXPECT_TRUE(didNavigationResponseCheck);
+}
+
+} // namespace TestWebKitAPI