Title: [247804] trunk
Revision
247804
Author
[email protected]
Date
2019-07-24 17:44:58 -0700 (Wed, 24 Jul 2019)

Log Message

Source/WebKit:
Allow Clients to Add Fields to the AutoFillContext Dictionary
https://bugs.webkit.org/show_bug.cgi?id=199326
rdar://problem/42816957

Patch by Priyanka Agarwal <[email protected]> on 2019-07-24
Reviewed by Wenson Hsieh.

* UIProcess/API/Cocoa/_WKInputDelegate.h:
Added function declaration for function which returns additional dictionary for autofillcontext

* UIProcess/ios/WKContentViewInteraction.h:
Created dictionary for additional autofillcontext

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]):
Populating additional dictionary for autofillcontext

(-[WKContentView _autofillContext]):
Adding new dictionary to the returned autofillcontext

Tools:
Allow Clients to Add Fields to the AutoFillContext Dictionary.
https://bugs.webkit.org/show_bug.cgi?id=199326
rdar://problem/42816957

Patch by Priyanka Agarwal <[email protected]> on 2019-07-24
Reviewed by Wenson Hsieh.

* TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
(TestWebKitAPI::TEST): Created a test to check that the auto fill context
is being properly populated with additional context dictionary.

* TestWebKitAPI/Tests/ios/TestInputDelegate.h:
* TestWebKitAPI/Tests/ios/TestInputDelegate.mm:
(-[TestInputDelegate setWebViewAdditionalContextForStrongPasswordAssistanceHandler:]): Setting the handler for the function
which will populate the additional autofill context dictionary.

(-[TestInputDelegate webViewAdditionalContextForStrongPasswordAssistanceHandler]): Returns the handler for the function which
populates the additional autofill context dictionary.

(-[TestInputDelegate _webViewAdditionalContextForStrongPasswordAssistance:]): Function which populates the additional autofill
context dictionary.

(-[TestInputDelegate setFocusRequiresStrongPasswordAssistanceHandler:]): Setting the handler for the function which checks if the
input field requires strong password work.

(-[TestInputDelegate focusRequiresStrongPasswordAssistanceHandler]): Returns the handler for the function which checks if the
input field requires strong password work.

(-[TestInputDelegate _webView:focusRequiresStrongPasswordAssistance:]): Function which checks if the input field requires strong
password work.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (247803 => 247804)


--- trunk/Source/WebKit/ChangeLog	2019-07-25 00:42:23 UTC (rev 247803)
+++ trunk/Source/WebKit/ChangeLog	2019-07-25 00:44:58 UTC (rev 247804)
@@ -1,3 +1,24 @@
+2019-07-24  Priyanka Agarwal  <[email protected]>
+
+        Allow Clients to Add Fields to the AutoFillContext Dictionary
+        https://bugs.webkit.org/show_bug.cgi?id=199326
+        rdar://problem/42816957
+
+        Reviewed by Wenson Hsieh.
+
+        * UIProcess/API/Cocoa/_WKInputDelegate.h:
+        Added function declaration for function which returns additional dictionary for autofillcontext
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        Created dictionary for additional autofillcontext
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]):
+        Populating additional dictionary for autofillcontext
+
+        (-[WKContentView _autofillContext]):
+        Adding new dictionary to the returned autofillcontext
+
 2019-07-24  Chris Dumez  <[email protected]>
 
         Regression(r247400): Unable to log into AIB Mobile Banking App

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInputDelegate.h (247803 => 247804)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInputDelegate.h	2019-07-25 00:42:23 UTC (rev 247803)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInputDelegate.h	2019-07-25 00:44:58 UTC (rev 247804)
@@ -55,6 +55,8 @@
 - (void)_webView:(WKWebView *)webView willStartInputSession:(id <_WKFormInputSession>)inputSession WK_API_AVAILABLE(ios(12.0));
 - (BOOL)_webView:(WKWebView *)webView focusRequiresStrongPasswordAssistance:(id <_WKFocusedElementInfo>)info WK_API_AVAILABLE(ios(12.0));
 
+- (NSDictionary<id, NSString *> *)_webViewAdditionalContextForStrongPasswordAssistance:(WKWebView *)webView WK_API_AVAILABLE(ios(WK_IOS_TBA));
+
 - (BOOL)_webView:(WKWebView *)webView shouldRevealFocusOverlayForInputSession:(id <_WKFormInputSession>)inputSession WK_API_AVAILABLE(ios(12.0));
 - (CGFloat)_webView:(WKWebView *)webView focusedElementContextViewHeightForFittingSize:(CGSize)fittingSize inputSession:(id <_WKFormInputSession>)inputSession WK_API_AVAILABLE(ios(12.0));
 - (UIView *)_webView:(WKWebView *)webView focusedElementContextViewForInputSession:(id <_WKFormInputSession>)inputSession WK_API_AVAILABLE(ios(12.0));

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (247803 => 247804)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-07-25 00:42:23 UTC (rev 247803)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-07-25 00:44:58 UTC (rev 247804)
@@ -356,6 +356,8 @@
     CompletionHandler<void(WebCore::DOMPasteAccessResponse)> _domPasteRequestHandler;
     BlockPtr<void(UIWKAutocorrectionContext *)> _pendingAutocorrectionContextHandler;
 
+    RetainPtr<NSDictionary> _additionalContextForStrongPasswordAssistance;
+
 #if ENABLE(DATA_INTERACTION)
     WebKit::DragDropInteractionState _dragDropInteractionState;
     RetainPtr<UIDragInteraction> _dragInteraction;

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (247803 => 247804)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-07-25 00:42:23 UTC (rev 247803)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-07-25 00:44:58 UTC (rev 247804)
@@ -849,6 +849,7 @@
     _outstandingPositionInformationRequest = WTF::nullopt;
 
     _focusRequiresStrongPasswordAssistance = NO;
+    _additionalContextForStrongPasswordAssistance = nil;
     _waitingForEditDragSnapshot = NO;
 
 #if USE(UIKIT_KEYBOARD_ADDITIONS)
@@ -5313,9 +5314,15 @@
     [_webView _resetFocusPreservationCount];
 
     _focusRequiresStrongPasswordAssistance = NO;
+    _additionalContextForStrongPasswordAssistance = nil;
     if ([inputDelegate respondsToSelector:@selector(_webView:focusRequiresStrongPasswordAssistance:)])
         _focusRequiresStrongPasswordAssistance = [inputDelegate _webView:_webView focusRequiresStrongPasswordAssistance:focusedElementInfo.get()];
 
+    if ([inputDelegate respondsToSelector:@selector(_webViewAdditionalContextForStrongPasswordAssistance:)])
+        _additionalContextForStrongPasswordAssistance = [inputDelegate _webViewAdditionalContextForStrongPasswordAssistance:_webView];
+    else
+        _additionalContextForStrongPasswordAssistance = @{ };
+
     bool delegateImplementsWillStartInputSession = [inputDelegate respondsToSelector:@selector(_webView:willStartInputSession:)];
     bool delegateImplementsDidStartInputSession = [inputDelegate respondsToSelector:@selector(_webView:didStartInputSession:)];
 
@@ -5403,6 +5410,7 @@
     _focusedElementInformation.shouldAvoidScrollingWhenFocusedContentIsVisible = false;
     _inputPeripheral = nil;
     _focusRequiresStrongPasswordAssistance = NO;
+    _additionalContextForStrongPasswordAssistance = nil;
 
 #if USE(UIKIT_KEYBOARD_ADDITIONS)
     // When defocusing an editable element reset a seen keydown before calling -_hideKeyboard so that we
@@ -6777,7 +6785,7 @@
         return nil;
 
     if (provideStrongPasswordAssistance)
-        return @{ @"_automaticPasswordKeyboard" : @YES };
+        return @{ @"_automaticPasswordKeyboard" : @YES, @"strongPasswordAdditionalContext" : _additionalContextForStrongPasswordAssistance.get() };
 
     NSURL *platformURL = _focusedElementInformation.representingPageURL;
     if (platformURL)

Modified: trunk/Tools/ChangeLog (247803 => 247804)


--- trunk/Tools/ChangeLog	2019-07-25 00:42:23 UTC (rev 247803)
+++ trunk/Tools/ChangeLog	2019-07-25 00:44:58 UTC (rev 247804)
@@ -1,3 +1,35 @@
+2019-07-24  Priyanka Agarwal  <[email protected]>
+
+        Allow Clients to Add Fields to the AutoFillContext Dictionary.
+        https://bugs.webkit.org/show_bug.cgi?id=199326
+        rdar://problem/42816957
+
+        Reviewed by Wenson Hsieh.
+
+        * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
+        (TestWebKitAPI::TEST): Created a test to check that the auto fill context
+        is being properly populated with additional context dictionary.
+
+        * TestWebKitAPI/Tests/ios/TestInputDelegate.h:
+        * TestWebKitAPI/Tests/ios/TestInputDelegate.mm:
+        (-[TestInputDelegate setWebViewAdditionalContextForStrongPasswordAssistanceHandler:]): Setting the handler for the function
+        which will populate the additional autofill context dictionary.
+
+        (-[TestInputDelegate webViewAdditionalContextForStrongPasswordAssistanceHandler]): Returns the handler for the function which
+        populates the additional autofill context dictionary.
+
+        (-[TestInputDelegate _webViewAdditionalContextForStrongPasswordAssistance:]): Function which populates the additional autofill
+        context dictionary.
+
+        (-[TestInputDelegate setFocusRequiresStrongPasswordAssistanceHandler:]): Setting the handler for the function which checks if the 
+        input field requires strong password work.
+
+        (-[TestInputDelegate focusRequiresStrongPasswordAssistanceHandler]): Returns the handler for the function which checks if the
+        input field requires strong password work.
+
+        (-[TestInputDelegate _webView:focusRequiresStrongPasswordAssistance:]): Function which checks if the input field requires strong
+        password work.
+
 2019-07-24  Zhifei Fang  <[email protected]>
 
         run-_javascript_core-tests won't report test results for testmasm, testair, testb3, testdfg and test api

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm (247803 => 247804)


--- trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm	2019-07-25 00:42:23 UTC (rev 247803)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm	2019-07-25 00:44:58 UTC (rev 247804)
@@ -527,6 +527,34 @@
     EXPECT_EQ(20, selectionClipRect.size.height);
 }
 
+TEST(KeyboardInputTests, TestWebViewAdditionalContextForStrongPasswordAssistance)
+{
+    NSDictionary *expected = @{ @"strongPasswordAdditionalContext" : @"testUUID" };
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]);
+
+    [inputDelegate setFocusStartsInputSessionPolicyHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy {
+        return _WKFocusStartsInputSessionPolicyAllow;
+    }];
+
+    [inputDelegate setWebViewAdditionalContextForStrongPasswordAssistanceHandler:[&] (WKWebView *) {
+        return expected;
+    }];
+
+    [inputDelegate setFocusRequiresStrongPasswordAssistanceHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) {
+        return YES;
+    }];
+
+    [webView _setInputDelegate:inputDelegate.get()];
+
+    [webView synchronouslyLoadHTMLString:@"<input type='password' id='input'>"];
+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.getElementById('input').focus()"];
+
+    NSDictionary *actual = [[webView textInputContentView] _autofillContext];
+    EXPECT_TRUE([[actual allValues] containsObject:expected]);
+}
+
 } // namespace TestWebKitAPI
 
 #endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.h (247803 => 247804)


--- trunk/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.h	2019-07-25 00:42:23 UTC (rev 247803)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.h	2019-07-25 00:44:58 UTC (rev 247804)
@@ -37,6 +37,8 @@
 @property (nonatomic, copy) _WKFocusStartsInputSessionPolicy (^focusStartsInputSessionPolicyHandler)(WKWebView *, id <_WKFocusedElementInfo>);
 @property (nonatomic, copy) void (^willStartInputSessionHandler)(WKWebView *, id <_WKFormInputSession>);
 @property (nonatomic, copy) void (^didStartInputSessionHandler)(WKWebView *, id <_WKFormInputSession>);
+@property (nonatomic, copy) NSDictionary<id, NSString *> * (^webViewAdditionalContextForStrongPasswordAssistanceHandler)(WKWebView *);
+@property (nonatomic, copy) BOOL (^focusRequiresStrongPasswordAssistanceHandler)(WKWebView *, id <_WKFocusedElementInfo>);
 @end
 
 #endif

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.mm (247803 => 247804)


--- trunk/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.mm	2019-07-25 00:42:23 UTC (rev 247803)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.mm	2019-07-25 00:44:58 UTC (rev 247804)
@@ -34,6 +34,8 @@
     BlockPtr<_WKFocusStartsInputSessionPolicy(WKWebView *, id <_WKFocusedElementInfo>)> _focusStartsInputSessionPolicyHandler;
     BlockPtr<void(WKWebView *, id <_WKFormInputSession>)> _willStartInputSessionHandler;
     BlockPtr<void(WKWebView *, id <_WKFormInputSession>)> _didStartInputSessionHandler;
+    BlockPtr<NSDictionary<id, NSString *> *(WKWebView *)> _webViewAdditionalContextForStrongPasswordAssistanceHandler;
+    BlockPtr<BOOL(WKWebView *, id <_WKFocusedElementInfo>)> _focusRequiresStrongPasswordAssistanceHandler;
 }
 
 - (void)setFocusStartsInputSessionPolicyHandler:(_WKFocusStartsInputSessionPolicy (^)(WKWebView *, id <_WKFocusedElementInfo>))handler
@@ -83,6 +85,40 @@
         _didStartInputSessionHandler(webView, inputSession);
 }
 
+- (void)setWebViewAdditionalContextForStrongPasswordAssistanceHandler:(NSDictionary<id, NSString *> * (^)(WKWebView *))webViewAdditionalContextForStrongPasswordAssistanceHandler
+{
+    _webViewAdditionalContextForStrongPasswordAssistanceHandler = makeBlockPtr(webViewAdditionalContextForStrongPasswordAssistanceHandler);
+}
+
+- (NSDictionary<id, NSString *> * (^)(WKWebView *))webViewAdditionalContextForStrongPasswordAssistanceHandler
+{
+    return _webViewAdditionalContextForStrongPasswordAssistanceHandler.get();
+}
+
+- (NSDictionary<id, NSString *> *)_webViewAdditionalContextForStrongPasswordAssistance:(WKWebView *)webView
+{
+    if (_webViewAdditionalContextForStrongPasswordAssistanceHandler)
+        return _webViewAdditionalContextForStrongPasswordAssistanceHandler(webView);
+    return @{ };
+}
+
+- (void)setFocusRequiresStrongPasswordAssistanceHandler:(BOOL (^)(WKWebView *, id <_WKFocusedElementInfo>))handler
+{
+    _focusRequiresStrongPasswordAssistanceHandler = makeBlockPtr(handler);
+}
+
+- (BOOL (^)(WKWebView *, id <_WKFocusedElementInfo>))focusRequiresStrongPasswordAssistanceHandler
+{
+    return _focusRequiresStrongPasswordAssistanceHandler.get();
+}
+
+- (BOOL)_webView:(WKWebView *)webView focusRequiresStrongPasswordAssistance:(id <_WKFocusedElementInfo>)info
+{
+    if (_focusRequiresStrongPasswordAssistanceHandler)
+        return _focusRequiresStrongPasswordAssistanceHandler(webView, info);
+    return NO;
+}
+
 @end
 
 #endif // PLATFORM(IOS_FAMILY)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to