Commit 43463aca authored by Mike Dougherty's avatar Mike Dougherty Committed by Commit Bot

[iOS][Test] Attach WKWebView to windowed container

This test is flaky on the bots when run as part of the suite. Although
unable to reproduce locally, the calls to ExecuteJavaScript were failing
which points to a general test problem.

Without being attached to a windowed view, WKWebView can internally
suspend processes. Add the |web_view| to a windowed container to try to
prevent flake.

Additionally, extend the timeout for JavaScript execution because the
old timeout was too short for JavaScript execution to always complete.

Bug: 1013206
Change-Id: I1bd685563bc0e522647ab0402e64428fa746e430
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1856659Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Auto-Submit: Mike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706639}
parent e69d90bc
...@@ -17,7 +17,7 @@ namespace test { ...@@ -17,7 +17,7 @@ namespace test {
namespace ios { namespace ios {
const NSTimeInterval kSpinDelaySeconds = 0.01; const NSTimeInterval kSpinDelaySeconds = 0.01;
const NSTimeInterval kWaitForJSCompletionTimeout = 4.0; const NSTimeInterval kWaitForJSCompletionTimeout = 6.0;
const NSTimeInterval kWaitForUIElementTimeout = 4.0; const NSTimeInterval kWaitForUIElementTimeout = 4.0;
const NSTimeInterval kWaitForDownloadTimeout = 10.0; const NSTimeInterval kWaitForDownloadTimeout = 10.0;
const NSTimeInterval kWaitForPageLoadTimeout = 10.0; const NSTimeInterval kWaitForPageLoadTimeout = 10.0;
......
...@@ -31,6 +31,9 @@ class WebViewWebClientTest : public web::WebTest { ...@@ -31,6 +31,9 @@ class WebViewWebClientTest : public web::WebTest {
TEST_F(WebViewWebClientTest, WKWebViewEarlyPageScriptAutofillController) { TEST_F(WebViewWebClientTest, WKWebViewEarlyPageScriptAutofillController) {
// WebView scripts rely on __gCrWeb object presence. // WebView scripts rely on __gCrWeb object presence.
WKWebView* web_view = web::BuildWKWebView(CGRectZero, GetBrowserState()); WKWebView* web_view = web::BuildWKWebView(CGRectZero, GetBrowserState());
// Add |web_view| to the windowed container to keep the WKWebView processes
// from being suspended.
[GetWebClient()->GetWindowedContainer() addSubview:web_view];
web::test::ExecuteJavaScript(web_view, @"__gCrWeb = {};"); web::test::ExecuteJavaScript(web_view, @"__gCrWeb = {};");
web::ScopedTestingWebClient web_client(std::make_unique<WebViewWebClient>()); web::ScopedTestingWebClient web_client(std::make_unique<WebViewWebClient>());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment