Changeset 273115 in webkit
- Timestamp:
- Feb 18, 2021 4:58:54 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r273114 r273115 1 2021-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 1 14 2021-02-18 Brent Fulgham <bfulgham@apple.com> 2 15 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r273077 r273115 8081 8081 - (NSDictionary *)_autofillContext 8082 8082 { 8083 BOOL provideStrongPasswordAssistance = _focusRequiresStrongPasswordAssistance && _focusedElementInformation.elementType == WebKit::InputType::Password; 8084 if (!self._hasFocusedElement || (!_focusedElementInformation.acceptsAutofilledLoginCredentials && !provideStrongPasswordAssistance)) 8083 if (!self._hasFocusedElement) 8085 8084 return nil; 8086 8085 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; 8089 8094 8090 8095 NSURL *platformURL = _focusedElementInformation.representingPageURL; 8091 8096 if (platformURL) 8092 return @{ @"_WebViewURL" : platformURL };8093 8094 return nil;8097 context.get()[@"_WebViewURL"] = platformURL; 8098 8099 return context.autorelease(); 8095 8100 } 8096 8101 -
trunk/Tools/ChangeLog
r273111 r273115 1 2021-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 1 19 2021-02-18 Alex Christensen <achristensen@webkit.org> 2 20 -
trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm
r265238 r273115 690 690 NSDictionary *actual = [[webView textInputContentView] _autofillContext]; 691 691 EXPECT_TRUE([[actual allValues] containsObject:expected]); 692 EXPECT_TRUE([actual[@"_automaticPasswordKeyboard"] boolValue]); 692 693 } 693 694 -
trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm
r272448 r273115 67 67 } 68 68 69 - (BOOL) textInputHasAutoFillContext70 { 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) 73 73 return NO; 74 74 75 NSURL *url = context[@"_WebViewURL"]; 76 EXPECT_TRUE([url isKindOfClass:NSURL.class]); 75 77 EXPECT_WK_STREQ([self stringByEvaluatingJavaScript:@"document.URL"], url.absoluteString); 76 return YES;78 return [context[@"_acceptsLoginCredentials"] boolValue]; 77 79 } 78 80 … … 86 88 [webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input id='password' type='password'>"]; 87 89 [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]); 92 94 93 95 auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"]; … … 97 99 98 100 [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"]; 99 EXPECT_FALSE([webView textInputHasAutoFillContext]);101 EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]); 100 102 } 101 103 … … 105 107 [webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input type='radio' name='radio_button' value='radio'><input id='password' type='password'>"]; 106 108 [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]); 111 113 112 114 auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"]; … … 117 119 118 120 [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"]; 119 EXPECT_FALSE([webView textInputHasAutoFillContext]);121 EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]); 120 122 } 121 123 … … 125 127 [webView synchronouslyLoadHTMLString:@"<input id='text1' type='email'><input id='text2' type='text'>"]; 126 128 [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"text1.focus()"]; 127 EXPECT_FALSE([webView textInputHasAutoFillContext]);129 EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]); 128 130 129 131 [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"text2.focus()"]; 130 EXPECT_FALSE([webView textInputHasAutoFillContext]);132 EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]); 131 133 } 132 134 … … 136 138 [webView synchronouslyLoadHTMLString:@"<input id='password' type='password'>"]; 137 139 [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"]; 138 EXPECT_TRUE([webView textInputHasAutoFillContext]);140 EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]); 139 141 140 142 auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"]; … … 144 146 145 147 [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"]; 146 EXPECT_FALSE([webView textInputHasAutoFillContext]);148 EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]); 147 149 } 148 150 … … 152 154 [webView synchronouslyLoadHTMLString:@"<input id='textfield' type='text'>"]; 153 155 [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"textfield.focus()"]; 154 EXPECT_FALSE([webView textInputHasAutoFillContext]);156 EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]); 155 157 } 156 158 … … 160 162 [webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input id='password' type='password'><input id='confirm_password' type='password'>"]; 161 163 [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]); 166 168 167 169 [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"confirm_password.focus()"]; 168 EXPECT_TRUE([webView textInputHasAutoFillContext]);170 EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]); 169 171 } 170 172 … … 188 190 Util::run(&done); 189 191 190 EXPECT_FALSE([webView textInputHasAutoFillContext]);192 EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]); 191 193 } 192 194
Note: See TracChangeset
for help on using the changeset viewer.