Title: [231115] trunk
- Revision
- 231115
- Author
- [email protected]
- Date
- 2018-04-27 15:30:43 -0700 (Fri, 27 Apr 2018)
Log Message
PSON: Triggering a navigation to an invalid URL creates a new WebContent process
https://bugs.webkit.org/show_bug.cgi?id=185066
Reviewed by Youenn Fablet.
Source/WebKit:
Don't create a new WebContent process when the target URL is invalid as well as when the source URL is invalid.
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForNavigationInternal):
Tools:
Added a new test case (ProcessSwap.NavigateToInvalidURL) for navigating to an invalid URL.
WebKit should not swap WebContent process in this case.
* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
(-[PSONNavigationDelegate webView:didFailProvisionalNavigation:withError:]):
(-[PSONUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (231114 => 231115)
--- trunk/Source/WebKit/ChangeLog 2018-04-27 22:11:00 UTC (rev 231114)
+++ trunk/Source/WebKit/ChangeLog 2018-04-27 22:30:43 UTC (rev 231115)
@@ -1,3 +1,15 @@
+2018-04-26 Ryosuke Niwa <[email protected]>
+
+ PSON: Triggering a navigation to an invalid URL creates a new WebContent process
+ https://bugs.webkit.org/show_bug.cgi?id=185066
+
+ Reviewed by Youenn Fablet.
+
+ Don't create a new WebContent process when the target URL is invalid as well as when the source URL is invalid.
+
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::processForNavigationInternal):
+
2018-04-27 Youenn Fablet <[email protected]>
Use NetworkLoadChecker for XHR/fetch loads
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (231114 => 231115)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-04-27 22:11:00 UTC (rev 231114)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-04-27 22:30:43 UTC (rev 231115)
@@ -2096,7 +2096,7 @@
auto targetURL = navigation.currentRequest().url();
auto url = "" { ParsedURLString, page.pageLoadState().url() };
- if (!url.isValid() || url.isEmpty() || url.isBlankURL() ||protocolHostAndPortAreEqual(url, targetURL))
+ if (!url.isValid() || !targetURL.isValid() || url.isEmpty() || url.isBlankURL() || protocolHostAndPortAreEqual(url, targetURL))
return page.process();
if (m_configuration->alwaysKeepAndReuseSwappedProcesses()) {
Modified: trunk/Tools/ChangeLog (231114 => 231115)
--- trunk/Tools/ChangeLog 2018-04-27 22:11:00 UTC (rev 231114)
+++ trunk/Tools/ChangeLog 2018-04-27 22:30:43 UTC (rev 231115)
@@ -1,3 +1,17 @@
+2018-04-26 Ryosuke Niwa <[email protected]>
+
+ PSON: Triggering a navigation to an invalid URL creates a new WebContent process
+ https://bugs.webkit.org/show_bug.cgi?id=185066
+
+ Reviewed by Youenn Fablet.
+
+ Added a new test case (ProcessSwap.NavigateToInvalidURL) for navigating to an invalid URL.
+ WebKit should not swap WebContent process in this case.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+ (-[PSONNavigationDelegate webView:didFailProvisionalNavigation:withError:]):
+ (-[PSONUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
+
2018-04-27 Nan Wang <[email protected]>
AX: Accessibility needs to know which part of the content view is visible on iOS
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (231114 => 231115)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2018-04-27 22:11:00 UTC (rev 231114)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2018-04-27 22:30:43 UTC (rev 231115)
@@ -54,10 +54,12 @@
#if WK_API_ENABLED
static bool done;
+static bool failed;
static bool didCreateWebView;
static int numberOfDecidePolicyCalls;
static RetainPtr<NSMutableArray> receivedMessages = adoptNS([@[] mutableCopy]);
+bool didReceiveAlert;
static bool receivedMessage;
static bool serverRedirected;
static HashSet<pid_t> seenPIDs;
@@ -83,6 +85,12 @@
@implementation PSONNavigationDelegate
+- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
+{
+ seenPIDs.add([webView _webProcessIdentifier]);
+ failed = true;
+}
+
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
seenPIDs.add([webView _webProcessIdentifier]);
@@ -131,6 +139,12 @@
return createdWebView.get();
}
+- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)())completionHandler
+{
+ didReceiveAlert = true;
+ completionHandler();
+}
+
@end
@interface PSONScheme : NSObject <WKURLSchemeHandler> {
@@ -1275,4 +1289,43 @@
EXPECT_EQ(pid1, pid3);
}
+static const char* navigateToInvalidURLTestBytes = R"PSONRESOURCE(
+<!DOCTYPE html>
+<html>
+<body _onload_="setTimeout(() => alert('DONE'), 0); location.href = ''">
+)PSONRESOURCE";
+
+TEST(ProcessSwap, NavigateToInvalidURL)
+{
+ auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+ processPoolConfiguration.get().processSwapsOnNavigation = YES;
+ auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+ auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [webViewConfiguration setProcessPool:processPool.get()];
+ RetainPtr<PSONScheme> handler = adoptNS([[PSONScheme alloc] initWithBytes:navigateToInvalidURLTestBytes]);
+ [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
+
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+ auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+ [webView setNavigationDelegate:navigationDelegate.get()];
+ auto uiDelegate = adoptNS([[PSONUIDelegate alloc] initWithNavigationDelegate:navigationDelegate.get()]);
+ [webView setUIDelegate:uiDelegate.get()];
+
+ numberOfDecidePolicyCalls = 0;
+ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://host/main1.html"]]];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+ auto pid1 = [webView _webProcessIdentifier];
+ EXPECT_TRUE(!!pid1);
+
+ TestWebKitAPI::Util::run(&didReceiveAlert);
+ didReceiveAlert = false;
+ auto pid2 = [webView _webProcessIdentifier];
+ EXPECT_TRUE(!!pid2);
+
+ EXPECT_EQ(2, numberOfDecidePolicyCalls);
+ EXPECT_EQ(pid1, pid2);
+}
+
#endif // WK_API_ENABLED
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes