Diff
Modified: trunk/LayoutTests/ChangeLog (240276 => 240277)
--- trunk/LayoutTests/ChangeLog 2019-01-22 20:51:27 UTC (rev 240276)
+++ trunk/LayoutTests/ChangeLog 2019-01-22 20:52:53 UTC (rev 240277)
@@ -1,3 +1,14 @@
+2019-01-22 Devin Rousso <[email protected]>
+
+ Web Inspector: Audit: provide a way to get related Accessibility nodes for a given node
+ https://bugs.webkit.org/show_bug.cgi?id=193225
+ <rdar://problem/46799956>
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/audit/run-accessibility.html:
+ * inspector/audit/run-accessibility-expected.txt:
+
2019-01-22 Simon Fraser <[email protected]>
Fix the position of layers nested inside of composited overflow-scroll
Modified: trunk/LayoutTests/inspector/audit/run-accessibility-expected.txt (240276 => 240277)
--- trunk/LayoutTests/inspector/audit/run-accessibility-expected.txt 2019-01-22 20:51:27 UTC (rev 240276)
+++ trunk/LayoutTests/inspector/audit/run-accessibility-expected.txt 2019-01-22 20:52:53 UTC (rev 240277)
@@ -39,6 +39,102 @@
Result: []
Audit teardown...
+-- Running test case: Audit.run.Accessibility.getActiveDescendant.parent
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getActiveDescendant(document.querySelector("#parent"))`...
+Result: #child
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getActiveDescendant.child
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getActiveDescendant(document.querySelector("#child"))`...
+Result: null
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getChildNodes.parent
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getChildNodes(document.querySelector("#parent"))`...
+Result: ["#child"]
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getChildNodes.child
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getChildNodes(document.querySelector("#child"))`...
+Result: []
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getControlledNodes.parent
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getControlledNodes(document.querySelector("#parent"))`...
+Result: ["#child"]
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getControlledNodes.child
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getControlledNodes(document.querySelector("#child"))`...
+Result: []
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getFlowedNodes.parent
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getFlowedNodes(document.querySelector("#parent"))`...
+Result: ["#child"]
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getFlowedNodes.child
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getFlowedNodes(document.querySelector("#child"))`...
+Result: []
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getMouseEventNode.parent
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getMouseEventNode(document.querySelector("#parent"))`...
+Result: #parent
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getMouseEventNode.child
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getMouseEventNode(document.querySelector("#child"))`...
+Result: #parent
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getOwnedNodes.parent
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getOwnedNodes(document.querySelector("#parent"))`...
+Result: ["#child"]
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getOwnedNodes.child
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getOwnedNodes(document.querySelector("#child"))`...
+Result: null
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getParentNode.parent
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getParentNode(document.querySelector("#parent"))`...
+Result: undefined
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getParentNode.child
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getParentNode(document.querySelector("#child"))`...
+Result: #parent
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getSelectedChildNodes.parent
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getSelectedChildNodes(document.querySelector("#parent"))`...
+Result: ["#child"]
+Audit teardown...
+
+-- Running test case: Audit.run.Accessibility.getSelectedChildNodes.child
+Audit setup...
+Audit run `WebInspectorAudit.Accessibility.getSelectedChildNodes(document.querySelector("#child"))`...
+Result: []
+Audit teardown...
+
-- Running test case: Audit.run.Accessibility.InvalidCopiedFunctionCall
Audit setup...
Copying WebInspectorAudit to window...
@@ -46,4 +142,28 @@
Testing copied getElementsByComputedRole...
PASS: Should produce an exception.
Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
+Testing copied getActiveDescendant...
+PASS: Should produce an exception.
+Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
+Testing copied getChildNodes...
+PASS: Should produce an exception.
+Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
+Testing copied getControlledNodes...
+PASS: Should produce an exception.
+Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
+Testing copied getFlowedNodes...
+PASS: Should produce an exception.
+Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
+Testing copied getMouseEventNode...
+PASS: Should produce an exception.
+Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
+Testing copied getOwnedNodes...
+PASS: Should produce an exception.
+Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
+Testing copied getParentNode...
+PASS: Should produce an exception.
+Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
+Testing copied getSelectedChildNodes...
+PASS: Should produce an exception.
+Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
Modified: trunk/LayoutTests/inspector/audit/run-accessibility.html (240276 => 240277)
--- trunk/LayoutTests/inspector/audit/run-accessibility.html 2019-01-22 20:51:27 UTC (rev 240276)
+++ trunk/LayoutTests/inspector/audit/run-accessibility.html 2019-01-22 20:52:53 UTC (rev 240277)
@@ -10,7 +10,9 @@
return "#" + result.id;
if (Array.isArray(result))
return JSON.stringify(result.map(stringify));
- return false;
+ if (result === null || result === undefined);
+ return result;
+ return "UNEXPECTED " + result;
}
function test()
@@ -35,6 +37,30 @@
{ func: "getElementsByComputedRole", role: "tree", target: "parent" },
{ func: "getElementsByComputedRole", role: "button" },
{ func: "getElementsByComputedRole", role: "button", target: "parent" },
+
+ { func: "getActiveDescendant", target: "parent" },
+ { func: "getActiveDescendant", target: "child" },
+
+ { func: "getChildNodes", target: "parent" },
+ { func: "getChildNodes", target: "child" },
+
+ { func: "getControlledNodes", target: "parent" },
+ { func: "getControlledNodes", target: "child" },
+
+ { func: "getFlowedNodes", target: "parent" },
+ { func: "getFlowedNodes", target: "child" },
+
+ { func: "getMouseEventNode", target: "parent" },
+ { func: "getMouseEventNode", target: "child" },
+
+ { func: "getOwnedNodes", target: "parent" },
+ { func: "getOwnedNodes", target: "child" },
+
+ { func: "getParentNode", target: "parent" },
+ { func: "getParentNode", target: "child" },
+
+ { func: "getSelectedChildNodes", target: "parent" },
+ { func: "getSelectedChildNodes", target: "child" },
];
for (let {func, target, role} of tests) {
Modified: trunk/Source/WebCore/ChangeLog (240276 => 240277)
--- trunk/Source/WebCore/ChangeLog 2019-01-22 20:51:27 UTC (rev 240276)
+++ trunk/Source/WebCore/ChangeLog 2019-01-22 20:52:53 UTC (rev 240277)
@@ -1,3 +1,26 @@
+2019-01-22 Devin Rousso <[email protected]>
+
+ Web Inspector: Audit: provide a way to get related Accessibility nodes for a given node
+ https://bugs.webkit.org/show_bug.cgi?id=193225
+ <rdar://problem/46799956>
+
+ Reviewed by Joseph Pecoraro.
+
+ Test: inspector/audit/run-accessibility.html
+
+ * inspector/InspectorAuditAccessibilityObject.idl:
+ * inspector/InspectorAuditAccessibilityObject.h:
+ * inspector/InspectorAuditAccessibilityObject.cpp:
+ (WebCore::InspectorAuditAccessibilityObject::getActiveDescendant): Added.
+ (WebCore::addChildren): Added.
+ (WebCore::InspectorAuditAccessibilityObject::getChildNodes): Added.
+ (WebCore::InspectorAuditAccessibilityObject::getControlledNodes): Added.
+ (WebCore::InspectorAuditAccessibilityObject::getFlowedNodes): Added.
+ (WebCore::InspectorAuditAccessibilityObject::getMouseEventNode): Added.
+ (WebCore::InspectorAuditAccessibilityObject::getOwnedNodes): Added.
+ (WebCore::InspectorAuditAccessibilityObject::getParentNode): Added.
+ (WebCore::InspectorAuditAccessibilityObject::getSelectedChildNodes): Added.
+
2019-01-22 David Kilzer <[email protected]>
Switch remaining QuickLook soft-linking in WebCore, WebKit over to QuickLookSoftLink.{cpp,h}
Modified: trunk/Source/WebCore/inspector/InspectorAuditAccessibilityObject.cpp (240276 => 240277)
--- trunk/Source/WebCore/inspector/InspectorAuditAccessibilityObject.cpp 2019-01-22 20:51:27 UTC (rev 240276)
+++ trunk/Source/WebCore/inspector/InspectorAuditAccessibilityObject.cpp 2019-01-22 20:52:53 UTC (rev 240277)
@@ -28,10 +28,13 @@
#include "InspectorAuditAccessibilityObject.h"
#include "AXObjectCache.h"
+#include "AccessibilityNodeObject.h"
#include "AccessibilityObject.h"
#include "ContainerNode.h"
#include "Document.h"
+#include "Element.h"
#include "ElementDescendantIterator.h"
+#include "HTMLNames.h"
#include "Node.h"
#include <wtf/Vector.h>
@@ -75,4 +78,156 @@
return nodes;
}
+ExceptionOr<RefPtr<Node>> InspectorAuditAccessibilityObject::getActiveDescendant(Node& node)
+{
+ ERROR_IF_NO_ACTIVE_AUDIT();
+
+ if (AccessibilityObject* axObject = accessiblityObjectForNode(node)) {
+ if (AccessibilityObject* activeDescendant = axObject->activeDescendant())
+ return activeDescendant->node();
+ }
+
+ return nullptr;
+}
+
+static void addChildren(AccessibilityObject& parentObject, Vector<RefPtr<Node>>& childNodes)
+{
+ for (const RefPtr<AccessibilityObject>& childObject : parentObject.children()) {
+ if (Node* childNode = childObject->node())
+ childNodes.append(childNode);
+ else
+ addChildren(*childObject, childNodes);
+ }
+}
+
+ExceptionOr<Optional<Vector<RefPtr<Node>>>> InspectorAuditAccessibilityObject::getChildNodes(Node& node)
+{
+ ERROR_IF_NO_ACTIVE_AUDIT();
+
+ Optional<Vector<RefPtr<Node>>> result;
+
+ if (AccessibilityObject* axObject = accessiblityObjectForNode(node)) {
+ Vector<RefPtr<Node>> childNodes;
+ addChildren(*axObject, childNodes);
+ result = WTFMove(childNodes);
+ }
+
+ return result;
+}
+
+
+ExceptionOr<Optional<Vector<RefPtr<Node>>>> InspectorAuditAccessibilityObject::getControlledNodes(Node& node)
+{
+ ERROR_IF_NO_ACTIVE_AUDIT();
+
+ Optional<Vector<RefPtr<Node>>> result;
+
+ if (AccessibilityObject* axObject = accessiblityObjectForNode(node)) {
+ Vector<RefPtr<Node>> controlledNodes;
+
+ Vector<Element*> controlledElements;
+ axObject->elementsFromAttribute(controlledElements, HTMLNames::aria_controlsAttr);
+ for (Element* controlledElement : controlledElements) {
+ if (controlledElement)
+ controlledNodes.append(controlledElement);
+ }
+
+ result = WTFMove(controlledNodes);
+ }
+
+ return result;
+}
+
+ExceptionOr<Optional<Vector<RefPtr<Node>>>> InspectorAuditAccessibilityObject::getFlowedNodes(Node& node)
+{
+ ERROR_IF_NO_ACTIVE_AUDIT();
+
+ Optional<Vector<RefPtr<Node>>> result;
+
+ if (AccessibilityObject* axObject = accessiblityObjectForNode(node)) {
+ Vector<RefPtr<Node>> flowedNodes;
+
+ Vector<Element*> flowedElements;
+ axObject->elementsFromAttribute(flowedElements, HTMLNames::aria_flowtoAttr);
+ for (Element* flowedElement : flowedElements) {
+ if (flowedElement)
+ flowedNodes.append(flowedElement);
+ }
+
+ result = WTFMove(flowedNodes);
+ }
+
+ return result;
+}
+
+ExceptionOr<RefPtr<Node>> InspectorAuditAccessibilityObject::getMouseEventNode(Node& node)
+{
+ ERROR_IF_NO_ACTIVE_AUDIT();
+
+ if (AccessibilityObject* axObject = accessiblityObjectForNode(node)) {
+ if (is<AccessibilityNodeObject>(axObject))
+ return downcast<AccessibilityNodeObject>(axObject)->mouseButtonListener(MouseButtonListenerResultFilter::IncludeBodyElement);
+ }
+
+ return nullptr;
+}
+
+ExceptionOr<Optional<Vector<RefPtr<Node>>>> InspectorAuditAccessibilityObject::getOwnedNodes(Node& node)
+{
+ ERROR_IF_NO_ACTIVE_AUDIT();
+
+ Optional<Vector<RefPtr<Node>>> result;
+
+ if (AccessibilityObject* axObject = accessiblityObjectForNode(node)) {
+ if (axObject->supportsARIAOwns()) {
+ Vector<RefPtr<Node>> ownedNodes;
+
+ Vector<Element*> ownedElements;
+ axObject->elementsFromAttribute(ownedElements, HTMLNames::aria_ownsAttr);
+ for (Element* ownedElement : ownedElements) {
+ if (ownedElement)
+ ownedNodes.append(ownedElement);
+ }
+
+ result = WTFMove(ownedNodes);
+ }
+ }
+
+ return result;
+}
+
+ExceptionOr<RefPtr<Node>> InspectorAuditAccessibilityObject::getParentNode(Node& node)
+{
+ ERROR_IF_NO_ACTIVE_AUDIT();
+
+ if (AccessibilityObject* axObject = accessiblityObjectForNode(node)) {
+ if (AccessibilityObject* parentObject = axObject->parentObjectUnignored())
+ return parentObject->node();
+ }
+
+ return nullptr;
+}
+
+ExceptionOr<Optional<Vector<RefPtr<Node>>>> InspectorAuditAccessibilityObject::getSelectedChildNodes(Node& node)
+{
+ ERROR_IF_NO_ACTIVE_AUDIT();
+
+ Optional<Vector<RefPtr<Node>>> result;
+
+ if (AccessibilityObject* axObject = accessiblityObjectForNode(node)) {
+ Vector<RefPtr<Node>> selectedChildNodes;
+
+ AccessibilityObject::AccessibilityChildrenVector selectedChildren;
+ axObject->selectedChildren(selectedChildren);
+ for (RefPtr<AccessibilityObject>& selectedChildObject : selectedChildren) {
+ if (Node* selectedChildNode = selectedChildObject->node())
+ selectedChildNodes.append(selectedChildNode);
+ }
+
+ result = WTFMove(selectedChildNodes);
+ }
+
+ return result;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/InspectorAuditAccessibilityObject.h (240276 => 240277)
--- trunk/Source/WebCore/inspector/InspectorAuditAccessibilityObject.h 2019-01-22 20:51:27 UTC (rev 240276)
+++ trunk/Source/WebCore/inspector/InspectorAuditAccessibilityObject.h 2019-01-22 20:52:53 UTC (rev 240277)
@@ -28,6 +28,7 @@
#include "ExceptionOr.h"
#include <_javascript_Core/InspectorAuditAgent.h>
#include <wtf/Forward.h>
+#include <wtf/Optional.h>
#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
@@ -45,6 +46,15 @@
ExceptionOr<Vector<Ref<Node>>> getElementsByComputedRole(Document&, const String& role, Node* container);
+ ExceptionOr<RefPtr<Node>> getActiveDescendant(Node&);
+ ExceptionOr<Optional<Vector<RefPtr<Node>>>> getChildNodes(Node&);
+ ExceptionOr<Optional<Vector<RefPtr<Node>>>> getControlledNodes(Node&);
+ ExceptionOr<Optional<Vector<RefPtr<Node>>>> getFlowedNodes(Node&);
+ ExceptionOr<RefPtr<Node>> getMouseEventNode(Node&);
+ ExceptionOr<Optional<Vector<RefPtr<Node>>>> getOwnedNodes(Node&);
+ ExceptionOr<RefPtr<Node>> getParentNode(Node&);
+ ExceptionOr<Optional<Vector<RefPtr<Node>>>> getSelectedChildNodes(Node&);
+
private:
explicit InspectorAuditAccessibilityObject(Inspector::InspectorAuditAgent&);
Modified: trunk/Source/WebCore/inspector/InspectorAuditAccessibilityObject.idl (240276 => 240277)
--- trunk/Source/WebCore/inspector/InspectorAuditAccessibilityObject.idl 2019-01-22 20:51:27 UTC (rev 240276)
+++ trunk/Source/WebCore/inspector/InspectorAuditAccessibilityObject.idl 2019-01-22 20:52:53 UTC (rev 240277)
@@ -29,4 +29,13 @@
NoInterfaceObject,
] interface InspectorAuditAccessibilityObject {
[CallWith=Document, MayThrowException] sequence<Node> getElementsByComputedRole(DOMString role, optional Node? container);
+
+ [MayThrowException] Node? getActiveDescendant(Node node);
+ [MayThrowException] sequence<Node>? getChildNodes(Node node);
+ [MayThrowException] sequence<Node>? getControlledNodes(Node node);
+ [MayThrowException] sequence<Node>? getFlowedNodes(Node node);
+ [MayThrowException] Node? getMouseEventNode(Node node);
+ [MayThrowException] sequence<Node>? getOwnedNodes(Node node);
+ [MayThrowException] Node? getParentNode(Node node);
+ [MayThrowException] sequence<Node>? getSelectedChildNodes(Node node);
};