WebKit Bugzilla
Attachment 358572 Details for
Bug 193228
: Web Inspector: Audit: provide a way to query for all nodes with a given computed Accessibility role
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
193228.diff (text/plain), 9.18 KB, created by
Devin Rousso
on 2019-01-07 22:14:55 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2019-01-07 22:14:55 PST
Size:
9.18 KB
patch
obsolete
>diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 50a6f484396..b81fd64dca9 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2019-01-07 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: Audit: provide a way to query for all nodes with a given computed Accessibility role >+ https://bugs.webkit.org/show_bug.cgi?id=193228 >+ <rdar://problem/46787787> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * inspector/audit/run-accessibility.html: Added. >+ * inspector/audit/run-accessibility-expected.txt: Added. >+ > 2019-01-06 Devin Rousso <drousso@apple.com> > > Web Inspector: Audit: create new IDL type for exposing special functionality in test context >diff --git a/LayoutTests/inspector/audit/run-accessibility-expected.txt b/LayoutTests/inspector/audit/run-accessibility-expected.txt >new file mode 100644 >index 00000000000..b79e1a1e3f5 >--- /dev/null >+++ b/LayoutTests/inspector/audit/run-accessibility-expected.txt >@@ -0,0 +1,29 @@ >+Tests for the injected AUDIT.Accessibility functions. >+ >+ >+ >+== Running test suite: Audit.run.Accessibility >+-- Running test case: Audit.run.Accessibility.getElementsByComputedRole.fakeRole >+Audit setup... >+Audit run `AUDIT.Accessibility.getElementsByComputedRole("fakeRole")`... >+Result: [] >+Audit teardown... >+ >+-- Running test case: Audit.run.Accessibility.getElementsByComputedRole.fakeRole.parent >+Audit setup... >+Audit run `AUDIT.Accessibility.getElementsByComputedRole("fakeRole", document.querySelector("#parent"))`... >+Result: [] >+Audit teardown... >+ >+-- Running test case: Audit.run.Accessibility.getElementsByComputedRole.button >+Audit setup... >+Audit run `AUDIT.Accessibility.getElementsByComputedRole("button")`... >+Result: ["#button"] >+Audit teardown... >+ >+-- Running test case: Audit.run.Accessibility.getElementsByComputedRole.button.parent >+Audit setup... >+Audit run `AUDIT.Accessibility.getElementsByComputedRole("button", document.querySelector("#parent"))`... >+Result: [] >+Audit teardown... >+ >diff --git a/LayoutTests/inspector/audit/run-accessibility.html b/LayoutTests/inspector/audit/run-accessibility.html >new file mode 100644 >index 00000000000..7055ed57c77 >--- /dev/null >+++ b/LayoutTests/inspector/audit/run-accessibility.html >@@ -0,0 +1,78 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../http/tests/inspector/resources/inspector-test.js"></script> >+<script src="resources/audit-utilities.js"></script> >+<script> >+ >+function stringify(result) { >+ if (result instanceof Element) >+ return "#" + result.id; >+ if (Array.isArray(result)) >+ return JSON.stringify(result.map(stringify)); >+ return false; >+} >+ >+function test() >+{ >+ async function auditRun(functionString, check) { >+ InspectorTest.log(`Audit run "${functionString}"...`); >+ >+ let {result, wasThrown} = await AuditAgent.run(functionString); >+ InspectorTest.assert(!wasThrown, "Should not throw an exception."); >+ if (!wasThrown) >+ check(result); >+ else >+ InspectorTest.log(result.description); >+ } >+ >+ let suite = InspectorTest.Audit.createSuite("Audit.run.Accessibility"); >+ >+ const tests = [ >+ { func: "getElementsByComputedRole", role: "fakeRole" }, >+ { func: "getElementsByComputedRole", role: "fakeRole", target: "parent" }, >+ { func: "getElementsByComputedRole", role: "button" }, >+ { func: "getElementsByComputedRole", role: "button", target: "parent" }, >+ ]; >+ >+ for (let {func, role, target} of tests) { >+ suite.addTestCase({ >+ name: "Audit.run.Accessibility." + func + (role ? "." + role : "") + (target ? "." + target : ""), >+ async test() { >+ let functionString = null; >+ if (target) { >+ if (role) >+ functionString = `AUDIT.Accessibility.${func}("${role}", document.querySelector("#${target}"))`; >+ else >+ functionString = `AUDIT.Accessibility.${func}(document.querySelector("#${target}"))`; >+ } else if (role) >+ functionString =`AUDIT.Accessibility.${func}("${role}")`; >+ >+ await InspectorTest.Audit.setupAudit(); >+ >+ InspectorTest.log(`Audit run \`${functionString}\`...`); >+ let {result, wasThrown} = await AuditAgent.run(`function() { return stringify(${functionString}); }`); >+ InspectorTest.assert(!wasThrown, "Should not throw an exception."); >+ if (!wasThrown) >+ InspectorTest.log("Result: " + result.value); >+ else >+ InspectorTest.log(result.description); >+ >+ await InspectorTest.Audit.teardownAudit(); >+ }, >+ }); >+ } >+ >+ suite.runTestCasesAndFinish(); >+} >+</script> >+</head> >+<body onload="runTest()"> >+ <p>Tests for the injected AUDIT.Accessibility functions.</p> >+ <ul id="parent" role="tree" aria-activedescendant="child" aria-controls="child" aria-flowto="child" aria-owns="child" onclick="void(0);"> >+ <li id="child" role="treeitem" aria-selected="true"></li> >+ </ul> >+ <button id="button"></button> >+ <div id="fakeRole" role="fakeRole"></div> >+</body> >+</html> >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 4fd67da18d9..1e7a149f4c6 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2019-01-07 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: Audit: provide a way to query for all nodes with a given computed Accessibility role >+ https://bugs.webkit.org/show_bug.cgi?id=193228 >+ <rdar://problem/46787787> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: inspector/audit/run-accessibility.html >+ >+ * inspector/InspectorAuditAccessibilityUtilities.idl: >+ * inspector/InspectorAuditAccessibilityUtilities.h: >+ * inspector/InspectorAuditAccessibilityUtilities.cpp: >+ (WebCore::accessiblityObjectForNode): Added. >+ (WebCore::InspectorAuditAccessibilityUtilities::getElementsByComputedRole): Added. >+ > 2019-01-06 Devin Rousso <drousso@apple.com> > > Web Inspector: Audit: create new IDL type for exposing special functionality in test context >diff --git a/Source/WebCore/inspector/InspectorAuditAccessibilityUtilities.cpp b/Source/WebCore/inspector/InspectorAuditAccessibilityUtilities.cpp >index 0e4ebf85693..e7bd174d62f 100644 >--- a/Source/WebCore/inspector/InspectorAuditAccessibilityUtilities.cpp >+++ b/Source/WebCore/inspector/InspectorAuditAccessibilityUtilities.cpp >@@ -27,10 +27,40 @@ > #include "config.h" > #include "InspectorAuditAccessibilityUtilities.h" > >+#include "AXObjectCache.h" >+#include "AccessibilityObject.h" >+#include "ContainerNode.h" >+#include "Document.h" >+#include "ElementDescendantIterator.h" >+#include "Node.h" >+#include <wtf/Vector.h> >+ > namespace WebCore { > > InspectorAuditAccessibilityUtilities::InspectorAuditAccessibilityUtilities() > { > } > >+static AccessibilityObject* accessiblityObjectForNode(Node& node) >+{ >+ if (!AXObjectCache::accessibilityEnabled()) >+ AXObjectCache::enableAccessibility(); >+ >+ if (AXObjectCache* axObjectCache = node.document().axObjectCache()) >+ return axObjectCache->getOrCreate(&node); >+ return nullptr; >+} >+ >+Vector<Ref<Node>> InspectorAuditAccessibilityUtilities::getElementsByComputedRole(Document& document, const String& role, Node* container) >+{ >+ Vector<Ref<Node>> nodes; >+ for (Element& element : elementDescendants(is<ContainerNode>(container) ? downcast<ContainerNode>(*container) : document)) { >+ if (AccessibilityObject* axObject = accessiblityObjectForNode(element)) { >+ if (axObject->computedRoleString() == role) >+ nodes.append(element); >+ } >+ } >+ return nodes; >+} >+ > } // namespace WebCore >diff --git a/Source/WebCore/inspector/InspectorAuditAccessibilityUtilities.h b/Source/WebCore/inspector/InspectorAuditAccessibilityUtilities.h >index a770a8087a4..95d39c132b5 100644 >--- a/Source/WebCore/inspector/InspectorAuditAccessibilityUtilities.h >+++ b/Source/WebCore/inspector/InspectorAuditAccessibilityUtilities.h >@@ -25,11 +25,15 @@ > > #pragma once > >+#include <wtf/Forward.h> > #include <wtf/Ref.h> > #include <wtf/RefCounted.h> > > namespace WebCore { > >+class Document; >+class Node; >+ > class InspectorAuditAccessibilityUtilities : public RefCounted<InspectorAuditAccessibilityUtilities> { > public: > static Ref<InspectorAuditAccessibilityUtilities> create() >@@ -37,6 +41,8 @@ public: > return adoptRef(*new InspectorAuditAccessibilityUtilities()); > } > >+ Vector<Ref<Node>> getElementsByComputedRole(Document&, const String& role, Node* container); >+ > private: > InspectorAuditAccessibilityUtilities(); > }; >diff --git a/Source/WebCore/inspector/InspectorAuditAccessibilityUtilities.idl b/Source/WebCore/inspector/InspectorAuditAccessibilityUtilities.idl >index 7ccd72bb093..e4cf2e8c9df 100644 >--- a/Source/WebCore/inspector/InspectorAuditAccessibilityUtilities.idl >+++ b/Source/WebCore/inspector/InspectorAuditAccessibilityUtilities.idl >@@ -28,4 +28,5 @@ > JSGenerateToJSObject, > NoInterfaceObject, > ] interface InspectorAuditAccessibilityUtilities { >+ [CallWith=Document] sequence<Node> getElementsByComputedRole(DOMString role, optional Node? container); > };
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
hi
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193228
:
358572
|
358850
|
359148