Title: [238216] trunk/Tools
Revision
238216
Author
cdu...@apple.com
Date
2018-11-14 19:32:32 -0800 (Wed, 14 Nov 2018)

Log Message

REGRESSION (r238115): [iOS] TestWebKitAPI.ProcessSwap.NavigateToInvalidURL is failing
https://bugs.webkit.org/show_bug.cgi?id=191660

Reviewed by Ryosuke Niwa.

The test tries to navigate to an invalid URL and makes sure that we do not process swap
for such load. The test was inherently racing because it was doing:
<body _onload_="setTimeout(() => alert('DONE'), 0); location.href = ''">

Its load event handler tries to navigate to 'http://A=a%B=b' and sets a 0 timer to
log an alert, which causes the API test to keep going and check that we did not swap
process. The issue is that a 0 timer may not be sufficient to trigger the load, as
the policy decision is asynchronous and relies on the UIProcess responding to it.

To address the issue, the test now waits for the next policy decision, spins the
run loop and then makes sure we did not swap process. It no longer relies on a message
from the page.

* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
(-[PSONNavigationDelegate webView:decidePolicyForNavigationAction:decisionHandler:]):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (238215 => 238216)


--- trunk/Tools/ChangeLog	2018-11-15 03:30:58 UTC (rev 238215)
+++ trunk/Tools/ChangeLog	2018-11-15 03:32:32 UTC (rev 238216)
@@ -1,5 +1,28 @@
 2018-11-14  Chris Dumez  <cdu...@apple.com>
 
+        REGRESSION (r238115): [iOS] TestWebKitAPI.ProcessSwap.NavigateToInvalidURL is failing
+        https://bugs.webkit.org/show_bug.cgi?id=191660
+
+        Reviewed by Ryosuke Niwa.
+
+        The test tries to navigate to an invalid URL and makes sure that we do not process swap
+        for such load. The test was inherently racing because it was doing:
+        <body _onload_="setTimeout(() => alert('DONE'), 0); location.href = ''">
+
+        Its load event handler tries to navigate to 'http://A=a%B=b' and sets a 0 timer to
+        log an alert, which causes the API test to keep going and check that we did not swap
+        process. The issue is that a 0 timer may not be sufficient to trigger the load, as
+        the policy decision is asynchronous and relies on the UIProcess responding to it.
+
+        To address the issue, the test now waits for the next policy decision, spins the
+        run loop and then makes sure we did not swap process. It no longer relies on a message
+        from the page.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+        (-[PSONNavigationDelegate webView:decidePolicyForNavigationAction:decisionHandler:]):
+
+2018-11-14  Chris Dumez  <cdu...@apple.com>
+
         WebKit.WebsiteDataStoreCustomPaths API test is failing when enabling process prewarming
         https://bugs.webkit.org/show_bug.cgi?id=191638
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (238215 => 238216)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2018-11-15 03:30:58 UTC (rev 238215)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2018-11-15 03:32:32 UTC (rev 238216)
@@ -62,6 +62,7 @@
 static bool failed;
 static bool didCreateWebView;
 static int numberOfDecidePolicyCalls;
+static bool didRepondToPolicyDecisionCall;
 
 static RetainPtr<NSMutableArray> receivedMessages = adoptNS([@[] mutableCopy]);
 bool didReceiveAlert;
@@ -123,6 +124,7 @@
         decidePolicyForNavigationAction(navigationAction, decisionHandler);
     else
         decisionHandler(WKNavigationActionPolicyAllow);
+    didRepondToPolicyDecisionCall = true;
 }
 
 - (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation
@@ -2344,12 +2346,6 @@
     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]);
@@ -2358,7 +2354,7 @@
 
     auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     [webViewConfiguration setProcessPool:processPool.get()];
-    auto handler = adoptNS([[PSONScheme alloc] initWithBytes:navigateToInvalidURLTestBytes]);
+    auto handler = adoptNS([[PSONScheme alloc] init]);
     [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
 
     auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
@@ -2374,8 +2370,15 @@
     auto pid1 = [webView _webProcessIdentifier];
     EXPECT_TRUE(!!pid1);
 
-    TestWebKitAPI::Util::run(&didReceiveAlert);
-    didReceiveAlert = false;
+    EXPECT_EQ(1, numberOfDecidePolicyCalls);
+
+    [webView evaluateJavaScript:@"location.href = ''" completionHandler:nil];
+
+    didRepondToPolicyDecisionCall = false;
+    TestWebKitAPI::Util::run(&didRepondToPolicyDecisionCall);
+
+    TestWebKitAPI::Util::spinRunLoop(1);
+
     auto pid2 = [webView _webProcessIdentifier];
     EXPECT_TRUE(!!pid2);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to