WebKit Bugzilla
Attachment 359783 Details for
Bug 193227
: Web Inspector: Audit: provide a way to get related Accessibility properties for a given node
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193227-20190122150822.patch (text/plain), 15.20 KB, created by
Devin Rousso
on 2019-01-22 15:08:22 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2019-01-22 15:08:22 PST
Size:
15.20 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d9ef453f48665c98734ef9afb53cddd3db4fbab4..427c1b648c49ddb0873f6726e945b2715d1c033b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,18 @@ >+2019-01-22 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: Audit: provide a way to get related Accessibility properties for a given node >+ https://bugs.webkit.org/show_bug.cgi?id=193227 >+ <rdar://problem/46787862> >+ >+ Reviewed by Joseph Pecoraro. >+ >+ Test: inspector/audit/run-accessibility.html >+ >+ * inspector/InspectorAuditAccessibilityObject.idl: >+ * inspector/InspectorAuditAccessibilityObject.h: >+ * inspector/InspectorAuditAccessibilityObject.cpp: >+ (WebCore::InspectorAuditAccessibilityObject::getComputedProperties): Added. >+ > 2019-01-22 Alex Christensen <achristensen@webkit.org> > > Fix more builds. >diff --git a/Source/WebCore/inspector/InspectorAuditAccessibilityObject.cpp b/Source/WebCore/inspector/InspectorAuditAccessibilityObject.cpp >index 1d8c403de017ef990593a23f877498657f41fa16..1ce5c9a8014d12ba84df348c7ff48ef12ac4892c 100644 >--- a/Source/WebCore/inspector/InspectorAuditAccessibilityObject.cpp >+++ b/Source/WebCore/inspector/InspectorAuditAccessibilityObject.cpp >@@ -36,7 +36,9 @@ > #include "ElementDescendantIterator.h" > #include "HTMLNames.h" > #include "Node.h" >+#include "SpaceSplitString.h" > #include <wtf/Vector.h> >+#include <wtf/text/WTFString.h> > > namespace WebCore { > >@@ -115,6 +117,129 @@ ExceptionOr<Optional<Vector<RefPtr<Node>>>> InspectorAuditAccessibilityObject::g > return result; > } > >+ExceptionOr<Optional<InspectorAuditAccessibilityObject::ComputedProperties>> InspectorAuditAccessibilityObject::getComputedProperties(Node& node) >+{ >+ ERROR_IF_NO_ACTIVE_AUDIT(); >+ >+ Optional<InspectorAuditAccessibilityObject::ComputedProperties> result; >+ >+ if (AccessibilityObject* axObject = accessiblityObjectForNode(node)) { >+ ComputedProperties computedProperties; >+ >+ AccessibilityObject* current = axObject; >+ while (current && (!computedProperties.busy || !computedProperties.busy.value())) { >+ computedProperties.busy = current->isBusy(); >+ current = current->parentObject(); >+ } >+ >+ if (axObject->supportsChecked()) { >+ AccessibilityButtonState checkValue = axObject->checkboxOrRadioValue(); >+ if (checkValue == AccessibilityButtonState::On) >+ computedProperties.checked = "true"_s; >+ else if (checkValue == AccessibilityButtonState::Mixed) >+ computedProperties.checked = "mixed"_s; >+ else if (axObject->isChecked()) >+ computedProperties.checked = "true"_s; >+ else >+ computedProperties.checked = "false"_s; >+ } >+ >+ switch (axObject->currentState()) { >+ case AccessibilityCurrentState::False: >+ computedProperties.currentState = "false"_s; >+ break; >+ case AccessibilityCurrentState::True: >+ computedProperties.currentState = "true"_s; >+ break; >+ case AccessibilityCurrentState::Page: >+ computedProperties.currentState = "page"_s; >+ break; >+ case AccessibilityCurrentState::Step: >+ computedProperties.currentState = "step"_s; >+ break; >+ case AccessibilityCurrentState::Location: >+ computedProperties.currentState = "location"_s; >+ break; >+ case AccessibilityCurrentState::Date: >+ computedProperties.currentState = "date"_s; >+ break; >+ case AccessibilityCurrentState::Time: >+ computedProperties.currentState = "time"_s; >+ break; >+ } >+ >+ computedProperties.disabled = !axObject->isEnabled(); >+ >+ if (axObject->supportsExpanded()) >+ computedProperties.expanded = axObject->isExpanded(); >+ >+ if (is<Element>(node) && axObject->canSetFocusAttribute()) >+ computedProperties.focused = axObject->isFocused(); >+ >+ computedProperties.headingLevel = axObject->headingLevel(); >+ computedProperties.hidden = axObject->isAXHidden() || axObject->isDOMHidden(); >+ computedProperties.hierarchicalLevel = axObject->hierarchicalLevel(); >+ computedProperties.ignored = axObject->accessibilityIsIgnored(); >+ computedProperties.ignoredByDefault = axObject->accessibilityIsIgnoredByDefault(); >+ >+ String invalidValue = axObject->invalidStatus(); >+ if (invalidValue == "false") >+ computedProperties.invalidStatus = "false"_s; >+ else if (invalidValue == "grammar") >+ computedProperties.invalidStatus = "grammar"_s; >+ else if (invalidValue == "spelling") >+ computedProperties.invalidStatus = "spelling"_s; >+ else >+ computedProperties.invalidStatus = "true"_s; >+ >+ computedProperties.isPopUpButton = axObject->isPopUpButton() || axObject->hasPopup(); >+ computedProperties.label = axObject->computedLabel(); >+ >+ if (axObject->supportsLiveRegion()) { >+ computedProperties.liveRegionAtomic = axObject->liveRegionAtomic(); >+ >+ String ariaRelevantAttrValue = axObject->liveRegionRelevant(); >+ if (!ariaRelevantAttrValue.isEmpty()) { >+ Vector<String> liveRegionRelevant; >+ String ariaRelevantAdditions = "additions"; >+ String ariaRelevantRemovals = "removals"; >+ String ariaRelevantText = "text"; >+ >+ const auto& values = SpaceSplitString(ariaRelevantAttrValue, true); >+ if (values.contains("all")) { >+ liveRegionRelevant.append(ariaRelevantAdditions); >+ liveRegionRelevant.append(ariaRelevantRemovals); >+ liveRegionRelevant.append(ariaRelevantText); >+ } else { >+ if (values.contains(ariaRelevantAdditions)) >+ liveRegionRelevant.append(ariaRelevantAdditions); >+ if (values.contains(ariaRelevantRemovals)) >+ liveRegionRelevant.append(ariaRelevantRemovals); >+ if (values.contains(ariaRelevantText)) >+ liveRegionRelevant.append(ariaRelevantText); >+ } >+ computedProperties.liveRegionRelevant = liveRegionRelevant; >+ } >+ >+ computedProperties.liveRegionStatus = axObject->liveRegionStatus(); >+ } >+ >+ computedProperties.pressed = axObject->pressedIsPresent() && axObject->isPressed(); >+ >+ if (axObject->isTextControl()) >+ computedProperties.readonly = !axObject->canSetValueAttribute(); >+ >+ if (axObject->supportsRequiredAttribute()) >+ computedProperties.required = axObject->isRequired(); >+ >+ computedProperties.role = axObject->computedRoleString(); >+ computedProperties.selected = axObject->isSelected(); >+ >+ result = computedProperties; >+ } >+ >+ return result; >+} > > ExceptionOr<Optional<Vector<RefPtr<Node>>>> InspectorAuditAccessibilityObject::getControlledNodes(Node& node) > { >diff --git a/Source/WebCore/inspector/InspectorAuditAccessibilityObject.h b/Source/WebCore/inspector/InspectorAuditAccessibilityObject.h >index 348e6fb5bed34ef0232d8dd60e8f723bd12213da..cbba2b86d8cb3d05e77c6b8879f42b345b168851 100644 >--- a/Source/WebCore/inspector/InspectorAuditAccessibilityObject.h >+++ b/Source/WebCore/inspector/InspectorAuditAccessibilityObject.h >@@ -46,8 +46,34 @@ public: > > ExceptionOr<Vector<Ref<Node>>> getElementsByComputedRole(Document&, const String& role, Node* container); > >+ struct ComputedProperties { >+ Optional<bool> busy; >+ String checked; >+ String currentState; >+ Optional<bool> disabled; >+ Optional<bool> expanded; >+ Optional<bool> focused; >+ Optional<int> headingLevel; >+ Optional<bool> hidden; >+ Optional<int> hierarchicalLevel; >+ Optional<bool> ignored; >+ Optional<bool> ignoredByDefault; >+ String invalidStatus; >+ Optional<bool> isPopUpButton; >+ String label; >+ Optional<bool> liveRegionAtomic; >+ Optional<Vector<String>> liveRegionRelevant; >+ String liveRegionStatus; >+ Optional<bool> pressed; >+ Optional<bool> readonly; >+ Optional<bool> required; >+ String role; >+ Optional<bool> selected; >+ }; >+ > ExceptionOr<RefPtr<Node>> getActiveDescendant(Node&); > ExceptionOr<Optional<Vector<RefPtr<Node>>>> getChildNodes(Node&); >+ ExceptionOr<Optional<ComputedProperties>> getComputedProperties(Node&); > ExceptionOr<Optional<Vector<RefPtr<Node>>>> getControlledNodes(Node&); > ExceptionOr<Optional<Vector<RefPtr<Node>>>> getFlowedNodes(Node&); > ExceptionOr<RefPtr<Node>> getMouseEventNode(Node&); >diff --git a/Source/WebCore/inspector/InspectorAuditAccessibilityObject.idl b/Source/WebCore/inspector/InspectorAuditAccessibilityObject.idl >index 926450f28283bb45ed8719337c0db01ae129f2f0..286d336cb544a410363c4ad2981c2c94ded8959e 100644 >--- a/Source/WebCore/inspector/InspectorAuditAccessibilityObject.idl >+++ b/Source/WebCore/inspector/InspectorAuditAccessibilityObject.idl >@@ -32,6 +32,7 @@ > > [MayThrowException] Node? getActiveDescendant(Node node); > [MayThrowException] sequence<Node>? getChildNodes(Node node); >+ [MayThrowException] ComputedProperties? getComputedProperties(Node node); > [MayThrowException] sequence<Node>? getControlledNodes(Node node); > [MayThrowException] sequence<Node>? getFlowedNodes(Node node); > [MayThrowException] Node? getMouseEventNode(Node node); >@@ -39,3 +40,30 @@ > [MayThrowException] Node? getParentNode(Node node); > [MayThrowException] sequence<Node>? getSelectedChildNodes(Node node); > }; >+ >+[ >+ JSGenerateToJSObject, >+] dictionary ComputedProperties { >+ boolean? busy; >+ DOMString? checked; >+ DOMString? currentState; >+ boolean? disabled; >+ boolean? expanded; >+ boolean? focused; >+ long? headingLevel; >+ boolean? hidden; >+ long? hierarchicalLevel; >+ boolean? ignored; >+ boolean? ignoredByDefault; >+ DOMString? invalidStatus; >+ boolean? isPopUpButton; >+ DOMString? label; >+ boolean? liveRegionAtomic; >+ sequence<DOMString>? liveRegionRelevant; >+ DOMString? liveRegionStatus; >+ boolean? pressed; >+ boolean? readonly; >+ boolean? required; >+ DOMString? role; >+ boolean? selected; >+}; >\ No newline at end of file >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index c90ff2522694442acb58d914bdfd086cff8dc8ec..ac94f22ebec8855fdd93a6e7ef042a8e6715d1d1 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2019-01-22 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: Audit: provide a way to get related Accessibility properties for a given node >+ https://bugs.webkit.org/show_bug.cgi?id=193227 >+ <rdar://problem/46787862> >+ >+ Reviewed by Joseph Pecoraro. >+ >+ * inspector/audit/run-accessibility.html: >+ * inspector/audit/run-accessibility-expected.txt: >+ > 2019-01-22 Michael Catanzaro <mcatanzaro@igalia.com> > > Unreviewed, skip all resource load statistics tests on GTK >diff --git a/LayoutTests/inspector/audit/run-accessibility-expected.txt b/LayoutTests/inspector/audit/run-accessibility-expected.txt >index 7dd1395a5de7dd27c509e1fad439b9449b5fb5c2..55a35307e44f1d4fe4db027aea0fe1eb6faf2f4a 100644 >--- a/LayoutTests/inspector/audit/run-accessibility-expected.txt >+++ b/LayoutTests/inspector/audit/run-accessibility-expected.txt >@@ -63,6 +63,46 @@ Audit run `WebInspectorAudit.Accessibility.getChildNodes(document.querySelector( > Result: [] > Audit teardown... > >+-- Running test case: Audit.run.Accessibility.getComputedProperties.parent >+Audit setup... >+Audit run `WebInspectorAudit.Accessibility.getComputedProperties(document.querySelector("#parent"))`... >+Result: { >+ "busy": false, >+ "currentState": "false", >+ "disabled": false, >+ "headingLevel": 0, >+ "hidden": false, >+ "hierarchicalLevel": 0, >+ "ignored": false, >+ "ignoredByDefault": false, >+ "invalidStatus": "false", >+ "isPopUpButton": false, >+ "pressed": false, >+ "role": "tree", >+ "selected": false >+} >+Audit teardown... >+ >+-- Running test case: Audit.run.Accessibility.getComputedProperties.child >+Audit setup... >+Audit run `WebInspectorAudit.Accessibility.getComputedProperties(document.querySelector("#child"))`... >+Result: { >+ "busy": false, >+ "currentState": "false", >+ "disabled": false, >+ "headingLevel": 0, >+ "hidden": false, >+ "hierarchicalLevel": 1, >+ "ignored": false, >+ "ignoredByDefault": false, >+ "invalidStatus": "false", >+ "isPopUpButton": false, >+ "pressed": false, >+ "role": "treeitem", >+ "selected": true >+} >+Audit teardown... >+ > -- Running test case: Audit.run.Accessibility.getControlledNodes.parent > Audit setup... > Audit run `WebInspectorAudit.Accessibility.getControlledNodes(document.querySelector("#parent"))`... >@@ -114,7 +154,7 @@ Audit teardown... > -- Running test case: Audit.run.Accessibility.getParentNode.parent > Audit setup... > Audit run `WebInspectorAudit.Accessibility.getParentNode(document.querySelector("#parent"))`... >-Result: undefined >+Result: <document> > Audit teardown... > > -- Running test case: Audit.run.Accessibility.getParentNode.child >@@ -148,6 +188,9 @@ 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 getComputedProperties... >+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 >diff --git a/LayoutTests/inspector/audit/run-accessibility.html b/LayoutTests/inspector/audit/run-accessibility.html >index 98b0e5d2bda0dd3f66701b9462fabbc7790b524a..689941a45e4bd189150215ff53592fb3412f8005 100644 >--- a/LayoutTests/inspector/audit/run-accessibility.html >+++ b/LayoutTests/inspector/audit/run-accessibility.html >@@ -6,12 +6,20 @@ > <script> > > function stringify(result) { >+ if (result === null || result === undefined || typeof result === "boolean" || typeof result === "string" || typeof result === "number") >+ return result; > if (result instanceof Element) > return "#" + result.id; >+ if (result instanceof HTMLDocument) >+ return "<document>"; > if (Array.isArray(result)) > return JSON.stringify(result.map(stringify)); >- if (result === null || result === undefined); >- return result; >+ if (typeof result === "object" && result.constructor === Object) { >+ let mapped = {}; >+ for (let key in result) >+ mapped[key] = stringify(result[key]); >+ return JSON.stringify(mapped, null, 4); >+ } > return "UNEXPECTED " + result; > } > >@@ -44,6 +52,9 @@ function test() > { func: "getChildNodes", target: "parent" }, > { func: "getChildNodes", target: "child" }, > >+ { func: "getComputedProperties", target: "parent" }, >+ { func: "getComputedProperties", target: "child" }, >+ > { func: "getControlledNodes", target: "parent" }, > { func: "getControlledNodes", target: "child" }, >
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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193227
:
358569
|
358853
|
359775
| 359783