Changeset 247804 in webkit


Ignore:
Timestamp:
Jul 24, 2019 5:44:58 PM (5 years ago)
Author:
commit-queue@webkit.org
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 <pagarwal999@apple.com> 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 <pagarwal999@apple.com> 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.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r247793 r247804  
     12019-07-24  Priyanka Agarwal  <pagarwal999@apple.com>
     2
     3        Allow Clients to Add Fields to the AutoFillContext Dictionary
     4        https://bugs.webkit.org/show_bug.cgi?id=199326
     5        rdar://problem/42816957
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * UIProcess/API/Cocoa/_WKInputDelegate.h:
     10        Added function declaration for function which returns additional dictionary for autofillcontext
     11
     12        * UIProcess/ios/WKContentViewInteraction.h:
     13        Created dictionary for additional autofillcontext
     14
     15        * UIProcess/ios/WKContentViewInteraction.mm:
     16        (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]):
     17        Populating additional dictionary for autofillcontext
     18
     19        (-[WKContentView _autofillContext]):
     20        Adding new dictionary to the returned autofillcontext
     21
    1222019-07-24  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInputDelegate.h

    r242339 r247804  
    5656- (BOOL)_webView:(WKWebView *)webView focusRequiresStrongPasswordAssistance:(id <_WKFocusedElementInfo>)info WK_API_AVAILABLE(ios(12.0));
    5757
     58- (NSDictionary<id, NSString *> *)_webViewAdditionalContextForStrongPasswordAssistance:(WKWebView *)webView WK_API_AVAILABLE(ios(WK_IOS_TBA));
     59
    5860- (BOOL)_webView:(WKWebView *)webView shouldRevealFocusOverlayForInputSession:(id <_WKFormInputSession>)inputSession WK_API_AVAILABLE(ios(12.0));
    5961- (CGFloat)_webView:(WKWebView *)webView focusedElementContextViewHeightForFittingSize:(CGSize)fittingSize inputSession:(id <_WKFormInputSession>)inputSession WK_API_AVAILABLE(ios(12.0));
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

    r247746 r247804  
    356356    CompletionHandler<void(WebCore::DOMPasteAccessResponse)> _domPasteRequestHandler;
    357357    BlockPtr<void(UIWKAutocorrectionContext *)> _pendingAutocorrectionContextHandler;
     358
     359    RetainPtr<NSDictionary> _additionalContextForStrongPasswordAssistance;
    358360
    359361#if ENABLE(DATA_INTERACTION)
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r247746 r247804  
    850850
    851851    _focusRequiresStrongPasswordAssistance = NO;
     852    _additionalContextForStrongPasswordAssistance = nil;
    852853    _waitingForEditDragSnapshot = NO;
    853854
     
    53145315
    53155316    _focusRequiresStrongPasswordAssistance = NO;
     5317    _additionalContextForStrongPasswordAssistance = nil;
    53165318    if ([inputDelegate respondsToSelector:@selector(_webView:focusRequiresStrongPasswordAssistance:)])
    53175319        _focusRequiresStrongPasswordAssistance = [inputDelegate _webView:_webView focusRequiresStrongPasswordAssistance:focusedElementInfo.get()];
     5320
     5321    if ([inputDelegate respondsToSelector:@selector(_webViewAdditionalContextForStrongPasswordAssistance:)])
     5322        _additionalContextForStrongPasswordAssistance = [inputDelegate _webViewAdditionalContextForStrongPasswordAssistance:_webView];
     5323    else
     5324        _additionalContextForStrongPasswordAssistance = @{ };
    53185325
    53195326    bool delegateImplementsWillStartInputSession = [inputDelegate respondsToSelector:@selector(_webView:willStartInputSession:)];
     
    54045411    _inputPeripheral = nil;
    54055412    _focusRequiresStrongPasswordAssistance = NO;
     5413    _additionalContextForStrongPasswordAssistance = nil;
    54065414
    54075415#if USE(UIKIT_KEYBOARD_ADDITIONS)
     
    67786786
    67796787    if (provideStrongPasswordAssistance)
    6780         return @{ @"_automaticPasswordKeyboard" : @YES };
     6788        return @{ @"_automaticPasswordKeyboard" : @YES, @"strongPasswordAdditionalContext" : _additionalContextForStrongPasswordAssistance.get() };
    67816789
    67826790    NSURL *platformURL = _focusedElementInformation.representingPageURL;
  • trunk/Tools/ChangeLog

    r247781 r247804  
     12019-07-24  Priyanka Agarwal  <pagarwal999@apple.com>
     2
     3        Allow Clients to Add Fields to the AutoFillContext Dictionary.
     4        https://bugs.webkit.org/show_bug.cgi?id=199326
     5        rdar://problem/42816957
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
     10        (TestWebKitAPI::TEST): Created a test to check that the auto fill context
     11        is being properly populated with additional context dictionary.
     12
     13        * TestWebKitAPI/Tests/ios/TestInputDelegate.h:
     14        * TestWebKitAPI/Tests/ios/TestInputDelegate.mm:
     15        (-[TestInputDelegate setWebViewAdditionalContextForStrongPasswordAssistanceHandler:]): Setting the handler for the function
     16        which will populate the additional autofill context dictionary.
     17
     18        (-[TestInputDelegate webViewAdditionalContextForStrongPasswordAssistanceHandler]): Returns the handler for the function which
     19        populates the additional autofill context dictionary.
     20
     21        (-[TestInputDelegate _webViewAdditionalContextForStrongPasswordAssistance:]): Function which populates the additional autofill
     22        context dictionary.
     23
     24        (-[TestInputDelegate setFocusRequiresStrongPasswordAssistanceHandler:]): Setting the handler for the function which checks if the
     25        input field requires strong password work.
     26
     27        (-[TestInputDelegate focusRequiresStrongPasswordAssistanceHandler]): Returns the handler for the function which checks if the
     28        input field requires strong password work.
     29
     30        (-[TestInputDelegate _webView:focusRequiresStrongPasswordAssistance:]): Function which checks if the input field requires strong
     31        password work.
     32
    1332019-07-24  Zhifei Fang  <zhifei_fang@apple.com>
    234
  • trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm

    r247398 r247804  
    528528}
    529529
     530TEST(KeyboardInputTests, TestWebViewAdditionalContextForStrongPasswordAssistance)
     531{
     532    NSDictionary *expected = @{ @"strongPasswordAdditionalContext" : @"testUUID" };
     533
     534    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     535    auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]);
     536
     537    [inputDelegate setFocusStartsInputSessionPolicyHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy {
     538        return _WKFocusStartsInputSessionPolicyAllow;
     539    }];
     540
     541    [inputDelegate setWebViewAdditionalContextForStrongPasswordAssistanceHandler:[&] (WKWebView *) {
     542        return expected;
     543    }];
     544
     545    [inputDelegate setFocusRequiresStrongPasswordAssistanceHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) {
     546        return YES;
     547    }];
     548
     549    [webView _setInputDelegate:inputDelegate.get()];
     550
     551    [webView synchronouslyLoadHTMLString:@"<input type='password' id='input'>"];
     552    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.getElementById('input').focus()"];
     553
     554    NSDictionary *actual = [[webView textInputContentView] _autofillContext];
     555    EXPECT_TRUE([[actual allValues] containsObject:expected]);
     556}
     557
    530558} // namespace TestWebKitAPI
    531559
  • trunk/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.h

    r246924 r247804  
    3838@property (nonatomic, copy) void (^willStartInputSessionHandler)(WKWebView *, id <_WKFormInputSession>);
    3939@property (nonatomic, copy) void (^didStartInputSessionHandler)(WKWebView *, id <_WKFormInputSession>);
     40@property (nonatomic, copy) NSDictionary<id, NSString *> * (^webViewAdditionalContextForStrongPasswordAssistanceHandler)(WKWebView *);
     41@property (nonatomic, copy) BOOL (^focusRequiresStrongPasswordAssistanceHandler)(WKWebView *, id <_WKFocusedElementInfo>);
    4042@end
    4143
  • trunk/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.mm

    r246924 r247804  
    3535    BlockPtr<void(WKWebView *, id <_WKFormInputSession>)> _willStartInputSessionHandler;
    3636    BlockPtr<void(WKWebView *, id <_WKFormInputSession>)> _didStartInputSessionHandler;
     37    BlockPtr<NSDictionary<id, NSString *> *(WKWebView *)> _webViewAdditionalContextForStrongPasswordAssistanceHandler;
     38    BlockPtr<BOOL(WKWebView *, id <_WKFocusedElementInfo>)> _focusRequiresStrongPasswordAssistanceHandler;
    3739}
    3840
     
    8486}
    8587
     88- (void)setWebViewAdditionalContextForStrongPasswordAssistanceHandler:(NSDictionary<id, NSString *> * (^)(WKWebView *))webViewAdditionalContextForStrongPasswordAssistanceHandler
     89{
     90    _webViewAdditionalContextForStrongPasswordAssistanceHandler = makeBlockPtr(webViewAdditionalContextForStrongPasswordAssistanceHandler);
     91}
     92
     93- (NSDictionary<id, NSString *> * (^)(WKWebView *))webViewAdditionalContextForStrongPasswordAssistanceHandler
     94{
     95    return _webViewAdditionalContextForStrongPasswordAssistanceHandler.get();
     96}
     97
     98- (NSDictionary<id, NSString *> *)_webViewAdditionalContextForStrongPasswordAssistance:(WKWebView *)webView
     99{
     100    if (_webViewAdditionalContextForStrongPasswordAssistanceHandler)
     101        return _webViewAdditionalContextForStrongPasswordAssistanceHandler(webView);
     102    return @{ };
     103}
     104
     105- (void)setFocusRequiresStrongPasswordAssistanceHandler:(BOOL (^)(WKWebView *, id <_WKFocusedElementInfo>))handler
     106{
     107    _focusRequiresStrongPasswordAssistanceHandler = makeBlockPtr(handler);
     108}
     109
     110- (BOOL (^)(WKWebView *, id <_WKFocusedElementInfo>))focusRequiresStrongPasswordAssistanceHandler
     111{
     112    return _focusRequiresStrongPasswordAssistanceHandler.get();
     113}
     114
     115- (BOOL)_webView:(WKWebView *)webView focusRequiresStrongPasswordAssistance:(id <_WKFocusedElementInfo>)info
     116{
     117    if (_focusRequiresStrongPasswordAssistanceHandler)
     118        return _focusRequiresStrongPasswordAssistanceHandler(webView, info);
     119    return NO;
     120}
     121
    86122@end
    87123
Note: See TracChangeset for help on using the changeset viewer.