AX: Cannot call setValue() on contenteditable or ARIA text controls
https://bugs.webkit.org/show_bug.cgi?id=173520
Reviewed by Ryosuke Niwa.
Source/WebCore:
Add support for changing the value of a contenteditable and any other aria text control in setValue().
Test: accessibility/mac/set-value-editable-types.html
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::setValue):
Tools:
Add setValue() method to WKTR (already existed in DRT).
* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
(WTR::AccessibilityUIElement::setValue):
* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
* WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::AccessibilityUIElement::setValue):
LayoutTests:
* accessibility/mac/set-value-editable-types-expected.txt: Added.
* accessibility/mac/set-value-editable-types.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@218783 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 53fb721..dd4edfb 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2017-06-24 Chris Fleizach <cfleizach@apple.com>
+
+ AX: Cannot call setValue() on contenteditable or ARIA text controls
+ https://bugs.webkit.org/show_bug.cgi?id=173520
+
+ Reviewed by Ryosuke Niwa.
+
+ * accessibility/mac/set-value-editable-types-expected.txt: Added.
+ * accessibility/mac/set-value-editable-types.html: Added.
+
2017-06-23 Chris Dumez <cdumez@apple.com>
fast/events/page-visibility-iframe-delete-test.html is flaky
diff --git a/LayoutTests/accessibility/mac/set-value-editable-types-expected.txt b/LayoutTests/accessibility/mac/set-value-editable-types-expected.txt
new file mode 100644
index 0000000..54712e6
--- /dev/null
+++ b/LayoutTests/accessibility/mac/set-value-editable-types-expected.txt
@@ -0,0 +1,16 @@
+This tests that you can set the value of a contenteditable element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Contenteditable
+Role: AXRole: AXTextArea
+Value: AXValue: current1
+Writable: true
+Value change notification received
+Updated Value: AXValue: new value
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/mac/set-value-editable-types.html b/LayoutTests/accessibility/mac/set-value-editable-types.html
new file mode 100644
index 0000000..5905f88
--- /dev/null
+++ b/LayoutTests/accessibility/mac/set-value-editable-types.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<body id="body">
+<script src="../../resources/js-test-pre.js"></script>
+<div id="content">
+
+<div contenteditable="true" id="contenteditable">current1</div>
+
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+ description("This tests that you can set the value of a contenteditable element.");
+
+ if (window.accessibilityController) {
+ jsTestIsAsync = true;
+
+ accessibilityController.addNotificationListener(function(element, notification) {
+ if (notification == "AXValueChanged") {
+ debug("Value change notification received");
+ var axElement = accessibilityController.accessibleElementById("contenteditable");
+ debug("Updated Value: " + axElement.stringValue);
+ document.getElementById("content").style.visibility = "hidden";
+ finishJSTest();
+ accessibilityController.removeNotificationListener();
+ }
+ });
+
+ function testElement(idValue) {
+ var axElement = accessibilityController.accessibleElementById(idValue);
+ debug("Role: " + axElement.role);
+ debug("Value: " + axElement.stringValue);
+
+ var writable = axElement.isAttributeSettable("AXValue");
+ debug("Writable: " + writable);
+
+ axElement.setValue("new value");
+ }
+
+ debug("\nContenteditable");
+ testElement("contenteditable");
+
+ } else {
+ testFailed("Could not load accessibility controller");
+ }
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 14304d7..a61e66e 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2017-06-24 Chris Fleizach <cfleizach@apple.com>
+
+ AX: Cannot call setValue() on contenteditable or ARIA text controls
+ https://bugs.webkit.org/show_bug.cgi?id=173520
+
+ Reviewed by Ryosuke Niwa.
+
+ Add support for changing the value of a contenteditable and any other aria text control in setValue().
+
+ Test: accessibility/mac/set-value-editable-types.html
+
+ * accessibility/AccessibilityRenderObject.cpp:
+ (WebCore::AccessibilityRenderObject::setValue):
+
2017-06-23 Simon Fraser <simon.fraser@apple.com>
Attempt to fix an internal build after r218755.
diff --git a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
index 0a8bfe2..4f0dd0e 100644
--- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
+++ b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
@@ -1743,16 +1743,15 @@
if (!m_renderer || !is<Element>(m_renderer->node()))
return;
Element& element = downcast<Element>(*m_renderer->node());
-
- if (!is<RenderBoxModelObject>(*m_renderer))
- return;
- RenderBoxModelObject& renderer = downcast<RenderBoxModelObject>(*m_renderer);
-
+ RenderObject& renderer = *m_renderer;
+
// FIXME: Do we want to do anything here for ARIA textboxes?
if (renderer.isTextField() && is<HTMLInputElement>(element))
downcast<HTMLInputElement>(element).setValue(string);
else if (renderer.isTextArea() && is<HTMLTextAreaElement>(element))
downcast<HTMLTextAreaElement>(element).setValue(string);
+ else if (is<HTMLElement>(element) && contentEditableAttributeIsEnabled(&element))
+ downcast<HTMLElement>(element).setInnerText(string);
}
bool AccessibilityRenderObject::supportsARIAOwns() const
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index d7cdba5..3fff50c 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,19 @@
+2017-06-24 Chris Fleizach <cfleizach@apple.com>
+
+ AX: Cannot call setValue() on contenteditable or ARIA text controls
+ https://bugs.webkit.org/show_bug.cgi?id=173520
+
+ Reviewed by Ryosuke Niwa.
+
+ Add setValue() method to WKTR (already existed in DRT).
+
+ * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
+ (WTR::AccessibilityUIElement::setValue):
+ * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
+ * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
+ * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+ (WTR::AccessibilityUIElement::setValue):
+
2017-06-23 Keith Miller <keith_miller@apple.com>
Switch VMTraps to use halt instructions rather than breakpoint instructions
diff --git a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp b/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp
index 25814e4..95cd26a 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp
+++ b/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp
@@ -89,6 +89,7 @@
RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::selectedTextMarkerRange() { return nullptr; }
void AccessibilityUIElement::resetSelectedTextMarkerRange() { }
void AccessibilityUIElement::setBoolAttributeValue(JSStringRef, bool) { }
+void AccessibilityUIElement::setValue(JSStringRef) { }
#endif
#if !PLATFORM(COCOA) || !HAVE(ACCESSIBILITY)
diff --git a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h b/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
index 4dfdbdd..ceac49e 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
+++ b/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
@@ -110,6 +110,7 @@
bool isPressActionSupported();
bool isIncrementActionSupported();
bool isDecrementActionSupported();
+ void setValue(JSStringRef);
JSRetainPtr<JSStringRef> role();
JSRetainPtr<JSStringRef> subrole();
JSRetainPtr<JSStringRef> roleDescription();
diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl
index c50d68f..8b9820a 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl
+++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl
@@ -69,6 +69,7 @@
boolean isPressActionSupported();
boolean isIncrementActionSupported();
boolean isDecrementActionSupported();
+ void setValue(DOMString value);
readonly attribute DOMString stringValue;
readonly attribute long intValue;
diff --git a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm b/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
index a4966af4..4a97a81 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
+++ b/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
@@ -589,7 +589,14 @@
[m_element _accessibilitySetTestValue:@(value) forAttribute:[NSString stringWithJSStringRef:attribute]];
END_AX_OBJC_EXCEPTIONS
}
-
+
+void AccessibilityUIElement::setValue(JSStringRef value)
+{
+ BEGIN_AX_OBJC_EXCEPTIONS
+ [m_element accessibilitySetValue:[NSString stringWithJSStringRef:value] forAttribute:NSAccessibilityValueAttribute];
+ END_AX_OBJC_EXCEPTIONS
+}
+
bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute)
{
BEGIN_AX_OBJC_EXCEPTIONS