Title: [281576] trunk
Revision
281576
Author
[email protected]
Date
2021-08-25 12:59:37 -0700 (Wed, 25 Aug 2021)

Log Message

[iOS 15] editing/input/cocoa/autocorrect-on.html times out when run after editing/input/cocoa/autocorrect-off.html
https://bugs.webkit.org/show_bug.cgi?id=229486
rdar://82191308

Reviewed by Tim Horton.

Source/WebKit:

See changes in Tools for more details.

* Platform/spi/ios/TextInputSPI.h:
* Platform/spi/ios/UIKitSPI.h:

Tools:

The layout test (autocorrect-on.html) fails when run immediately after autocorrect-off.html, in the same
directory. This occurs because autocorrect-on.html attempts to verify that typing a period after "Tset" will
autocorrect to "Test"; however, the previous test disables autocorrection and types "Tset.", which causes UIKit
keyboard autocorrection code to add "Tset" to its lexicon. This means that we end up not autocorrecting to
"Test" in `autocorrect-on.html`.

In the past (r265376), to mitigate this, we set `-[UIKeyboardImpl correctionLearningAllowed]` to `NO`. However,
after what appears to be a recent TextInput change, this fails to prevent the test runner from learning "Tset"
while running autocorrect-off.html.

We take a more heavy-handed approach in this mitigation, and instead use swizzling to prevent UIKeyboardImpl
from notifying kbd when text candidates are "accepted".

* WebKitTestRunner/ios/TestControllerIOS.mm:
(overrideSyncInputManagerToAcceptedAutocorrection):
(WTR::TestController::platformResetStateToConsistentValues):

LayoutTests:

Remove the failing test expectations.

* platform/ios-wk2/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (281575 => 281576)


--- trunk/LayoutTests/ChangeLog	2021-08-25 19:50:35 UTC (rev 281575)
+++ trunk/LayoutTests/ChangeLog	2021-08-25 19:59:37 UTC (rev 281576)
@@ -1,3 +1,15 @@
+2021-08-25  Wenson Hsieh  <[email protected]>
+
+        [iOS 15] editing/input/cocoa/autocorrect-on.html times out when run after editing/input/cocoa/autocorrect-off.html
+        https://bugs.webkit.org/show_bug.cgi?id=229486
+        rdar://82191308
+
+        Reviewed by Tim Horton.
+
+        Remove the failing test expectations.
+
+        * platform/ios-wk2/TestExpectations:
+
 2021-08-25  Arcady Goldmints-Orlov  <[email protected]>
 
         [GLIB] Update baselines after r281419

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (281575 => 281576)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2021-08-25 19:50:35 UTC (rev 281575)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2021-08-25 19:59:37 UTC (rev 281576)
@@ -1006,9 +1006,6 @@
 # Failures as of 06/09/2015
 editing/input/emacs-ctrl-o.html [ Failure ]
 
-# rdar://82191308 ([ Sky ] editing/input/cocoa/autocorrect-on.html is timing out)
-editing/input/cocoa/autocorrect-on.html [ Timeout ]
-
 # Time outs as of 06/09/2015
 fast/images/animated-gif-webkit-transform.html
 

Modified: trunk/Source/WebKit/ChangeLog (281575 => 281576)


--- trunk/Source/WebKit/ChangeLog	2021-08-25 19:50:35 UTC (rev 281575)
+++ trunk/Source/WebKit/ChangeLog	2021-08-25 19:59:37 UTC (rev 281576)
@@ -1,3 +1,16 @@
+2021-08-25  Wenson Hsieh  <[email protected]>
+
+        [iOS 15] editing/input/cocoa/autocorrect-on.html times out when run after editing/input/cocoa/autocorrect-off.html
+        https://bugs.webkit.org/show_bug.cgi?id=229486
+        rdar://82191308
+
+        Reviewed by Tim Horton.
+
+        See changes in Tools for more details.
+
+        * Platform/spi/ios/TextInputSPI.h:
+        * Platform/spi/ios/UIKitSPI.h:
+
 2021-08-25  Peng Liu  <[email protected]>
 
         [Monterey] LayoutTest media/element-containing-pip-video-going-into-fullscreen.html is flaky timeout/crash

Modified: trunk/Source/WebKit/Platform/spi/ios/TextInputSPI.h (281575 => 281576)


--- trunk/Source/WebKit/Platform/spi/ios/TextInputSPI.h	2021-08-25 19:50:35 UTC (rev 281575)
+++ trunk/Source/WebKit/Platform/spi/ios/TextInputSPI.h	2021-08-25 19:59:37 UTC (rev 281576)
@@ -27,11 +27,19 @@
 
 #if USE(APPLE_INTERNAL_SDK)
 
+#import <TextInput/TIKeyboardCandidate.h>
+#import <TextInput/TIKeyboardInput.h>
 #import <TextInput/TIPreferencesController.h>
 #import <TextInput/TI_NSStringExtras.h>
 
 #else
 
+@interface TIKeyboardCandidate : NSObject <NSCopying, NSSecureCoding>
+@end
+
+@interface TIKeyboardInput : NSObject <NSSecureCoding>
+@end
+
 @protocol TIPreferencesControllerActions <NSObject>
 - (BOOL)oneTimeActionCompleted:(NSString *)actionKey;
 - (void)didTriggerOneTimeAction:(NSString *)actionKey;

Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (281575 => 281576)


--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2021-08-25 19:50:35 UTC (rev 281575)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2021-08-25 19:59:37 UTC (rev 281576)
@@ -1407,6 +1407,9 @@
 - (CGFloat)getVerticalOverlapForView:(UIView *)view usingKeyboardInfo:(NSDictionary *)info;
 @end
 
+@class TIKeyboardCandidate;
+@class TIKeyboardInput;
+
 @interface UIKeyboardImpl (IPI)
 - (void)setInitialDirection;
 - (void)prepareKeyboardInputModeFromPreferences:(UIKeyboardInputMode *)lastUsedMode;
@@ -1415,6 +1418,7 @@
 - (BOOL)handleKeyInputMethodCommandForCurrentEvent;
 - (BOOL)isCallingInputDelegate;
 - (BOOL)delegateSupportsImagePaste;
+- (void)syncInputManagerToAcceptedAutocorrection:(TIKeyboardCandidate *)autocorrection forInput:(TIKeyboardInput *)inputEvent;
 @property (nonatomic, readonly) UIKeyboardInputMode *currentInputModeInPreference;
 @end
 

Modified: trunk/Tools/ChangeLog (281575 => 281576)


--- trunk/Tools/ChangeLog	2021-08-25 19:50:35 UTC (rev 281575)
+++ trunk/Tools/ChangeLog	2021-08-25 19:59:37 UTC (rev 281576)
@@ -1,3 +1,28 @@
+2021-08-25  Wenson Hsieh  <[email protected]>
+
+        [iOS 15] editing/input/cocoa/autocorrect-on.html times out when run after editing/input/cocoa/autocorrect-off.html
+        https://bugs.webkit.org/show_bug.cgi?id=229486
+        rdar://82191308
+
+        Reviewed by Tim Horton.
+
+        The layout test (autocorrect-on.html) fails when run immediately after autocorrect-off.html, in the same
+        directory. This occurs because autocorrect-on.html attempts to verify that typing a period after "Tset" will
+        autocorrect to "Test"; however, the previous test disables autocorrection and types "Tset.", which causes UIKit
+        keyboard autocorrection code to add "Tset" to its lexicon. This means that we end up not autocorrecting to
+        "Test" in `autocorrect-on.html`.
+
+        In the past (r265376), to mitigate this, we set `-[UIKeyboardImpl correctionLearningAllowed]` to `NO`. However,
+        after what appears to be a recent TextInput change, this fails to prevent the test runner from learning "Tset"
+        while running autocorrect-off.html.
+
+        We take a more heavy-handed approach in this mitigation, and instead use swizzling to prevent UIKeyboardImpl
+        from notifying kbd when text candidates are "accepted".
+
+        * WebKitTestRunner/ios/TestControllerIOS.mm:
+        (overrideSyncInputManagerToAcceptedAutocorrection):
+        (WTR::TestController::platformResetStateToConsistentValues):
+
 2021-08-24  Alan Bujtas  <[email protected]>
 
         [ iOS ] TestWebKitAPI.DocumentEditingContext.Request* tests are failing

Modified: trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm (281575 => 281576)


--- trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2021-08-25 19:50:35 UTC (rev 281575)
+++ trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2021-08-25 19:59:37 UTC (rev 281576)
@@ -48,6 +48,11 @@
 #import <pal/spi/ios/GraphicsServicesSPI.h>
 #import <wtf/MainThread.h>
 
+static void overrideSyncInputManagerToAcceptedAutocorrection(id, SEL, TIKeyboardCandidate *candidate, TIKeyboardInput *input)
+{
+    // Intentionally unimplemented. See usage below for more information.
+}
+
 static BOOL overrideIsInHardwareKeyboardMode()
 {
     return NO;
@@ -182,6 +187,10 @@
 
     GSEventSetHardwareKeyboardAttached(true, 0);
 
+    // Ignore calls to inform the keyboard daemon that we accepted autocorrection candidates.
+    // This prevents the device from learning misspelled words in between layout tests.
+    method_setImplementation(class_getInstanceMethod(UIKeyboardImpl.class, @selector(syncInputManagerToAcceptedAutocorrection:forInput:)), reinterpret_cast<IMP>(overrideSyncInputManagerToAcceptedAutocorrection));
+
     // Override the implementation of +[UIKeyboard isInHardwareKeyboardMode] to ensure that test runs are deterministic
     // regardless of whether a hardware keyboard is attached. We intentionally never restore the original implementation.
     //
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to