<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[244425] branches/safari-607-branch/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/244425">244425</a></dd>
<dt>Author</dt> <dd>ryanhaddad@apple.com</dd>
<dt>Date</dt> <dd>2019-04-18 09:24:25 -0700 (Thu, 18 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/240301">r240301</a>. rdar://problem/49984116

    [iOS] Multiple WKWebViewAutofillTests are flaky failures
    https://bugs.webkit.org/show_bug.cgi?id=189165
    <rdar://problem/47433765>

    Reviewed by Tim Horton.

    These tests are currently flaky because they expect an invocation of "Element.blur()" in the web process to
    immediately dispatch an IPC message to notify the UI process that the element has been blurred. In particular,
    the -textInputHasAutofillContext helper assumes that waiting for the next remote layer tree commit in the UI
    process in sufficient to ensure that any previous action that blurred the focused element in the web process
    would make its way to the UI process by the time the layer tree commit is finished.

    However, WebPage::elementDidBlur sends its IPC message to the UI process asynchronously, using callOnMainThread.
    This means that if a layer tree flush was already scheduled in the web process before the element was blurred,
    the element blur IPC message to the UI process will lose the race against the layer tree commit, and the test
    will fail because it asks for -_autofillContext too early.

    To fix this, we tweak these tests to actually wait until the intended input session change triggered by script
    is handled in the UI process.

    * TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:

    Tweak some of these tests to wait for input session changes before checking for the presence of an autofill
    context. The only exception is an existing test that doesn't allow programmatic focus to begin input sessions
    by default; to fix this test, we simply wait for _WKInputDelegate to be invoked, instead of waiting for a new
    input session.

    (-[AutofillTestView textInputHasAutofillContext]):

    Remove the incorrect presentation update here. This helper now assumes that the UI process is up to date.

    * TestWebKitAPI/cocoa/TestWKWebView.h:
    * TestWebKitAPI/cocoa/TestWKWebView.mm:
    (nextInputSessionChangeCount):

    Monotonically increasing identifier that's incremented whenever an input session is started in the UI process.
    This includes changing the focused element from one to another.

    (-[TestWKWebView initWithFrame:configuration:addToWindow:]):
    (-[TestWKWebView didStartFormControlInteraction]):
    (-[TestWKWebView didEndFormControlInteraction]):
    (-[TestWKWebView evaluateJavaScriptAndWaitForInputSessionToChange:]):

    Add a helper to evaluate JavaScript and wait for this script to cause some change in the input session. This
    handles three cases: (1) changing focus from an element that doesn't require an input session to one that does,
    (2) changing focus between elements that require input sessions, and (3) changing focus from an input session
    that doesn't require an input session to one that doesn't.

    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@240301 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari607branchToolsChangeLog">branches/safari-607-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari607branchToolsTestWebKitAPITestsiosWKWebViewAutofillTestsmm">branches/safari-607-branch/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm</a></li>
<li><a href="#branchessafari607branchToolsTestWebKitAPIcocoaTestWKWebViewh">branches/safari-607-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.h</a></li>
<li><a href="#branchessafari607branchToolsTestWebKitAPIcocoaTestWKWebViewmm">branches/safari-607-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari607branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-607-branch/Tools/ChangeLog (244424 => 244425)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-607-branch/Tools/ChangeLog       2019-04-18 15:51:14 UTC (rev 244424)
+++ branches/safari-607-branch/Tools/ChangeLog  2019-04-18 16:24:25 UTC (rev 244425)
</span><span class="lines">@@ -1,5 +1,110 @@
</span><span class="cx"> 2019-04-17  Ryan Haddad  <ryanhaddad@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r240301. rdar://problem/49984116
+
+    [iOS] Multiple WKWebViewAutofillTests are flaky failures
+    https://bugs.webkit.org/show_bug.cgi?id=189165
+    <rdar://problem/47433765>
+    
+    Reviewed by Tim Horton.
+    
+    These tests are currently flaky because they expect an invocation of "Element.blur()" in the web process to
+    immediately dispatch an IPC message to notify the UI process that the element has been blurred. In particular,
+    the -textInputHasAutofillContext helper assumes that waiting for the next remote layer tree commit in the UI
+    process in sufficient to ensure that any previous action that blurred the focused element in the web process
+    would make its way to the UI process by the time the layer tree commit is finished.
+    
+    However, WebPage::elementDidBlur sends its IPC message to the UI process asynchronously, using callOnMainThread.
+    This means that if a layer tree flush was already scheduled in the web process before the element was blurred,
+    the element blur IPC message to the UI process will lose the race against the layer tree commit, and the test
+    will fail because it asks for -_autofillContext too early.
+    
+    To fix this, we tweak these tests to actually wait until the intended input session change triggered by script
+    is handled in the UI process.
+    
+    * TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:
+    
+    Tweak some of these tests to wait for input session changes before checking for the presence of an autofill
+    context. The only exception is an existing test that doesn't allow programmatic focus to begin input sessions
+    by default; to fix this test, we simply wait for _WKInputDelegate to be invoked, instead of waiting for a new
+    input session.
+    
+    (-[AutofillTestView textInputHasAutofillContext]):
+    
+    Remove the incorrect presentation update here. This helper now assumes that the UI process is up to date.
+    
+    * TestWebKitAPI/cocoa/TestWKWebView.h:
+    * TestWebKitAPI/cocoa/TestWKWebView.mm:
+    (nextInputSessionChangeCount):
+    
+    Monotonically increasing identifier that's incremented whenever an input session is started in the UI process.
+    This includes changing the focused element from one to another.
+    
+    (-[TestWKWebView initWithFrame:configuration:addToWindow:]):
+    (-[TestWKWebView didStartFormControlInteraction]):
+    (-[TestWKWebView didEndFormControlInteraction]):
+    (-[TestWKWebView evaluateJavaScriptAndWaitForInputSessionToChange:]):
+    
+    Add a helper to evaluate JavaScript and wait for this script to cause some change in the input session. This
+    handles three cases: (1) changing focus from an element that doesn't require an input session to one that does,
+    (2) changing focus between elements that require input sessions, and (3) changing focus from an input session
+    that doesn't require an input session to one that doesn't.
+    
+    
+    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@240301 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-01-22  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+            [iOS] Multiple WKWebViewAutofillTests are flaky failures
+            https://bugs.webkit.org/show_bug.cgi?id=189165
+            <rdar://problem/47433765>
+
+            Reviewed by Tim Horton.
+
+            These tests are currently flaky because they expect an invocation of "Element.blur()" in the web process to
+            immediately dispatch an IPC message to notify the UI process that the element has been blurred. In particular,
+            the -textInputHasAutofillContext helper assumes that waiting for the next remote layer tree commit in the UI
+            process in sufficient to ensure that any previous action that blurred the focused element in the web process
+            would make its way to the UI process by the time the layer tree commit is finished.
+
+            However, WebPage::elementDidBlur sends its IPC message to the UI process asynchronously, using callOnMainThread.
+            This means that if a layer tree flush was already scheduled in the web process before the element was blurred,
+            the element blur IPC message to the UI process will lose the race against the layer tree commit, and the test
+            will fail because it asks for -_autofillContext too early.
+
+            To fix this, we tweak these tests to actually wait until the intended input session change triggered by script
+            is handled in the UI process.
+
+            * TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:
+
+            Tweak some of these tests to wait for input session changes before checking for the presence of an autofill
+            context. The only exception is an existing test that doesn't allow programmatic focus to begin input sessions
+            by default; to fix this test, we simply wait for _WKInputDelegate to be invoked, instead of waiting for a new
+            input session.
+
+            (-[AutofillTestView textInputHasAutofillContext]):
+
+            Remove the incorrect presentation update here. This helper now assumes that the UI process is up to date.
+
+            * TestWebKitAPI/cocoa/TestWKWebView.h:
+            * TestWebKitAPI/cocoa/TestWKWebView.mm:
+            (nextInputSessionChangeCount):
+
+            Monotonically increasing identifier that's incremented whenever an input session is started in the UI process.
+            This includes changing the focused element from one to another.
+
+            (-[TestWKWebView initWithFrame:configuration:addToWindow:]):
+            (-[TestWKWebView didStartFormControlInteraction]):
+            (-[TestWKWebView didEndFormControlInteraction]):
+            (-[TestWKWebView evaluateJavaScriptAndWaitForInputSessionToChange:]):
+
+            Add a helper to evaluate JavaScript and wait for this script to cause some change in the input session. This
+            handles three cases: (1) changing focus from an element that doesn't require an input session to one that does,
+            (2) changing focus between elements that require input sessions, and (3) changing focus from an input session
+            that doesn't require an input session to one that doesn't.
+
+2019-04-17  Ryan Haddad  <ryanhaddad@apple.com>
+
</ins><span class="cx">         Cherry-pick r242819. rdar://problem/49979209
</span><span class="cx"> 
</span><span class="cx">     Flaky API Test TestWebKitAPI.WebKitLegacy.ScrollingDoesNotPauseMedia
</span></span></pre></div>
<a id="branchessafari607branchToolsTestWebKitAPITestsiosWKWebViewAutofillTestsmm"></a>
<div class="modfile"><h4>Modified: branches/safari-607-branch/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm (244424 => 244425)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-607-branch/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm       2019-04-18 15:51:14 UTC (rev 244424)
+++ branches/safari-607-branch/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm  2019-04-18 16:24:25 UTC (rev 244425)
</span><span class="lines">@@ -64,7 +64,6 @@
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)textInputHasAutofillContext
</span><span class="cx"> {
</span><del>-    [self waitForNextPresentationUpdate];
</del><span class="cx">     NSURL *url = [self._autofillInputView._autofillContext objectForKey:@"_WebViewURL"];
</span><span class="cx">     if (![url isKindOfClass:[NSURL class]])
</span><span class="cx">         return NO;
</span><span class="lines">@@ -81,10 +80,10 @@
</span><span class="cx"> {
</span><span class="cx">     auto webView = adoptNS([[AutofillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
</span><span class="cx">     [webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input id='password' type='password'>"];
</span><del>-    [webView stringByEvaluatingJavaScript:@"user.focus()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"user.focus()"];
</ins><span class="cx">     EXPECT_TRUE([webView textInputHasAutofillContext]);
</span><span class="cx"> 
</span><del>-    [webView stringByEvaluatingJavaScript:@"password.focus()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
</ins><span class="cx">     EXPECT_TRUE([webView textInputHasAutofillContext]);
</span><span class="cx"> 
</span><span class="cx">     auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
</span><span class="lines">@@ -92,7 +91,7 @@
</span><span class="cx"> 
</span><span class="cx">     EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
</span><span class="cx"> 
</span><del>-    [webView stringByEvaluatingJavaScript:@"document.activeElement.blur()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"];
</ins><span class="cx">     EXPECT_FALSE([webView textInputHasAutofillContext]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -100,10 +99,10 @@
</span><span class="cx"> {
</span><span class="cx">     auto webView = adoptNS([[AutofillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
</span><span class="cx">     [webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input type='radio' name='radio_button' value='radio'><input id='password' type='password'>"];
</span><del>-    [webView stringByEvaluatingJavaScript:@"user.focus()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"user.focus()"];
</ins><span class="cx">     EXPECT_TRUE([webView textInputHasAutofillContext]);
</span><span class="cx"> 
</span><del>-    [webView stringByEvaluatingJavaScript:@"password.focus()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
</ins><span class="cx">     EXPECT_TRUE([webView textInputHasAutofillContext]);
</span><span class="cx"> 
</span><span class="cx">     auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
</span><span class="lines">@@ -112,7 +111,7 @@
</span><span class="cx">     EXPECT_WK_STREQ("frederik", [webView stringByEvaluatingJavaScript:@"user.value"]);
</span><span class="cx">     EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
</span><span class="cx"> 
</span><del>-    [webView stringByEvaluatingJavaScript:@"document.activeElement.blur()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"];
</ins><span class="cx">     EXPECT_FALSE([webView textInputHasAutofillContext]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -120,10 +119,10 @@
</span><span class="cx"> {
</span><span class="cx">     auto webView = adoptNS([[AutofillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
</span><span class="cx">     [webView synchronouslyLoadHTMLString:@"<input id='text1' type='email'><input id='text2' type='text'>"];
</span><del>-    [webView stringByEvaluatingJavaScript:@"text1.focus()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"text1.focus()"];
</ins><span class="cx">     EXPECT_FALSE([webView textInputHasAutofillContext]);
</span><span class="cx"> 
</span><del>-    [webView stringByEvaluatingJavaScript:@"text2.focus()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"text2.focus()"];
</ins><span class="cx">     EXPECT_FALSE([webView textInputHasAutofillContext]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -131,7 +130,7 @@
</span><span class="cx"> {
</span><span class="cx">     auto webView = adoptNS([[AutofillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
</span><span class="cx">     [webView synchronouslyLoadHTMLString:@"<input id='password' type='password'>"];
</span><del>-    [webView stringByEvaluatingJavaScript:@"password.focus()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
</ins><span class="cx">     EXPECT_TRUE([webView textInputHasAutofillContext]);
</span><span class="cx"> 
</span><span class="cx">     auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
</span><span class="lines">@@ -139,7 +138,7 @@
</span><span class="cx"> 
</span><span class="cx">     EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
</span><span class="cx"> 
</span><del>-    [webView stringByEvaluatingJavaScript:@"document.activeElement.blur()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"];
</ins><span class="cx">     EXPECT_FALSE([webView textInputHasAutofillContext]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -147,7 +146,7 @@
</span><span class="cx"> {
</span><span class="cx">     auto webView = adoptNS([[AutofillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
</span><span class="cx">     [webView synchronouslyLoadHTMLString:@"<input id='textfield' type='text'>"];
</span><del>-    [webView stringByEvaluatingJavaScript:@"textfield.focus()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"textfield.focus()"];
</ins><span class="cx">     EXPECT_FALSE([webView textInputHasAutofillContext]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -155,13 +154,13 @@
</span><span class="cx"> {
</span><span class="cx">     auto webView = adoptNS([[AutofillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
</span><span class="cx">     [webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input id='password' type='password'><input id='confirm_password' type='password'>"];
</span><del>-    [webView stringByEvaluatingJavaScript:@"user.focus()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"user.focus()"];
</ins><span class="cx">     EXPECT_FALSE([webView textInputHasAutofillContext]);
</span><span class="cx"> 
</span><del>-    [webView stringByEvaluatingJavaScript:@"password.focus()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
</ins><span class="cx">     EXPECT_FALSE([webView textInputHasAutofillContext]);
</span><span class="cx"> 
</span><del>-    [webView stringByEvaluatingJavaScript:@"confirm_password.focus()"];
</del><ins>+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"confirm_password.focus()"];
</ins><span class="cx">     EXPECT_FALSE([webView textInputHasAutofillContext]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -174,12 +173,15 @@
</span><span class="cx"> {
</span><span class="cx">     ClassMethodSwizzler swizzler([UIKeyboard class], @selector(isInHardwareKeyboardMode), reinterpret_cast<IMP>(overrideIsInHardwareKeyboardMode));
</span><span class="cx"> 
</span><ins>+    bool done = false;
</ins><span class="cx">     auto webView = adoptNS([[AutofillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
</span><del>-    [(TestInputDelegate *)[webView _inputDelegate] setFocusStartsInputSessionPolicyHandler:[] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy {
</del><ins>+    [(TestInputDelegate *)[webView _inputDelegate] setFocusStartsInputSessionPolicyHandler:[&done] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy {
+        done = true;
</ins><span class="cx">         return _WKFocusStartsInputSessionPolicyAuto;
</span><span class="cx">     }];
</span><span class="cx">     [webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input id='password' type='password'>"];
</span><span class="cx">     [webView stringByEvaluatingJavaScript:@"user.focus()"];
</span><ins>+    Util::run(&done);
</ins><span class="cx"> 
</span><span class="cx">     EXPECT_FALSE([webView textInputHasAutofillContext]);
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari607branchToolsTestWebKitAPIcocoaTestWKWebViewh"></a>
<div class="modfile"><h4>Modified: branches/safari-607-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.h (244424 => 244425)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-607-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.h     2019-04-18 15:51:14 UTC (rev 244424)
+++ branches/safari-607-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.h        2019-04-18 16:24:25 UTC (rev 244425)
</span><span class="lines">@@ -87,6 +87,7 @@
</span><span class="cx"> @property (nonatomic, readonly) CGRect caretViewRectInContentCoordinates;
</span><span class="cx"> @property (nonatomic, readonly) NSArray<NSValue *> *selectionViewRectsInContentCoordinates;
</span><span class="cx"> - (_WKActivatedElementInfo *)activatedElementAtPosition:(CGPoint)position;
</span><ins>+- (void)evaluateJavaScriptAndWaitForInputSessionToChange:(NSString *)script;
</ins><span class="cx"> @end
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari607branchToolsTestWebKitAPIcocoaTestWKWebViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-607-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm (244424 => 244425)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-607-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm    2019-04-18 15:51:14 UTC (rev 244424)
+++ branches/safari-607-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm       2019-04-18 16:24:25 UTC (rev 244425)
</span><span class="lines">@@ -249,11 +249,23 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS_FAMILY)
+
+using InputSessionChangeCount = NSUInteger;
+static InputSessionChangeCount nextInputSessionChangeCount()
+{
+    static InputSessionChangeCount gInputSessionChangeCount = 0;
+    return ++gInputSessionChangeCount;
+}
+
+#endif
+
</ins><span class="cx"> @implementation TestWKWebView {
</span><span class="cx">     RetainPtr<TestWKWebViewHostWindow> _hostWindow;
</span><span class="cx">     RetainPtr<TestMessageHandler> _testHandler;
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     std::unique_ptr<ClassMethodSwizzler> _sharedCalloutBarSwizzler;
</span><ins>+    InputSessionChangeCount _inputSessionChangeCount;
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -289,6 +301,7 @@
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     // FIXME: Remove this workaround once <https://webkit.org/b/175204> is fixed.
</span><span class="cx">     _sharedCalloutBarSwizzler = std::make_unique<ClassMethodSwizzler>([UICalloutBar class], @selector(sharedCalloutBar), reinterpret_cast<IMP>(suppressUICalloutBar));
</span><ins>+    _inputSessionChangeCount = 0;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     return self;
</span><span class="lines">@@ -409,6 +422,20 @@
</span><span class="cx">     [self evaluateJavaScript:@"getSelection().collapseToEnd()" completionHandler:nil];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS_FAMILY)
+
+- (void)didStartFormControlInteraction
+{
+    _inputSessionChangeCount = nextInputSessionChangeCount();
+}
+
+- (void)didEndFormControlInteraction
+{
+    _inputSessionChangeCount = 0;
+}
+
+#endif // PLATFORM(IOS_FAMILY)
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="lines">@@ -415,6 +442,26 @@
</span><span class="cx"> 
</span><span class="cx"> @implementation TestWKWebView (IOSOnly)
</span><span class="cx"> 
</span><ins>+- (void)evaluateJavaScriptAndWaitForInputSessionToChange:(NSString *)script
+{
+    auto initialChangeCount = _inputSessionChangeCount;
+    BOOL hasEmittedWarning = NO;
+    NSTimeInterval secondsToWaitUntilWarning = 2;
+    NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate];
+
+    [self objectByEvaluatingJavaScript:script];
+    while ([[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]]) {
+        if (_inputSessionChangeCount != initialChangeCount)
+            break;
+
+        if (hasEmittedWarning || startTime + secondsToWaitUntilWarning >= [NSDate timeIntervalSinceReferenceDate])
+            continue;
+
+        NSLog(@"Warning: expecting input session change count to differ from %tu", initialChangeCount);
+        hasEmittedWarning = YES;
+    }
+}
+
</ins><span class="cx"> - (UIView <UITextInputPrivate, UITextInputMultiDocument> *)textInputContentView
</span><span class="cx"> {
</span><span class="cx">     return (UIView <UITextInputPrivate, UITextInputMultiDocument> *)[self valueForKey:@"_currentContentView"];
</span></span></pre>
</div>
</div>

</body>
</html>