Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/inspector/elements/accessibility/accessibility-pane-test.js |
| diff --git a/third_party/WebKit/LayoutTests/inspector/elements/accessibility/accessibility-pane-test.js b/third_party/WebKit/LayoutTests/inspector/elements/accessibility/accessibility-pane-test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d10da8679d500da9ad2d5d472ef3c75784112eca |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/inspector/elements/accessibility/accessibility-pane-test.js |
| @@ -0,0 +1,87 @@ |
| +var initialize_AccessibilityTest = function() { |
| + |
| +var sidebarPane; |
| + |
| +InspectorTest.showAccessibilityWidget = function() |
| +{ |
| + var sidebarPaneWrappers = WebInspector.panels.elements._elementsSidebarViewWrappers; |
|
dgozman
2016/07/22 16:44:29
These panes are loaded asynchronously. We should w
|
| + var sidebarPaneWrapper = sidebarPaneWrappers.find((wrapper) => { return wrapper._title === "Accessibility"; }); |
| + |
| + sidebarPaneWrapper.expandPane(); |
| + sidebarPane = sidebarPaneWrapper.children()[0]; |
| +} |
| + |
| +/** |
| + * @param {string} idValue |
| + * @param {function(!WebInspector.DOMNode)} callback |
| + */ |
| +InspectorTest.selectNodeAndWaitForAccessibility = function(idValue, callback) |
| +{ |
| + callback = InspectorTest.safeWrap(callback); |
| + |
| + var targetNode; |
| + |
| + InspectorTest.selectNodeWithId(idValue, nodeSelected); |
| + InspectorTest.waitForAccessibilityNodeUpdate(callback); |
| + |
| + /** |
| + * @param {!WebInspector.DOMNode} node |
| + */ |
| + function nodeSelected(node) |
| + { |
| + targetNode = node; |
| + } |
| +} |
| + |
| +InspectorTest.dumpSelectedElementAccessibilityNode = function() |
| +{ |
| + if (!sidebarPane) |
| + InspectorTest.showAccessibilityWidget(); |
| + |
| + InspectorTest.dumpAccessibilityNode(sidebarPane._axNodeSubPane._axNode); |
| +} |
| + |
| +/** |
| + * @param {!AccessibilityAgent.AXNode} accessibilityNode |
| + */ |
| +InspectorTest.dumpAccessibilityNode = function(accessibilityNode) |
| +{ |
| + if (!accessibilityNode) { |
| + InspectorTest.addResult("<null>"); |
| + return; |
| + } |
| + var builder = []; |
| + builder.push(accessibilityNode.role.value); |
| + builder.push('"' + accessibilityNode.name.value + '"'); |
| + |
| + for (var property of accessibilityNode.properties) |
| + builder.push(property.name + '="' + property.value.value + '"'); |
| + |
| + InspectorTest.addResult(builder.join(" ")); |
| +} |
| + |
| +/** |
| + * @param {!AccessibilitySidebarView} sidebarPane |
| + * @param {string} attribute |
| + * @return {?WebInspector.ARIAAttributesTreeElement} |
| + */ |
| +InspectorTest.findARIAAttributeTreeElement = function(attribute) |
| +{ |
| + var ariaSubPane = sidebarPane._ariaSubPane; |
| + var treeOutline = ariaSubPane._treeOutline; |
| + var childNodes = treeOutline._rootElement._children; |
| + for (var treeElement of childNodes) { |
| + if (treeElement._attribute.name === attribute) |
| + return treeElement; |
| + } |
| + return null; |
| +} |
| + |
| +/** |
| + * @param {function()} callback |
| + */ |
| +InspectorTest.waitForAccessibilityNodeUpdate = function(callback) |
| +{ |
| + InspectorTest.addSniffer(WebInspector.AccessibilitySidebarView.prototype, "_accessibilityNodeUpdatedForTest", callback); |
| +} |
| +}; |