Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (273758 => 273759)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2021-03-02 21:31:00 UTC (rev 273758)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2021-03-02 22:11:55 UTC (rev 273759)
@@ -8129,18 +8129,23 @@
- (NSDictionary *)_autofillContext
{
- BOOL provideStrongPasswordAssistance = _focusRequiresStrongPasswordAssistance && _focusedElementInformation.elementType == WebKit::InputType::Password;
- if (!self._hasFocusedElement || (!_focusedElementInformation.acceptsAutofilledLoginCredentials && !provideStrongPasswordAssistance))
+ if (!self._hasFocusedElement)
return nil;
- if (provideStrongPasswordAssistance)
- return @{ @"_automaticPasswordKeyboard" : @YES, @"strongPasswordAdditionalContext" : _additionalContextForStrongPasswordAssistance.get() };
+ auto context = adoptNS([[NSMutableDictionary alloc] init]);
+ context.get()[@"_WKAutofillContextVersion"] = @(2);
+ if (_focusRequiresStrongPasswordAssistance && _focusedElementInformation.elementType == WebKit::InputType::Password) {
+ context.get()[@"_automaticPasswordKeyboard"] = @YES;
+ context.get()[@"strongPasswordAdditionalContext"] = _additionalContextForStrongPasswordAssistance.get();
+ } else if (_focusedElementInformation.acceptsAutofilledLoginCredentials)
+ context.get()[@"_acceptsLoginCredentials"] = @YES;
+
NSURL *platformURL = _focusedElementInformation.representingPageURL;
if (platformURL)
- return @{ @"_WebViewURL" : platformURL };
+ context.get()[@"_WebViewURL"] = platformURL;
- return nil;
+ return context.autorelease();
}
- (BOOL)supportsImagePaste
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm (273758 => 273759)
--- trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm 2021-03-02 21:31:00 UTC (rev 273758)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm 2021-03-02 22:11:55 UTC (rev 273759)
@@ -689,6 +689,7 @@
NSDictionary *actual = [[webView textInputContentView] _autofillContext];
EXPECT_TRUE([[actual allValues] containsObject:expected]);
+ EXPECT_TRUE([actual[@"_automaticPasswordKeyboard"] boolValue]);
}
TEST(KeyboardInputTests, TestWebViewAccessoryDoneDuringStrongPasswordAssistance)
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm (273758 => 273759)
--- trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm 2021-03-02 21:31:00 UTC (rev 273758)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm 2021-03-02 22:11:55 UTC (rev 273759)
@@ -66,14 +66,16 @@
return (AutoFillInputView *)self.textInputContentView;
}
-- (BOOL)textInputHasAutoFillContext
+- (BOOL)acceptsAutoFillLoginCredentials
{
- NSURL *url = "" objectForKey:@"_WebViewURL"];
- if (![url isKindOfClass:[NSURL class]])
+ auto context = self._autofillInputView._autofillContext;
+ if (!context)
return NO;
+ NSURL *url = ""
+ EXPECT_TRUE([url isKindOfClass:NSURL.class]);
EXPECT_WK_STREQ([self stringByEvaluatingJavaScript:@"document.URL"], url.absoluteString);
- return YES;
+ return [context[@"_acceptsLoginCredentials"] boolValue];
}
@end
@@ -85,10 +87,10 @@
auto webView = adoptNS([[AutoFillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
[webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input id='password' type='password'>"];
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"user.focus()"];
- EXPECT_TRUE([webView textInputHasAutoFillContext]);
+ EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
- EXPECT_TRUE([webView textInputHasAutoFillContext]);
+ EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
[[webView _autofillInputView] insertTextSuggestion:credentialSuggestion];
@@ -96,7 +98,7 @@
EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"];
- EXPECT_FALSE([webView textInputHasAutoFillContext]);
+ EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
}
TEST(WKWebViewAutoFillTests, UsernameAndPasswordFieldSeparatedByRadioButton)
@@ -104,10 +106,10 @@
auto webView = adoptNS([[AutoFillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
[webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input type='radio' name='radio_button' value='radio'><input id='password' type='password'>"];
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"user.focus()"];
- EXPECT_TRUE([webView textInputHasAutoFillContext]);
+ EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
- EXPECT_TRUE([webView textInputHasAutoFillContext]);
+ EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
[[webView _autofillInputView] insertTextSuggestion:credentialSuggestion];
@@ -116,7 +118,7 @@
EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"];
- EXPECT_FALSE([webView textInputHasAutoFillContext]);
+ EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
}
TEST(WKWebViewAutoFillTests, TwoTextFields)
@@ -124,10 +126,10 @@
auto webView = adoptNS([[AutoFillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
[webView synchronouslyLoadHTMLString:@"<input id='text1' type='email'><input id='text2' type='text'>"];
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"text1.focus()"];
- EXPECT_FALSE([webView textInputHasAutoFillContext]);
+ EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"text2.focus()"];
- EXPECT_FALSE([webView textInputHasAutoFillContext]);
+ EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
}
TEST(WKWebViewAutoFillTests, StandalonePasswordField)
@@ -135,7 +137,7 @@
auto webView = adoptNS([[AutoFillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
[webView synchronouslyLoadHTMLString:@"<input id='password' type='password'>"];
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
- EXPECT_TRUE([webView textInputHasAutoFillContext]);
+ EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
[[webView _autofillInputView] insertTextSuggestion:credentialSuggestion];
@@ -143,7 +145,7 @@
EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"];
- EXPECT_FALSE([webView textInputHasAutoFillContext]);
+ EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
}
TEST(WKWebViewAutoFillTests, StandaloneTextField)
@@ -151,7 +153,7 @@
auto webView = adoptNS([[AutoFillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
[webView synchronouslyLoadHTMLString:@"<input id='textfield' type='text'>"];
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"textfield.focus()"];
- EXPECT_FALSE([webView textInputHasAutoFillContext]);
+ EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
}
TEST(WKWebViewAutoFillTests, AccountCreationPage)
@@ -159,13 +161,13 @@
auto webView = adoptNS([[AutoFillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
[webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input id='password' type='password'><input id='confirm_password' type='password'>"];
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"user.focus()"];
- EXPECT_TRUE([webView textInputHasAutoFillContext]);
+ EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
- EXPECT_TRUE([webView textInputHasAutoFillContext]);
+ EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"confirm_password.focus()"];
- EXPECT_TRUE([webView textInputHasAutoFillContext]);
+ EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
}
static BOOL overrideIsInHardwareKeyboardMode()
@@ -187,7 +189,7 @@
[webView stringByEvaluatingJavaScript:@"user.focus()"];
Util::run(&done);
- EXPECT_FALSE([webView textInputHasAutoFillContext]);
+ EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
}
#if PLATFORM(WATCHOS)