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..196f7dc4aa260e03a19d34ff87e20333d1367588 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/inspector/elements/accessibility/accessibility-pane-test.js |
| @@ -0,0 +1,135 @@ |
| +var initialize_AccessibilityTest = function() { |
| + |
| +/** |
| + * @return {Promise} |
| + */ |
| +InspectorTest.showAccessibilityView = function() |
| +{ |
| + var sidebarPane = _getAccessibilitySidebarPane(); |
| + if (sidebarPane) { |
| + sidebarPane.requestReveal(); |
| + return Promise.resolve(sidebarPane); |
| + } else { |
| + return _waitForViewsLoaded() |
| + .then(() => { |
|
dgozman
2016/07/25 17:39:38
I think we can just pass result of Promise.all() i
aboxhall
2016/07/25 19:49:19
Hm, I think I need to extra wrapper so that Promis
dgozman
2016/07/25 22:41:53
You are right! I missed that.
|
| + return Promise.all([InspectorTest.waitForAccessibilityNodeUpdate(), |
| + InspectorTest.showAccessibilityView()]); |
| + }); |
| + } |
| +} |
| + |
| + |
| +/** |
| + * @return {Promise} |
| + */ |
| +_waitForViewsLoaded = function() { |
|
dgozman
2016/07/25 17:39:38
InspectorTest._waitForViewsLoaded
aboxhall
2016/07/25 19:49:19
I figured it doesn't need to be accessible outside
dgozman
2016/07/25 22:41:53
It doesn't, but that's how we usually name them. A
|
| + return new Promise(function(resolve, reject) |
| + { |
| + InspectorTest.addSniffer(WebInspector.ElementsPanel.prototype, |
| + "_sidebarViewsLoadedForTest", |
| + () => { resolve(); }); |
|
dgozman
2016/07/25 17:39:38
Can just pass |resolve| as a sniffer.
aboxhall
2016/07/25 19:49:19
Done.
|
| + WebInspector.panels.elements._loadSidebarViews(); |
| + }); |
| +} |
| + |
| +_getAccessibilitySidebarPane = function() |
|
dgozman
2016/07/25 17:39:38
InspectorTest._getAccessibilitySidebarPane
aboxhall
2016/07/25 19:49:19
Similar to above.
|
| +{ |
| + var sidebarViews = WebInspector.panels.elements._elementsSidebarViews; |
| + var sidebarPane = sidebarViews.find((view) => { return view._title === "Accessibility"; }); |
| + return sidebarPane; |
| +} |
| + |
| +/** |
| + * @param {string} idValue |
| + * @return {Promise} |
| + */ |
| +InspectorTest.selectNodeAndWaitForAccessibility = function(idValue) |
| +{ |
| + return Promise.all([InspectorTest.waitForAccessibilityNodeUpdateInARIAPane(), |
| + InspectorTest.waitForAccessibilityNodeUpdate(), |
| + new Promise(function(resolve) { |
| + InspectorTest.selectNodeWithId(idValue, resolve); |
| + })]); |
| +} |
| + |
| +InspectorTest.dumpSelectedElementAccessibilityNode = function() |
| +{ |
| + var sidebarPane = _getAccessibilitySidebarPane(); |
| + |
| + if (!sidebarPane) { |
| + InspectorTest.addResult('No sidebarPane in dumpSelectedElementAccessibilityNode'); |
| + InspectorTest.completeTest(); |
| + return; |
| + } |
| + InspectorTest.dumpAccessibilityNode(sidebarPane._axNodeSubPane._axNode); |
| +} |
| + |
| +/** |
| + * @param {!AccessibilityAgent.AXNode} accessibilityNode |
| + */ |
| +InspectorTest.dumpAccessibilityNode = function(accessibilityNode) |
| +{ |
| + if (!accessibilityNode) { |
| + InspectorTest.addResult("<null>"); |
| + InspectorTest.completeTest(); |
| + return; |
| + } |
| + |
| + var builder = []; |
| + builder.push(accessibilityNode.role.value); |
| + builder.push(accessibilityNode.name ? '"' + accessibilityNode.name.value + '"' |
| + : "<undefined>"); |
| + if ('properties' in accessibilityNode) { |
|
dgozman
2016/07/25 17:39:38
style: double quotes
aboxhall
2016/07/25 19:49:19
Oh, weird presubmit didn't catch that. Fixed.
|
| + for (var property of accessibilityNode.properties) { |
| + if ('value' in property) |
|
dgozman
2016/07/25 17:39:38
ditto
aboxhall
2016/07/25 19:49:19
Done.
|
| + builder.push(property.name + '="' + property.value.value + '"'); |
| + } |
| + } |
| + InspectorTest.addResult(builder.join(" ")); |
| +} |
| + |
| +/** |
| + * @param {string} attribute |
| + * @return {?WebInspector.ARIAAttributesTreeElement} |
| + */ |
| +InspectorTest.findARIAAttributeTreeElement = function(attribute) |
| +{ |
| + var sidebarPane = _getAccessibilitySidebarPane(); |
| + |
| + if (!sidebarPane) { |
| + InspectorTest.completeTest(); |
|
dgozman
2016/07/25 17:39:38
Add error message similar to above.
aboxhall
2016/07/25 19:49:19
Done.
|
| + return; |
| + } |
| + |
| + 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; |
| +} |
| + |
| +/** |
| + * @return {Promise} |
| + */ |
| +InspectorTest.waitForAccessibilityNodeUpdate = function() |
| +{ |
| + return new Promise(function(resolve, reject) |
| + { |
| + InspectorTest.addSniffer(WebInspector.AccessibilitySidebarView.prototype, "_accessibilityNodeUpdatedForTest", resolve); |
| + }); |
| +} |
| + |
| +/** |
| + * @return {Promise} |
| + */ |
| +InspectorTest.waitForAccessibilityNodeUpdateInARIAPane = function() |
| +{ |
| + return new Promise(function(resolve, reject) |
| + { |
| + InspectorTest.addSniffer(WebInspector.ARIAAttributesPane.prototype, "_gotNodeForTest", resolve); |
| + }); |
| +} |
| +}; |