Changeset 273115 in webkit


Ignore:
Timestamp:
Feb 18, 2021 4:58:54 PM (3 years ago)
Author:
commit-queue@webkit.org
Message:

Unconditionally return information in _autofillContext SPI when a field is focused
https://bugs.webkit.org/show_bug.cgi?id=221828
rdar://74211237

Patch by Ricky Mondello <Ricky Mondello> on 2021-02-18
Reviewed by Darin Adler.

Source/WebKit:

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _autofillContext]): Change the contract of _autofillContext to return information for any focused

text field. Add a "version" key. Explicitly indicate whether we're in a login context. This SPI remains stringly
typed for flexibility.

Tools:

Tests updated by Wenson Hsieh.

Rebaseline tests.

  • TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:

(TestWebKitAPI::TEST):

  • TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:

(-[AutoFillTestView acceptsAutoFillLoginCredentials]): Renamed in line with the Password AutoFill-related

contract these tests are about.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r273114 r273115  
     12021-02-18  Ricky Mondello  <rmondello@apple.com>
     2
     3        Unconditionally return information in _autofillContext SPI when a field is focused
     4        https://bugs.webkit.org/show_bug.cgi?id=221828
     5        rdar://74211237
     6
     7        Reviewed by Darin Adler.
     8
     9        * UIProcess/ios/WKContentViewInteraction.mm:
     10        (-[WKContentView _autofillContext]): Change the contract of _autofillContext to return information for any focused
     11            text field. Add a "version" key. Explicitly indicate whether we're in a login context. This SPI remains stringly
     12            typed for flexibility.
     13
    1142021-02-18  Brent Fulgham  <bfulgham@apple.com>
    215
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r273077 r273115  
    80818081- (NSDictionary *)_autofillContext
    80828082{
    8083     BOOL provideStrongPasswordAssistance = _focusRequiresStrongPasswordAssistance && _focusedElementInformation.elementType == WebKit::InputType::Password;
    8084     if (!self._hasFocusedElement || (!_focusedElementInformation.acceptsAutofilledLoginCredentials && !provideStrongPasswordAssistance))
     8083    if (!self._hasFocusedElement)
    80858084        return nil;
    80868085
    8087     if (provideStrongPasswordAssistance)
    8088         return @{ @"_automaticPasswordKeyboard" : @YES, @"strongPasswordAdditionalContext" : _additionalContextForStrongPasswordAssistance.get() };
     8086    auto context = adoptNS([[NSMutableDictionary alloc] init]);
     8087    context.get()[@"_WKAutofillContextVersion"] = @(2);
     8088
     8089    if (_focusRequiresStrongPasswordAssistance && _focusedElementInformation.elementType == WebKit::InputType::Password) {
     8090        context.get()[@"_automaticPasswordKeyboard"] = @YES;
     8091        context.get()[@"strongPasswordAdditionalContext"] = _additionalContextForStrongPasswordAssistance.get();
     8092    } else if (_focusedElementInformation.acceptsAutofilledLoginCredentials)
     8093        context.get()[@"_acceptsLoginCredentials"] = @YES;
    80898094
    80908095    NSURL *platformURL = _focusedElementInformation.representingPageURL;
    80918096    if (platformURL)
    8092         return @{ @"_WebViewURL" : platformURL };
    8093 
    8094     return nil;
     8097        context.get()[@"_WebViewURL"] = platformURL;
     8098
     8099    return context.autorelease();
    80958100}
    80968101
  • trunk/Tools/ChangeLog

    r273111 r273115  
     12021-02-18  Ricky Mondello  <rmondello@apple.com>
     2
     3        Unconditionally return information in _autofillContext SPI when a field is focused
     4        https://bugs.webkit.org/show_bug.cgi?id=221828
     5        rdar://74211237
     6
     7        Reviewed by Darin Adler.
     8
     9        Tests updated by Wenson Hsieh.
     10
     11        Rebaseline tests.
     12
     13        * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
     14        (TestWebKitAPI::TEST):
     15        * TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:
     16        (-[AutoFillTestView acceptsAutoFillLoginCredentials]): Renamed in line with the Password AutoFill-related
     17            contract these tests are about.
     18
    1192021-02-18  Alex Christensen  <achristensen@webkit.org>
    220
  • trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm

    r265238 r273115  
    690690    NSDictionary *actual = [[webView textInputContentView] _autofillContext];
    691691    EXPECT_TRUE([[actual allValues] containsObject:expected]);
     692    EXPECT_TRUE([actual[@"_automaticPasswordKeyboard"] boolValue]);
    692693}
    693694
  • trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm

    r272448 r273115  
    6767}
    6868
    69 - (BOOL)textInputHasAutoFillContext
    70 {
    71     NSURL *url = [self._autofillInputView._autofillContext objectForKey:@"_WebViewURL"];
    72     if (![url isKindOfClass:[NSURL class]])
     69- (BOOL)acceptsAutoFillLoginCredentials
     70{
     71    auto context = self._autofillInputView._autofillContext;
     72    if (!context)
    7373        return NO;
    7474
     75    NSURL *url = context[@"_WebViewURL"];
     76    EXPECT_TRUE([url isKindOfClass:NSURL.class]);
    7577    EXPECT_WK_STREQ([self stringByEvaluatingJavaScript:@"document.URL"], url.absoluteString);
    76     return YES;
     78    return [context[@"_acceptsLoginCredentials"] boolValue];
    7779}
    7880
     
    8688    [webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input id='password' type='password'>"];
    8789    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"user.focus()"];
    88     EXPECT_TRUE([webView textInputHasAutoFillContext]);
    89 
    90     [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
    91     EXPECT_TRUE([webView textInputHasAutoFillContext]);
     90    EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
     91
     92    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
     93    EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
    9294
    9395    auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
     
    9799
    98100    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"];
    99     EXPECT_FALSE([webView textInputHasAutoFillContext]);
     101    EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
    100102}
    101103
     
    105107    [webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input type='radio' name='radio_button' value='radio'><input id='password' type='password'>"];
    106108    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"user.focus()"];
    107     EXPECT_TRUE([webView textInputHasAutoFillContext]);
    108 
    109     [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
    110     EXPECT_TRUE([webView textInputHasAutoFillContext]);
     109    EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
     110
     111    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
     112    EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
    111113
    112114    auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
     
    117119
    118120    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"];
    119     EXPECT_FALSE([webView textInputHasAutoFillContext]);
     121    EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
    120122}
    121123
     
    125127    [webView synchronouslyLoadHTMLString:@"<input id='text1' type='email'><input id='text2' type='text'>"];
    126128    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"text1.focus()"];
    127     EXPECT_FALSE([webView textInputHasAutoFillContext]);
     129    EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
    128130
    129131    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"text2.focus()"];
    130     EXPECT_FALSE([webView textInputHasAutoFillContext]);
     132    EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
    131133}
    132134
     
    136138    [webView synchronouslyLoadHTMLString:@"<input id='password' type='password'>"];
    137139    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
    138     EXPECT_TRUE([webView textInputHasAutoFillContext]);
     140    EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
    139141
    140142    auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
     
    144146
    145147    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"];
    146     EXPECT_FALSE([webView textInputHasAutoFillContext]);
     148    EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
    147149}
    148150
     
    152154    [webView synchronouslyLoadHTMLString:@"<input id='textfield' type='text'>"];
    153155    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"textfield.focus()"];
    154     EXPECT_FALSE([webView textInputHasAutoFillContext]);
     156    EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
    155157}
    156158
     
    160162    [webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input id='password' type='password'><input id='confirm_password' type='password'>"];
    161163    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"user.focus()"];
    162     EXPECT_TRUE([webView textInputHasAutoFillContext]);
    163 
    164     [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
    165     EXPECT_TRUE([webView textInputHasAutoFillContext]);
     164    EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
     165
     166    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
     167    EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
    166168
    167169    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"confirm_password.focus()"];
    168     EXPECT_TRUE([webView textInputHasAutoFillContext]);
     170    EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
    169171}
    170172
     
    188190    Util::run(&done);
    189191
    190     EXPECT_FALSE([webView textInputHasAutoFillContext]);
     192    EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
    191193}
    192194
Note: See TracChangeset for help on using the changeset viewer.