Title: [295553] trunk
Revision
295553
Author
[email protected]
Date
2022-06-14 23:38:29 -0700 (Tue, 14 Jun 2022)

Log Message

AX: AccessibilityObject::insertText does not insert any text into password fields
https://bugs.webkit.org/show_bug.cgi?id=241613

Reviewed by Chris Fleizach and Andres Gonzalez.

Prior to this patch, AccessibilityObject::insertText used to return
early if Element::shouldUseInputMethod returned false. We need to
exclude password fields from this check, which this patch implements.

* LayoutTests/accessibility/insert-text-into-password-field-expected.txt: Added.
* LayoutTests/accessibility/insert-text-into-password-field.html: Added.
* LayoutTests/platform/glib/TestExpectations: Disable new test.
* LayoutTests/platform/ios/TestExpectations: Enable new test.
* LayoutTests/platform/win/TestExpectations: Disable new test.
* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::insertText):

Canonical link: https://commits.webkit.org/251558@main

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/accessibility/insert-text-into-password-field-expected.txt (0 => 295553)


--- trunk/LayoutTests/accessibility/insert-text-into-password-field-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/insert-text-into-password-field-expected.txt	2022-06-15 06:38:29 UTC (rev 295553)
@@ -0,0 +1,8 @@
+This test ensures that inserting text into a password field works.
+
+Focusing #password-input, and then inserting text 'foo' into it.
+#password-input AXValue: •••
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/insert-text-into-password-field.html (0 => 295553)


--- trunk/LayoutTests/accessibility/insert-text-into-password-field.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/insert-text-into-password-field.html	2022-06-15 06:38:29 UTC (rev 295553)
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+
+<input type="password" id="password-input">
+
+<script>
+    var testOutput = "This test ensures that inserting text into a password field works.\n\n";
+
+    if (window.accessibilityController) {
+        testOutput += "Focusing #password-input, and then inserting text 'foo' into it.\n";
+        // Put focus into the password input so `insertText` has a target.
+        document.getElementById("password-input").focus();
+        var passwordInput = accessibilityController.accessibleElementById("password-input");
+        passwordInput.insertText("foo");
+
+        testOutput += `#password-input ${passwordInput.stringValue}`;
+        debug(testOutput);
+    }
+</script>
+</body>
+</html>
+

Modified: trunk/LayoutTests/platform/glib/TestExpectations (295552 => 295553)


--- trunk/LayoutTests/platform/glib/TestExpectations	2022-06-15 05:57:05 UTC (rev 295552)
+++ trunk/LayoutTests/platform/glib/TestExpectations	2022-06-15 06:38:29 UTC (rev 295553)
@@ -336,6 +336,9 @@
 
 accessibility/svg-font-face.html [ Skip ]
 
+# Need to implement AccessibilityUIElement::insertText.
+accessibility/insert-text-into-password-field.html [ Skip ]
+
 # Need to implement AccessibilityUIElement::hasDocumentRoleAncestor(), AccessibilityUIElement::hasWebApplicationAncestor(),
 # AccessibilityUIElement::isInDescriptionListDetail(), AccessibilityUIElement::isInDescriptionListTerm(), and
 # AccessibilityUIElement::isInCell().

Modified: trunk/LayoutTests/platform/ios/TestExpectations (295552 => 295553)


--- trunk/LayoutTests/platform/ios/TestExpectations	2022-06-15 05:57:05 UTC (rev 295552)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2022-06-15 06:38:29 UTC (rev 295553)
@@ -2133,6 +2133,7 @@
 accessibility/display-contents-element-roles.html [ Pass ]
 accessibility/element-haspopup.html [ Pass ]
 accessibility/heading-level.html [ Pass ]
+accessibility/insert-text-into-password-field.html [ Pass ]
 accessibility/list-with-dynamically-changing-content.html [ Pass ]
 accessibility/live-region-attributes-update-after-dynamic-change.html [ Pass ]
 accessibility/node-only-inert-object.html [ Pass ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (295552 => 295553)


--- trunk/LayoutTests/platform/win/TestExpectations	2022-06-15 05:57:05 UTC (rev 295552)
+++ trunk/LayoutTests/platform/win/TestExpectations	2022-06-15 06:38:29 UTC (rev 295553)
@@ -484,6 +484,9 @@
 accessibility/visible-character-range-scrolling.html [ Skip ]
 accessibility/visible-character-range-width-changes.html [ Skip ]
 
+# Need to implement AccessibilityUIElement::insertText.
+accessibility/insert-text-into-password-field.html [ Skip ]
+
 # Need to implement AccessibilityUIElement::hasDocumentRoleAncestor(), AccessibilityUIElement::hasWebApplicationAncestor(),
 # AccessibilityUIElement::isInDescriptionListDetail(), AccessibilityUIElement::isInDescriptionListTerm(), and
 # AccessibilityUIElement::isInCell().

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (295552 => 295553)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2022-06-15 05:57:05 UTC (rev 295552)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2022-06-15 06:38:29 UTC (rev 295553)
@@ -2369,9 +2369,8 @@
         return false;
 
     auto& element = downcast<Element>(*renderer()->node());
-
-    // Only try to insert text if the field is in editing mode.
-    if (!element.shouldUseInputMethod())
+    // Only try to insert text if the field is in editing mode (excluding password fields, which we do still want to try to insert into).
+    if (!isPasswordField() && !element.shouldUseInputMethod())
         return false;
 
     // Use Editor::insertText to mimic typing into the field.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to