Title: [222013] trunk
Revision
222013
Author
[email protected]
Date
2017-09-14 00:01:20 -0700 (Thu, 14 Sep 2017)

Log Message

Introduce the option to mark an HTML element as having AutoFill available.
https://bugs.webkit.org/show_bug.cgi?id=176710

Patch by Maureen Daum <[email protected]> on 2017-09-14
Reviewed by Alex Christensen.

Source/WebCore:

Introduce the option to mark an HTML element as having AutoFill available. Accessibility
can use this property when deciding whether to announce that the focused field offers
AutoFill.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::isValueAutofillAvailable const):
Check if the field is explicitly marked as having AutoFill available.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::HTMLInputElement):
* html/HTMLInputElement.h:
(WebCore::HTMLInputElement::isAutoFillAvailable const):
(WebCore::HTMLInputElement::setAutoFillAvailable):

Source/WebKit:

Introduce the option to mark an HTML element as having AutoFill available. Accessibility
can use this property when deciding whether to announce that the focused field offers
AutoFill.

* WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
(WKBundleNodeHandleGetHTMLInputElementAutoFillAvailable):
(WKBundleNodeHandleSetHTMLInputElementAutoFillAvailable):
* WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:
* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::InjectedBundleNodeHandle::isAutoFillAvailable const):
(WebKit::InjectedBundleNodeHandle::setAutoFillAvailable):
* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:

Tools:

Add an API test that verifies after we mark a field as having AutoFill available,
Accessibility also considers it to have AutoFill available.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add AutoFillAvailable.mm
* TestWebKitAPI/Tests/WebKitCocoa/AutoFillAvailable.mm: Added.
Create an input element, mark it as having AutoFill available, then focus it so that
we can get the accessibility information for it. Ask accessibility whether it considers
the field to have AutoFill available, and pick the alert message based on that.
(-[AutoFillAvailable webProcessPlugIn:didCreateBrowserContextController:]):
* TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
(TEST):
(-[AutoFillAvailableDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
Verify that we get the alert message indicating that accessibility indeed considers
the input element as having AutoFill available after we explicitly marked it as so.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (222012 => 222013)


--- trunk/Source/WebCore/ChangeLog	2017-09-14 06:57:12 UTC (rev 222012)
+++ trunk/Source/WebCore/ChangeLog	2017-09-14 07:01:20 UTC (rev 222013)
@@ -1,3 +1,23 @@
+2017-09-14  Maureen Daum  <[email protected]>
+
+        Introduce the option to mark an HTML element as having AutoFill available.
+        https://bugs.webkit.org/show_bug.cgi?id=176710
+
+        Reviewed by Alex Christensen.
+
+        Introduce the option to mark an HTML element as having AutoFill available. Accessibility
+        can use this property when deciding whether to announce that the focused field offers
+        AutoFill.
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::isValueAutofillAvailable const):
+        Check if the field is explicitly marked as having AutoFill available.
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::HTMLInputElement):
+        * html/HTMLInputElement.h:
+        (WebCore::HTMLInputElement::isAutoFillAvailable const):
+        (WebCore::HTMLInputElement::setAutoFillAvailable):
+
 2017-09-13  Basuke Suzuki  <[email protected]>
 
         [Curl] Move response related features into ResourceResponse

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (222012 => 222013)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2017-09-14 06:57:12 UTC (rev 222012)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2017-09-14 07:01:20 UTC (rev 222013)
@@ -2461,7 +2461,7 @@
     if (!is<HTMLInputElement>(node))
         return false;
     
-    return downcast<HTMLInputElement>(*node).autoFillButtonType() != AutoFillButtonType::None;
+    return downcast<HTMLInputElement>(*node).isAutoFillAvailable() || downcast<HTMLInputElement>(*node).autoFillButtonType() != AutoFillButtonType::None;
 }
 
 AutoFillButtonType AccessibilityObject::valueAutofillButtonType() const

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (222012 => 222013)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2017-09-14 06:57:12 UTC (rev 222012)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2017-09-14 07:01:20 UTC (rev 222013)
@@ -103,6 +103,7 @@
     , m_autocomplete(Uninitialized)
     , m_isAutoFilled(false)
     , m_autoFillButtonType(static_cast<uint8_t>(AutoFillButtonType::None))
+    , m_isAutoFillAvailable(false)
 #if ENABLE(DATALIST_ELEMENT)
     , m_hasNonEmptyList(false)
 #endif

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (222012 => 222013)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2017-09-14 06:57:12 UTC (rev 222012)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2017-09-14 07:01:20 UTC (rev 222013)
@@ -237,6 +237,9 @@
     AutoFillButtonType autoFillButtonType() const { return (AutoFillButtonType)m_autoFillButtonType; }
     WEBCORE_EXPORT void setShowAutoFillButton(AutoFillButtonType);
 
+    bool isAutoFillAvailable() const { return m_isAutoFillAvailable; }
+    void setAutoFillAvailable(bool autoFillAvailable) { m_isAutoFillAvailable = autoFillAvailable; }
+
     WEBCORE_EXPORT FileList* files();
     WEBCORE_EXPORT void setFiles(RefPtr<FileList>&&);
 
@@ -447,6 +450,7 @@
     unsigned m_autocomplete : 2; // AutoCompleteSetting
     bool m_isAutoFilled : 1;
     unsigned m_autoFillButtonType : 2; // AutoFillButtonType;
+    bool m_isAutoFillAvailable : 1;
 #if ENABLE(DATALIST_ELEMENT)
     bool m_hasNonEmptyList : 1;
 #endif

Modified: trunk/Source/WebKit/ChangeLog (222012 => 222013)


--- trunk/Source/WebKit/ChangeLog	2017-09-14 06:57:12 UTC (rev 222012)
+++ trunk/Source/WebKit/ChangeLog	2017-09-14 07:01:20 UTC (rev 222013)
@@ -1,3 +1,23 @@
+2017-09-14  Maureen Daum  <[email protected]>
+
+        Introduce the option to mark an HTML element as having AutoFill available.
+        https://bugs.webkit.org/show_bug.cgi?id=176710
+
+        Reviewed by Alex Christensen.
+
+        Introduce the option to mark an HTML element as having AutoFill available. Accessibility
+        can use this property when deciding whether to announce that the focused field offers
+        AutoFill.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
+        (WKBundleNodeHandleGetHTMLInputElementAutoFillAvailable):
+        (WKBundleNodeHandleSetHTMLInputElementAutoFillAvailable):
+        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
+        (WebKit::InjectedBundleNodeHandle::isAutoFillAvailable const):
+        (WebKit::InjectedBundleNodeHandle::setAutoFillAvailable):
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:
+
 2017-09-13  John Wilander  <[email protected]>
 
         Introduce Storage Access API (document parts) as an experimental feature

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp (222012 => 222013)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp	2017-09-14 06:57:12 UTC (rev 222012)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp	2017-09-14 07:01:20 UTC (rev 222013)
@@ -120,6 +120,16 @@
     toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFillButtonEnabled(toAutoFillButtonType(autoFillButtonType));
 }
 
+bool WKBundleNodeHandleGetHTMLInputElementAutoFillAvailable(WKBundleNodeHandleRef htmlInputElementHandleRef)
+{
+    return toImpl(htmlInputElementHandleRef)->isAutoFillAvailable();
+}
+
+void WKBundleNodeHandleSetHTMLInputElementAutoFillAvailable(WKBundleNodeHandleRef htmlInputElementHandleRef, bool autoFillAvailable)
+{
+    toImpl(htmlInputElementHandleRef)->setAutoFillAvailable(autoFillAvailable);
+}
+
 WKRect WKBundleNodeHandleGetHTMLInputElementAutoFillButtonBounds(WKBundleNodeHandleRef htmlInputElementHandleRef)
 {
     return toAPI(toImpl(htmlInputElementHandleRef)->htmlInputElementAutoFillButtonBounds());

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h (222012 => 222013)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h	2017-09-14 06:57:12 UTC (rev 222012)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h	2017-09-14 07:01:20 UTC (rev 222013)
@@ -64,6 +64,8 @@
 WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled);
 WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandle);
 WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabledWithButtonType(WKBundleNodeHandleRef htmlInputElementHandle, WKAutoFillButtonType autoFillButtonType);
+WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutoFillAvailable(WKBundleNodeHandleRef htmlInputElementHandle);
+WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFillAvailable(WKBundleNodeHandleRef htmlInputElementHandle, bool autoFillAvailable);
 WK_EXPORT WKRect WKBundleNodeHandleGetHTMLInputElementAutoFillButtonBounds(WKBundleNodeHandleRef htmlInputElementHandle);
 WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlInputElementHandle);
 

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp (222012 => 222013)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp	2017-09-14 06:57:12 UTC (rev 222012)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp	2017-09-14 07:01:20 UTC (rev 222013)
@@ -271,6 +271,22 @@
     downcast<HTMLInputElement>(m_node.get()).setShowAutoFillButton(autoFillButtonType);
 }
 
+bool InjectedBundleNodeHandle::isAutoFillAvailable() const
+{
+    if (!is<HTMLInputElement>(m_node))
+        return false;
+
+    return downcast<HTMLInputElement>(m_node.get()).isAutoFillAvailable();
+}
+
+void InjectedBundleNodeHandle::setAutoFillAvailable(bool autoFillAvailable)
+{
+    if (!is<HTMLInputElement>(m_node))
+        return;
+
+    downcast<HTMLInputElement>(m_node.get()).setAutoFillAvailable(autoFillAvailable);
+}
+
 IntRect InjectedBundleNodeHandle::htmlInputElementAutoFillButtonBounds()
 {
     if (!is<HTMLInputElement>(m_node))

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h (222012 => 222013)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h	2017-09-14 06:57:12 UTC (rev 222012)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h	2017-09-14 07:01:20 UTC (rev 222013)
@@ -70,6 +70,8 @@
     void setHTMLInputElementAutoFilled(bool);
     bool isHTMLInputElementAutoFillButtonEnabled() const;
     void setHTMLInputElementAutoFillButtonEnabled(WebCore::AutoFillButtonType);
+    bool isAutoFillAvailable() const;
+    void setAutoFillAvailable(bool);
     WebCore::IntRect htmlInputElementAutoFillButtonBounds();
     bool htmlInputElementLastChangeWasUserEdit();
     bool htmlTextAreaElementLastChangeWasUserEdit();

Modified: trunk/Tools/ChangeLog (222012 => 222013)


--- trunk/Tools/ChangeLog	2017-09-14 06:57:12 UTC (rev 222012)
+++ trunk/Tools/ChangeLog	2017-09-14 07:01:20 UTC (rev 222013)
@@ -1,3 +1,25 @@
+2017-09-14  Maureen Daum  <[email protected]>
+
+        Introduce the option to mark an HTML element as having AutoFill available.
+        https://bugs.webkit.org/show_bug.cgi?id=176710
+
+        Reviewed by Alex Christensen.
+
+        Add an API test that verifies after we mark a field as having AutoFill available,
+        Accessibility also considers it to have AutoFill available.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add AutoFillAvailable.mm
+        * TestWebKitAPI/Tests/WebKitCocoa/AutoFillAvailable.mm: Added.
+        Create an input element, mark it as having AutoFill available, then focus it so that
+        we can get the accessibility information for it. Ask accessibility whether it considers
+        the field to have AutoFill available, and pick the alert message based on that.
+        (-[AutoFillAvailable webProcessPlugIn:didCreateBrowserContextController:]):
+        * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
+        (TEST):
+        (-[AutoFillAvailableDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
+        Verify that we get the alert message indicating that accessibility indeed considers
+        the input element as having AutoFill available after we explicitly marked it as so.
+
 2017-09-13  John Wilander  <[email protected]>
 
         Introduce Storage Access API (document parts) as an experimental feature

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (222012 => 222013)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-09-14 06:57:12 UTC (rev 222012)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-09-14 07:01:20 UTC (rev 222013)
@@ -244,6 +244,7 @@
 		6356FB221EC4E0BA0044BF18 /* VisibleContentRect.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6356FB211EC4E0BA0044BF18 /* VisibleContentRect.mm */; };
 		636353A71E98665D0009F8AF /* GeolocationGetCurrentPositionResult.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 636353A61E9861940009F8AF /* GeolocationGetCurrentPositionResult.html */; };
 		6BFD294C1D5E6C1D008EC968 /* HashCountedSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */; };
+		754CEC811F6722F200D0039A /* AutoFillAvailable.mm in Sources */ = {isa = PBXBuildFile; fileRef = 754CEC801F6722DC00D0039A /* AutoFillAvailable.mm */; };
 		755A20AF1E6E38630093C69F /* DatabaseTrackerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 755A20AE1E6E38630093C69F /* DatabaseTrackerTest.cpp */; };
 		764322D71B61CCC30024F801 /* WordBoundaryTypingAttributes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 764322D51B61CCA40024F801 /* WordBoundaryTypingAttributes.mm */; };
 		7673499D1930C5BB00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7673499A1930182E00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp */; };
@@ -1336,6 +1337,7 @@
 		634910DF1E9D3FF300880309 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
 		6356FB211EC4E0BA0044BF18 /* VisibleContentRect.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = VisibleContentRect.mm; sourceTree = "<group>"; };
 		636353A61E9861940009F8AF /* GeolocationGetCurrentPositionResult.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = GeolocationGetCurrentPositionResult.html; sourceTree = "<group>"; };
+		754CEC801F6722DC00D0039A /* AutoFillAvailable.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoFillAvailable.mm; sourceTree = "<group>"; };
 		755A20AE1E6E38630093C69F /* DatabaseTrackerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseTrackerTest.cpp; sourceTree = "<group>"; };
 		7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheAddImageToCacheIOS.mm; sourceTree = "<group>"; };
 		75F3133F18C171B70041CAEC /* EphemeralSessionPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EphemeralSessionPushStateNoHistoryCallback.cpp; sourceTree = "<group>"; };
@@ -1911,6 +1913,7 @@
 				37E7DD651EA0715B009B396D /* AdditionalReadAccessAllowedURLsProtocol.h */,
 				A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */,
 				2DE71AFD1D49C0BD00904094 /* AnimatedResize.mm */,
+				754CEC801F6722DC00D0039A /* AutoFillAvailable.mm */,
 				2DD355351BD08378005DF4A7 /* AutoLayoutIntegration.mm */,
 				374B7A5E1DF36EEE00ACCB6C /* BundleEditingDelegate.mm */,
 				374B7A5F1DF36EEE00ACCB6C /* BundleEditingDelegatePlugIn.mm */,
@@ -3478,6 +3481,7 @@
 				A14FC58B1B89927100D107EB /* ContentFilteringPlugIn.mm in Sources */,
 				A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */,
 				1A4F81CF1BDFFD53004E672E /* RemoteObjectRegistryPlugIn.mm in Sources */,
+				754CEC811F6722F200D0039A /* AutoFillAvailable.mm in Sources */,
 				A12DDC021E837C2400CF6CAE /* RenderedImageWithOptionsPlugIn.mm in Sources */,
 				7C882E091C80C630006BF731 /* UserContentWorldPlugIn.mm in Sources */,
 				7C83E03D1D0A60D600FEBCF3 /* UtilitiesCocoa.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AutoFillAvailable.mm (0 => 222013)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AutoFillAvailable.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AutoFillAvailable.mm	2017-09-14 07:01:20 UTC (rev 222013)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if WK_API_ENABLED && PLATFORM(MAC)
+
+#import <WebKit/WKBundleNodeHandlePrivate.h>
+#import <WebKit/WKBundlePagePrivate.h>
+#import <WebKit/WKDOMDocument.h>
+#import <WebKit/WKDOMElement.h>
+#import <WebKit/WKDOMNodePrivate.h>
+#import <WebKit/WKWebProcessPlugIn.h>
+#import <WebKit/WKWebProcessPlugInBrowserContextControllerPrivate.h>
+#import <WebKit/WKWebProcessPlugInFrame.h>
+#import <WebKit/WKWebProcessPlugInScriptWorld.h>
+
+@interface AutoFillAvailable : NSObject <WKWebProcessPlugIn>
+@end
+
+@implementation AutoFillAvailable
+
+- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController
+{
+    WKDOMDocument *document = [browserContextController mainFrameDocument];
+    WKDOMElement *inputElement = [document createElement:@"input"];
+    [[document body] appendChild:inputElement];
+    WKBundleNodeHandleRef node = [inputElement _copyBundleNodeHandleRef];
+    WKBundleNodeHandleSetHTMLInputElementAutoFillAvailable(node, true);
+    [[[browserContextController mainFrame] jsContextForWorld:[WKWebProcessPlugInScriptWorld normalWorld]] evaluateScript:@"document.getElementsByTagName(\"input\")[0].focus()"];
+
+    void* accessibilityElement = WKAccessibilityFocusedObject([browserContextController _bundlePageRef]);
+    id autofillAvailable = [(id)accessibilityElement accessibilityAttributeValue:@"AXValueAutofillAvailable"];
+
+    NSString *script = [autofillAvailable boolValue] ?  @"alert('autofill available')" : @"alert('autofill not available')";
+    [[[browserContextController mainFrame] jsContextForWorld:[WKWebProcessPlugInScriptWorld normalWorld]] evaluateScript:script];
+}
+
+@end
+
+#endif // WK_API_ENABLED && PLATFORM(MAC)

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm (222012 => 222013)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm	2017-09-14 06:57:12 UTC (rev 222012)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm	2017-09-14 07:01:20 UTC (rev 222013)
@@ -455,6 +455,30 @@
     TestWebKitAPI::Util::run(&done);
 }
 
+@interface AutoFillAvailableDelegate : NSObject <WKUIDelegatePrivate>
+@end
+
+@implementation AutoFillAvailableDelegate
+
+- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)())completionHandler
+{
+    completionHandler();
+    ASSERT_STREQ(message.UTF8String, "autofill available");
+    done = true;
+}
+
+@end
+
+TEST(WebKit, AutoFillAvailable)
+{
+    WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"AutoFillAvailable"];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]);
+    auto delegate = adoptNS([[AutoFillAvailableDelegate alloc] init]);
+    [webView setUIDelegate:delegate.get()];
+    TestWebKitAPI::Util::run(&done);
+}
+
 @interface PinnedStateObserver : NSObject
 @end
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to