AX: Expose strong password fields on iOS
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2018 02:08:16 +0000 (02:08 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2018 02:08:16 +0000 (02:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184465
<rdar://problem/39325104>

Reviewed by Chris Fleizach.

Source/WebCore:

Exposed the strong password field on iOS. And made sure
we are returning its actual value in accessibilityValue.

Test: accessibility/ios-simulator/strong-password-field.html

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper _accessibilityIsStrongPasswordField]):
(-[WebAccessibilityObjectWrapper accessibilityValue]):

Tools:

* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(AccessibilityUIElement::boolAttributeValue):
* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(WTR::AccessibilityUIElement::boolAttributeValue):

LayoutTests:

* accessibility/ios-simulator/strong-password-field-expected.txt: Added.
* accessibility/ios-simulator/strong-password-field.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230510 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/accessibility/ios-simulator/strong-password-field-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/ios-simulator/strong-password-field.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Tools/ChangeLog
Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm

index 4f18046..46952db 100644 (file)
@@ -1,3 +1,14 @@
+2018-04-10  Nan Wang  <n_wang@apple.com>
+
+        AX: Expose strong password fields on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=184465
+        <rdar://problem/39325104>
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/ios-simulator/strong-password-field-expected.txt: Added.
+        * accessibility/ios-simulator/strong-password-field.html: Added.
+
 2018-04-10  Per Arne Vollan  <pvollan@apple.com>
 
         Mark legacy-animation-engine/compositing tests as failures on Windows.
diff --git a/LayoutTests/accessibility/ios-simulator/strong-password-field-expected.txt b/LayoutTests/accessibility/ios-simulator/strong-password-field-expected.txt
new file mode 100644 (file)
index 0000000..0508949
--- /dev/null
@@ -0,0 +1,16 @@
+  
+This tests the strong password fields on iOS
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS axPw1.boolAttributeValue('AXIsStrongPasswordField') is false
+PASS axPw2.boolAttributeValue('AXIsStrongPasswordField') is true
+PASS axPw3.boolAttributeValue('AXIsStrongPasswordField') is true
+PASS axPw1.stringValue is 'AXValue: ••••••••'
+PASS axPw2.stringValue is 'AXValue: strong password'
+PASS axPw3.stringValue is 'AXValue: strong confirmation password'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/ios-simulator/strong-password-field.html b/LayoutTests/accessibility/ios-simulator/strong-password-field.html
new file mode 100644 (file)
index 0000000..bcd4d58
--- /dev/null
@@ -0,0 +1,52 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<meta charset="UTF-8">
+</head>
+<body id="body">
+
+<div id="container">
+<input id="pw1" type="password" value="password">
+<input id="pw2" type="password" value="strong password">
+<input id="pw3" type="password" value="strong confirmation password">
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests the strong password fields on iOS");
+
+    var pw1 = document.getElementById("pw1");
+    var pw2 = document.getElementById("pw2");
+    var pw3 = document.getElementById("pw3");
+
+    if (window.internals) {
+        window.internals.setAutofilled(pw2, true);
+        window.internals.setShowAutoFillButton(pw2, "StrongConfirmationPassword");
+
+        window.internals.setAutofilled(pw3, true);
+        window.internals.setShowAutoFillButton(pw3, "StrongPassword");
+    }
+
+    if (window.accessibilityController) {
+        var axPw1 = accessibilityController.accessibleElementById("pw1");
+        var axPw2 = accessibilityController.accessibleElementById("pw2");
+        var axPw3 = accessibilityController.accessibleElementById("pw3");
+
+        shouldBeFalse("axPw1.boolAttributeValue('AXIsStrongPasswordField')");
+        shouldBeTrue("axPw2.boolAttributeValue('AXIsStrongPasswordField')");
+        shouldBeTrue("axPw3.boolAttributeValue('AXIsStrongPasswordField')");
+
+        shouldBe("axPw1.stringValue", "'AXValue: ••••••••'");
+        shouldBe("axPw2.stringValue", "'AXValue: strong password'");
+        shouldBe("axPw3.stringValue", "'AXValue: strong confirmation password'");
+    }
+    
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index 9be34c6..f4b5d64 100644 (file)
@@ -1,3 +1,20 @@
+2018-04-10  Nan Wang  <n_wang@apple.com>
+
+        AX: Expose strong password fields on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=184465
+        <rdar://problem/39325104>
+
+        Reviewed by Chris Fleizach.
+
+        Exposed the strong password field on iOS. And made sure
+        we are returning its actual value in accessibilityValue.
+
+        Test: accessibility/ios-simulator/strong-password-field.html
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper _accessibilityIsStrongPasswordField]):
+        (-[WebAccessibilityObjectWrapper accessibilityValue]):
+
 2018-04-10  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         [Win] Add UserAgentWin.cpp
index 49d5814..30ec04a 100644 (file)
@@ -1084,6 +1084,18 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
     return m_object->isValueAutofilled();
 }
 
+- (BOOL)_accessibilityIsStrongPasswordField
+{
+    if (![self _prepareAccessibilityCall])
+        return NO;
+    
+    if (!m_object->isPasswordField())
+        return NO;
+    
+    AutoFillButtonType type = m_object->valueAutofillButtonType();
+    return type == AutoFillButtonType::StrongConfirmationPassword || type == AutoFillButtonType::StrongPassword;
+}
+
 - (CGFloat)_accessibilityMinValue
 {
     if (![self _prepareAccessibilityCall])
@@ -1408,7 +1420,7 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
         return [NSString stringWithFormat:@"%d", 1];
 
     // rdar://8131388 WebKit should expose the same info as UIKit for its password fields.
-    if (m_object->isPasswordField()) {
+    if (m_object->isPasswordField() && ![self _accessibilityIsStrongPasswordField]) {
         int passwordLength = m_object->accessibilityPasswordFieldLength();
         NSMutableString* string = [NSMutableString string];
         for (int k = 0; k < passwordLength; ++k)
index 1d6e541..ffc1250 100644 (file)
@@ -1,3 +1,16 @@
+2018-04-10  Nan Wang  <n_wang@apple.com>
+
+        AX: Expose strong password fields on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=184465
+        <rdar://problem/39325104>
+
+        Reviewed by Chris Fleizach.
+
+        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
+        (AccessibilityUIElement::boolAttributeValue):
+        * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+        (WTR::AccessibilityUIElement::boolAttributeValue):
+
 2018-04-10  Zalan Bujtas  <zalan@apple.com>
 
         [LayoutReloaded] Add support for out-of-flow descendants in inline formatting context.
index 8913d19..ff5e486 100644 (file)
@@ -102,6 +102,7 @@ AccessibilityUIElement::~AccessibilityUIElement()
 - (NSUInteger)accessibilityBlockquoteLevel;
 - (NSArray *)accessibilityFindMatchingObjects:(NSDictionary *)parameters;
 - (NSArray *)accessibilitySpeechHint;
+- (BOOL)_accessibilityIsStrongPasswordField;
 
 // TextMarker related
 - (NSArray *)textMarkerRange;
@@ -715,6 +716,8 @@ bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute)
 {
     if (JSStringIsEqualToUTF8CString(attribute, "AXHasTouchEventListener"))
         return [m_element _accessibilityHasTouchEventListener];
+    if (JSStringIsEqualToUTF8CString(attribute, "AXIsStrongPasswordField"))
+        return [m_element _accessibilityIsStrongPasswordField];
     return false;
 }
 
index d0a3c6b..f39647c 100644 (file)
@@ -80,6 +80,7 @@ typedef void (*AXPostedNotificationCallback)(id element, NSString* notification,
 - (NSUInteger)accessibilityBlockquoteLevel;
 - (NSArray *)accessibilityFindMatchingObjects:(NSDictionary *)parameters;
 - (NSArray<NSString *> *)accessibilitySpeechHint;
+- (BOOL)_accessibilityIsStrongPasswordField;
 
 // TextMarker related
 - (NSArray *)textMarkerRange;
@@ -400,6 +401,8 @@ bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute)
 {
     if (JSStringIsEqualToUTF8CString(attribute, "AXHasTouchEventListener"))
         return [m_element _accessibilityHasTouchEventListener];
+    if (JSStringIsEqualToUTF8CString(attribute, "AXIsStrongPasswordField"))
+        return [m_element _accessibilityIsStrongPasswordField];
     return false;
 }