Bug 164077 - iOS autocorrection does not trigger an input event of inputType "insertReplacementText"
Summary: iOS autocorrection does not trigger an input event of inputType "insertReplac...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks: 163112
  Show dependency treegraph
 
Reported: 2016-10-27 14:00 PDT by Wenson Hsieh
Modified: 2016-10-28 22:19 PDT (History)
4 users (show)

See Also:


Attachments
Patch (32.63 KB, patch)
2016-10-28 15:16 PDT, Wenson Hsieh
simon.fraser: review+
Details | Formatted Diff | Diff
[For EWS] Fix DRT and implement feedback (33.90 KB, patch)
2016-10-28 16:41 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
[For EWS] Fix iOS OpenSource build. (34.38 KB, patch)
2016-10-28 17:08 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Patch for landing (34.37 KB, patch)
2016-10-28 17:33 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2016-10-27 14:00:42 PDT
With input events on:
- Start typing something in an editable area (e.g. “tes”). The candidate bar on iOS should show an autocompletion candidate (e.g. “test” or “testing”)
- Select the candidate
- Observe that `beforeinput` and `input` events of type “insertText” were fired, when they should really be of type “insertReplacementText”.
Comment 1 Wenson Hsieh 2016-10-27 14:01:30 PDT
<rdar://problem/28987810>
Comment 2 Wenson Hsieh 2016-10-28 15:16:46 PDT
Created attachment 293229 [details]
Patch
Comment 3 Simon Fraser (smfr) 2016-10-28 15:29:38 PDT
Comment on attachment 293229 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=293229&action=review

> Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:260
> +    ASSERT(index >= 0 && index < 3);

This should not assert if it's possible for the JS to send in arbitrary values, but ideally it would trigger an error if too big.

> Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:283
> +    float offsetX = (index * 2 + 1) * CGRectGetWidth(predictionViewFrame) / 6;
> +    float offsetY = CGRectGetHeight(webView.window.frame) - CGRectGetHeight([UIKeyboardPredictionView activeInstance].superview.frame) + CGRectGetHeight(predictionViewFrame) / 2;
> +    [[HIDEventGenerator sharedHIDEventGenerator] tap:CGPointMake(offsetX, offsetY) completionBlock:^{
> +        if (m_context)
> +            m_context->asyncTaskComplete(callbackID);
> +    }];

Seems fragile in the face of UI changes, but oh well.

> LayoutTests/fast/events/ios/before-input-events-prevent-candidate-insertion.html:16
> +            uiController.singleTapAtPoint(100, 50, function() {});

You should get the coordinates via getBoundingClientRect, like other tests.

> LayoutTests/fast/events/ios/input-events-insert-replacement-text.html:16
> +            uiController.singleTapAtPoint(100, 100, function() {});

Ditto.
Comment 4 Wenson Hsieh 2016-10-28 16:41:06 PDT
Created attachment 293244 [details]
[For EWS] Fix DRT and implement feedback
Comment 5 Wenson Hsieh 2016-10-28 16:43:44 PDT
Comment on attachment 293229 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=293229&action=review

>> Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:260
>> +    ASSERT(index >= 0 && index < 3);
> 
> This should not assert if it's possible for the JS to send in arbitrary values, but ideally it would trigger an error if too big.

Yes, this is reasonable. There are a few other places where we should use exceptions (e.g. typeCharacterUsingHardwareKeyboard with an invalid string, or zoomToScale with a negative scale). I'll file a followup to make these throw exceptions on receiving bad arguments.

>> Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:283
>> +    }];
> 
> Seems fragile in the face of UI changes, but oh well.

I agree :(
Since we want to eventually test using the software keyboard as well, we should reach out to the keyboards team and see if we can get any SPI to make this more robust.

>> LayoutTests/fast/events/ios/before-input-events-prevent-candidate-insertion.html:16
>> +            uiController.singleTapAtPoint(100, 50, function() {});
> 
> You should get the coordinates via getBoundingClientRect, like other tests.

Sounds good! Done.

>> LayoutTests/fast/events/ios/input-events-insert-replacement-text.html:16
>> +            uiController.singleTapAtPoint(100, 100, function() {});
> 
> Ditto.

Done.
Comment 6 Wenson Hsieh 2016-10-28 17:08:12 PDT
Created attachment 293249 [details]
[For EWS] Fix iOS OpenSource build.
Comment 7 Wenson Hsieh 2016-10-28 17:33:24 PDT
Created attachment 293257 [details]
Patch for landing
Comment 8 WebKit Commit Bot 2016-10-28 18:09:06 PDT
Comment on attachment 293257 [details]
Patch for landing

Clearing flags on attachment: 293257

Committed r208090: <http://trac.webkit.org/changeset/208090>
Comment 9 Wenson Hsieh 2016-10-28 22:19:04 PDT
Build fix in r208094