Commit 348ccc57 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Prevent endless recursion in WebTestWithWebState::LoadHtml.

Instead of recursively reloading html, this function now waits until
the script execution is possible.

Bug: 814709
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I45a6bc7413d2a508aaa4b6af123c243f96b8bc42
Reviewed-on: https://chromium-review.googlesource.com/934628Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539151}
parent fd88bbe4
......@@ -22,6 +22,7 @@
using testing::WaitUntilConditionOrTimeout;
using testing::kWaitForJSCompletionTimeout;
using testing::kWaitForPageLoadTimeout;
namespace {
// Returns CRWWebController for the given |web_state|.
......@@ -125,12 +126,11 @@ void WebTestWithWebState::LoadHtml(NSString* html, const GURL& url) {
return web_controller.loadPhase == PAGE_LOADED;
});
// Reload the page if script execution is not possible. Script execution will
// fail if WKUserScript was not injected by WKWebView (which sometimes happens
// after -[WKWebView loadHTMLString:baseURL:]).
if (![ExecuteJavaScript(@"0;") isEqual:@0]) {
LoadHtml(html, url);
}
// Wait until the script execution is possible. Script execution will fail if
// WKUserScript was not jet injected by WKWebView.
ASSERT_TRUE(WaitUntilConditionOrTimeout(kWaitForPageLoadTimeout, ^bool {
return [ExecuteJavaScript(@"0;") isEqual:@0];
}));
}
void WebTestWithWebState::LoadHtml(NSString* html) {
......
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