[Webkit-unassigned] [Bug 212098] New: Inserting a non-break space before or after a marker removes the marker

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue May 19 11:56:47 PDT 2020


https://bugs.webkit.org/show_bug.cgi?id=212098

            Bug ID: 212098
           Summary: Inserting a non-break space before or after a marker
                    removes the marker
           Product: WebKit
           Version: WebKit Local Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebCore Misc.
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: dbates at webkit.org

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

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200519/392f4718/attachment-0001.htm>


More information about the webkit-unassigned mailing list