Title: [273759] trunk
Revision
273759
Author
[email protected]
Date
2021-03-02 14:11:55 -0800 (Tue, 02 Mar 2021)

Log 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 <[email protected]> on 2021-03-02
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.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (273758 => 273759)


--- trunk/Source/WebKit/ChangeLog	2021-03-02 21:31:00 UTC (rev 273758)
+++ trunk/Source/WebKit/ChangeLog	2021-03-02 22:11:55 UTC (rev 273759)
@@ -1,3 +1,16 @@
+2021-03-02  Ricky Mondello  <[email protected]>
+
+        Unconditionally return information in _autofillContext SPI when a field is focused
+        https://bugs.webkit.org/show_bug.cgi?id=221828
+        rdar://74211237
+
+        Reviewed by Darin Adler.
+
+        * 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.
+
 2021-03-02  Carlos Garcia Campos  <[email protected]>
 
         REGRESSION(r263094): [GTK][WPE] API test /webkit/WebKitWebContext/languages is failing

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/ChangeLog (273758 => 273759)


--- trunk/Tools/ChangeLog	2021-03-02 21:31:00 UTC (rev 273758)
+++ trunk/Tools/ChangeLog	2021-03-02 22:11:55 UTC (rev 273759)
@@ -1,3 +1,21 @@
+2021-03-02  Ricky Mondello  <[email protected]>
+
+        Unconditionally return information in _autofillContext SPI when a field is focused
+        https://bugs.webkit.org/show_bug.cgi?id=221828
+        rdar://74211237
+
+        Reviewed by Darin Adler.
+
+        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.
+
 2021-03-02  Aakash Jain  <[email protected]>
 
         Make build.webkit.org loadconfig similar to EWS

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)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to