Title: [227647] trunk
Revision
227647
Author
[email protected]
Date
2018-01-25 17:31:10 -0800 (Thu, 25 Jan 2018)

Log Message

REGRESSION (r221899): Web Content process hangs when webpage tries to make a new window if the WKWebView doesn’t have a UI delegate
https://bugs.webkit.org/show_bug.cgi?id=182152

Reviewed by Joseph Pecoraro.

Source/WebKit:

Call the completion handler of the default API::UIClient::createNewPage.

* UIProcess/API/APIUIClient.h:
(API::UIClient::createNewPage):
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient):
* UIProcess/Cocoa/UIDelegate.h:
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::UIClient::createNewPage):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
(-[NoUIDelegate webView:decidePolicyForNavigationAction:decisionHandler:]):
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (227646 => 227647)


--- trunk/Source/WebKit/ChangeLog	2018-01-26 01:18:30 UTC (rev 227646)
+++ trunk/Source/WebKit/ChangeLog	2018-01-26 01:31:10 UTC (rev 227647)
@@ -1,3 +1,20 @@
+2018-01-25  Alex Christensen  <[email protected]>
+
+        REGRESSION (r221899): Web Content process hangs when webpage tries to make a new window if the WKWebView doesn’t have a UI delegate
+        https://bugs.webkit.org/show_bug.cgi?id=182152
+
+        Reviewed by Joseph Pecoraro.
+
+        Call the completion handler of the default API::UIClient::createNewPage.
+
+        * UIProcess/API/APIUIClient.h:
+        (API::UIClient::createNewPage):
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageUIClient):
+        * UIProcess/Cocoa/UIDelegate.h:
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::UIClient::createNewPage):
+
 2018-01-25  Wenson Hsieh  <[email protected]>
 
         [iOS] [WK2] Introduce new views and view controllers to support extra-zoomed text form controls

Modified: trunk/Source/WebKit/UIProcess/API/APIUIClient.h (227646 => 227647)


--- trunk/Source/WebKit/UIProcess/API/APIUIClient.h	2018-01-26 01:18:30 UTC (rev 227646)
+++ trunk/Source/WebKit/UIProcess/API/APIUIClient.h	2018-01-26 01:31:10 UTC (rev 227647)
@@ -30,6 +30,7 @@
 #include "WebHitTestResultData.h"
 #include "WebPageProxy.h"
 #include <WebCore/FloatRect.h>
+#include <wtf/CompletionHandler.h>
 
 #if PLATFORM(IOS)
 OBJC_CLASS NSArray;
@@ -71,7 +72,7 @@
 public:
     virtual ~UIClient() { }
 
-    virtual void createNewPage(WebKit::WebPageProxy&, Ref<FrameInfo>&&, WebCore::ResourceRequest&&, WebCore::WindowFeatures&&, WebKit::NavigationActionData&&, WTF::Function<void(RefPtr<WebKit::WebPageProxy>&&)>&&) { }
+    virtual void createNewPage(WebKit::WebPageProxy&, Ref<FrameInfo>&&, WebCore::ResourceRequest&&, WebCore::WindowFeatures&&, WebKit::NavigationActionData&&, CompletionHandler<void(RefPtr<WebKit::WebPageProxy>&&)>&& completionHandler) { completionHandler(nullptr); }
     virtual void showPage(WebKit::WebPageProxy*) { }
     virtual void fullscreenMayReturnToInline(WebKit::WebPageProxy*) { }
     virtual void didEnterFullscreen(WebKit::WebPageProxy*) { }

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (227646 => 227647)


--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2018-01-26 01:18:30 UTC (rev 227646)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2018-01-26 01:31:10 UTC (rev 227647)
@@ -1566,7 +1566,7 @@
         }
 
     private:
-        void createNewPage(WebPageProxy& page, Ref<API::FrameInfo>&& sourceFrameInfo, WebCore::ResourceRequest&& resourceRequest, WebCore::WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, WTF::Function<void(RefPtr<WebPageProxy>&&)>&& completionHandler) final
+        void createNewPage(WebPageProxy& page, Ref<API::FrameInfo>&& sourceFrameInfo, WebCore::ResourceRequest&& resourceRequest, WebCore::WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) final
         {
             if (m_client.createNewPage) {
                 auto configuration = page.configuration().copy();

Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h (227646 => 227647)


--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h	2018-01-26 01:18:30 UTC (rev 227646)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h	2018-01-26 01:31:10 UTC (rev 227647)
@@ -80,7 +80,7 @@
 
     private:
         // API::UIClient
-        void createNewPage(WebPageProxy&, Ref<API::FrameInfo>&&, WebCore::ResourceRequest&&, WebCore::WindowFeatures&&, NavigationActionData&&, WTF::Function<void(RefPtr<WebPageProxy>&&)>&&) final;
+        void createNewPage(WebPageProxy&, Ref<API::FrameInfo>&&, WebCore::ResourceRequest&&, WebCore::WindowFeatures&&, NavigationActionData&&, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&&) final;
         void close(WebPageProxy*) final;
         void fullscreenMayReturnToInline(WebPageProxy*) final;
         void didEnterFullscreen(WebPageProxy*) final;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm (227646 => 227647)


--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm	2018-01-26 01:18:30 UTC (rev 227646)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm	2018-01-26 01:31:10 UTC (rev 227647)
@@ -201,7 +201,7 @@
 {
 }
 
-void UIDelegate::UIClient::createNewPage(WebPageProxy& page, Ref<API::FrameInfo>&& sourceFrameInfo, WebCore::ResourceRequest&& request, WebCore::WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, WTF::Function<void(RefPtr<WebPageProxy>&&)>&& completionHandler)
+void UIDelegate::UIClient::createNewPage(WebPageProxy& page, Ref<API::FrameInfo>&& sourceFrameInfo, WebCore::ResourceRequest&& request, WebCore::WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler)
 {
     auto delegate = m_uiDelegate.m_delegate.get();
     ASSERT(delegate);
@@ -216,7 +216,7 @@
     auto apiWindowFeatures = API::WindowFeatures::create(windowFeatures);
 
     if (m_uiDelegate.m_delegateMethods.webViewCreateWebViewWithConfigurationForNavigationActionWindowFeaturesAsync) {
-        RefPtr<CompletionHandlerCallChecker> checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:completionHandler:));
+        auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:completionHandler:));
 
         [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView createWebViewWithConfiguration:configuration.get() forNavigationAction:wrapper(apiNavigationAction) windowFeatures:wrapper(apiWindowFeatures) completionHandler:BlockPtr<void (WKWebView *)>::fromCallable([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker), relatedWebView = RetainPtr<WKWebView>(m_uiDelegate.m_webView)](WKWebView *webView) {
             if (checker->completionHandlerHasBeenCalled())

Modified: trunk/Tools/ChangeLog (227646 => 227647)


--- trunk/Tools/ChangeLog	2018-01-26 01:18:30 UTC (rev 227646)
+++ trunk/Tools/ChangeLog	2018-01-26 01:31:10 UTC (rev 227647)
@@ -1,3 +1,14 @@
+2018-01-25  Alex Christensen  <[email protected]>
+
+        REGRESSION (r221899): Web Content process hangs when webpage tries to make a new window if the WKWebView doesn’t have a UI delegate
+        https://bugs.webkit.org/show_bug.cgi?id=182152
+
+        Reviewed by Joseph Pecoraro.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
+        (-[NoUIDelegate webView:decidePolicyForNavigationAction:decisionHandler:]):
+        (TEST):
+
 2018-01-25  Youenn Fablet  <[email protected]>
 
         WebPluginInfoProvider should handle null host queries

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm (227646 => 227647)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm	2018-01-26 01:18:30 UTC (rev 227646)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm	2018-01-26 01:31:10 UTC (rev 227647)
@@ -77,6 +77,30 @@
     TestWebKitAPI::Util::run(&done);
 }
 
+@interface NoUIDelegate : NSObject <WKNavigationDelegate>
+@end
+
+@implementation NoUIDelegate
+
+- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
+{
+    if ([navigationAction.request.URL.absoluteString isEqualToString:[[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"] absoluteString]])
+        done = true;
+    decisionHandler(WKNavigationActionPolicyAllow);
+}
+
+@end
+
+TEST(WebKit, WindowOpenWithoutUIDelegate)
+{
+    done = false;
+    auto webView = adoptNS([[WKWebView alloc] init]);
+    auto delegate = adoptNS([[NoUIDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+    [webView loadHTMLString:@"<script>window.open('simple2.html');window.location='simple.html'</script>" baseURL:[[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    TestWebKitAPI::Util::run(&done);
+}
+
 @interface GeolocationDelegate : NSObject <WKUIDelegatePrivate> {
     bool _allowGeolocation;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to