NEW 212098
Inserting a no-break space before or after a marker removes the marker
https://bugs.webkit.org/show_bug.cgi?id=212098
Summary Inserting a no-break space before or after a marker removes the marker
Daniel Bates
Reported 2020-05-19 11:56:47 PDT
This affects all markers by code inspection, but is user visible with a dictation alternative marker. (Not user visible with spelling and grammar markers because engine re-runs spell check, which masks the bug). Steps to reproduce: 1. Add the following test case: [[ #include "config.h" #if PLATFORM(IOS_FAMILY) #import "PlatformUtilities.h" #import "TestInputDelegate.h" #import "TestWKWebView.h" #import "UIKitSPI.h" #import "WKWebViewConfigurationExtras.h" #import <WebKit/WKWebViewPrivate.h> #import <wtf/unicode/CharacterNames.h> namespace TestWebKitAPI { static inline NSString *makeNSStringWithCharacter(unichar c) { return [NSString stringWithCharacters:&c length:1]; }; TEST(InsertTextAlternatives, InsertLeadingNoBreakSpace) { auto *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES]; auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration]); auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]); [inputDelegate setFocusStartsInputSessionPolicyHandler:[] (WKWebView *, id <_WKFocusedElementInfo>) { return _WKFocusStartsInputSessionPolicyAllow; }]; [webView _setInputDelegate:inputDelegate.get()]; [webView synchronouslyLoadHTMLString:@"<body contenteditable='true'></body>"]; [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.body.focus()"]; [[webView textInputContentView] insertText:@"hello" alternatives:@[@"yellow"] style:UITextAlternativeStyleNone]; [webView waitForNextPresentationUpdate]; [webView _synchronouslyExecuteEditCommand:@"MoveToBeginningOfDocument" argument:nil]; [[webView textInputContentView] insertText:makeNSStringWithCharacter(noBreakSpace)]; [webView _synchronouslyExecuteEditCommand:@"MoveToBeginningOfDocument" argument:nil]; [webView waitForNextPresentationUpdate]; EXPECT_FALSE([[webView objectByEvaluatingJavaScript:@"internals.hasDictationAlternativesMarker(0, 1)"] boolValue]); // <no-break space> EXPECT_TRUE([[webView objectByEvaluatingJavaScript:@"internals.hasDictationAlternativesMarker(1, 5)"] boolValue]); // hello } TEST(InsertTextAlternatives, InsertTrailingNoBreakSpace) { auto *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES]; auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration]); auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]); [inputDelegate setFocusStartsInputSessionPolicyHandler:[] (WKWebView *, id <_WKFocusedElementInfo>) { return _WKFocusStartsInputSessionPolicyAllow; }]; [webView _setInputDelegate:inputDelegate.get()]; [webView synchronouslyLoadHTMLString:@"<body contenteditable='true'></body>"]; [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.body.focus()"]; [[webView textInputContentView] insertText:@"hello" alternatives:@[@"yellow"] style:UITextAlternativeStyleNone]; [[webView textInputContentView] insertText:makeNSStringWithCharacter(noBreakSpace)]; [webView _synchronouslyExecuteEditCommand:@"MoveToBeginningOfDocument" argument:nil]; [webView waitForNextPresentationUpdate]; EXPECT_TRUE([[webView objectByEvaluatingJavaScript:@"internals.hasDictationAlternativesMarker(0, 5)"] boolValue]); // hello EXPECT_FALSE([[webView objectByEvaluatingJavaScript:@"internals.hasDictationAlternativesMarker(5, 1)"] boolValue]); // <no-break space> } } // namespace TestWebKitAPI #endif // PLATFORM(IOS_FAMILY) ]] 2.Run them Then InsertLeadingNoBreakSpace fails because of: EXPECT_TRUE([[webView objectByEvaluatingJavaScript:@"internals.hasDictationAlternativesMarker(1, 5)"] boolValue]); // hello And InsertTrailingNoBreakSpace because of: EXPECT_TRUE([[webView objectByEvaluatingJavaScript:@"internals.hasDictationAlternativesMarker(0, 5)"] boolValue]); // hello
Attachments
Daniel Bates
Comment 1 2020-05-20 08:57:17 PDT
I committed failing version of ^^^ in bug #212097.
Note You need to log in before you can comment on or make changes to this bug.