| Index: third_party/WebKit/LayoutTests/inspector-protocol/resources/accessibility-dumpAccessibilityNodes.js
|
| diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/accessibility/accessibility-dumpAccessibilityNodes.js b/third_party/WebKit/LayoutTests/inspector-protocol/resources/accessibility-dumpAccessibilityNodes.js
|
| similarity index 83%
|
| rename from third_party/WebKit/LayoutTests/inspector-protocol/accessibility/accessibility-dumpAccessibilityNodes.js
|
| rename to third_party/WebKit/LayoutTests/inspector-protocol/resources/accessibility-dumpAccessibilityNodes.js
|
| index a933495d11430c467e855ec76f006904ad91676f..dc0259eb468e62dafe822b7c8e7173ac8a7fec56 100644
|
| --- a/third_party/WebKit/LayoutTests/inspector-protocol/accessibility/accessibility-dumpAccessibilityNodes.js
|
| +++ b/third_party/WebKit/LayoutTests/inspector-protocol/resources/accessibility-dumpAccessibilityNodes.js
|
| @@ -2,7 +2,49 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -function initialize_DumpAccessibilityNodesTest() {
|
| +(function initialize_DumpAccessibilityNodesTest(session) {
|
| +
|
| + InspectorTest.trackGetChildNodesEvents = function(nodeInfo, callback)
|
| + {
|
| + session.Protocol.DOM.onSetChildNodes(setChildNodes);
|
| +
|
| + function setChildNodes(message)
|
| + {
|
| + var nodes = message.params.nodes;
|
| + for (var i = 0; i < nodes.length; ++i)
|
| + InspectorTest.addNode(nodeInfo, nodes[i]);
|
| + if (callback)
|
| + callback();
|
| + }
|
| + }
|
| +
|
| + InspectorTest.addNode = function(nodeInfo, node)
|
| + {
|
| + nodeInfo[node.nodeId] = node;
|
| + delete node.nodeId;
|
| + var children = node.children || [];
|
| + for (var i = 0; i < children.length; ++i)
|
| + InspectorTest.addNode(nodeInfo, children[i]);
|
| + var shadowRoots = node.shadowRoots || [];
|
| + for (var i = 0; i < shadowRoots.length; ++i)
|
| + InspectorTest.addNode(nodeInfo, shadowRoots[i]);
|
| + }
|
| +
|
| + InspectorTest.requestDocumentNodeId = async function(callback)
|
| + {
|
| + var result = (await session.Protocol.DOM.getDocument()).result;
|
| + if (callback)
|
| + callback(result.root.nodeId);
|
| + return result.root.nodeId;
|
| + };
|
| +
|
| + InspectorTest.requestNodeId = async function(documentNodeId, selector, callback)
|
| + {
|
| + var result = (await session.Protocol.DOM.querySelector({"nodeId": documentNodeId , "selector": selector})).result;
|
| + if (callback)
|
| + callback(result.nodeId);
|
| + return result.nodeId;
|
| + };
|
|
|
| var nodeInfo = {};
|
| InspectorTest.trackGetChildNodesEvents(nodeInfo);
|
| @@ -27,29 +69,14 @@ InspectorTest.dumpAccessibilityNodesBySelectorAndCompleteTest = function(selecto
|
| .catch((msg) => { InspectorTest.log("Error: " + JSON.stringify(msg)); })
|
| }
|
|
|
| -function sendCommandPromise(command, params)
|
| -{
|
| - return new Promise(function(resolve, reject) {
|
| - InspectorTest.sendCommand(command, params, function(msg) {
|
| - if (msg.error) {
|
| - reject(msg.error);
|
| - return;
|
| - }
|
| -
|
| - resolve(msg);
|
| - })
|
| - });
|
| -}
|
| -
|
| function done()
|
| {
|
| - sendCommandPromise("Runtime.evaluate", { expression: "done();" });
|
| + session.Protocol.Runtime.evaluate({expression: "done();"});
|
| }
|
|
|
| function sendQuerySelectorAll(nodeId, selector)
|
| {
|
| - return sendCommandPromise("DOM.querySelectorAll", { "nodeId": nodeId, "selector":
|
| - selector });
|
| + return session.Protocol.DOM.querySelectorAll({"nodeId": nodeId, "selector": selector });
|
| }
|
|
|
| function getAXNodes(msg, fetchRelatives)
|
| @@ -62,13 +89,13 @@ function getAXNodes(msg, fetchRelatives)
|
| msg.result.nodeIds.forEach((id) => {
|
| if (fetchRelatives) {
|
| promise = promise.then(() => {
|
| - return sendCommandPromise("Accessibility.getPartialAXTree", { "nodeId": id, "fetchRelatives": true });
|
| + return session.Protocol.Accessibility.getPartialAXTree({ "nodeId": id, "fetchRelatives": true });
|
| });
|
| promise = promise.then((msg) => { return rewriteRelatedNodes(msg, id); })
|
| .then((msg) => { return dumpTreeStructure(msg); });
|
|
|
| }
|
| - promise = promise.then(() => { return sendCommandPromise("Accessibility.getPartialAXTree", { "nodeId": id, "fetchRelatives": false }); })
|
| + promise = promise.then(() => { return session.Protocol.Accessibility.getPartialAXTree({ "nodeId": id, "fetchRelatives": false }); })
|
| .then((msg) => { return rewriteRelatedNodes(msg, id); })
|
| .then((msg) => { return dumpNode(msg); });
|
|
|
| @@ -123,7 +150,7 @@ function rewriteBackendDomNodeId(axNode, selectedNodeId, promises)
|
| }
|
|
|
| var params = { "backendNodeIds": [ backendDOMNodeId ] };
|
| - InspectorTest.sendCommand("DOM.pushNodesByBackendIdsToFrontend", params , onDomNodeResolved.bind(null, backendDOMNodeId));
|
| + session.Protocol.DOM.pushNodesByBackendIdsToFrontend(params).then(onDomNodeResolved.bind(null, backendDOMNodeId));
|
| }
|
| promises.push(new Promise(rewriteBackendDomNodeIdPromise));
|
| }
|
| @@ -157,7 +184,7 @@ function rewriteRelatedNode(relatedNode)
|
| resolve();
|
| }
|
| var params = { "backendNodeIds": [ backendDOMNodeId ] };
|
| - InspectorTest.sendCommand("DOM.pushNodesByBackendIdsToFrontend", params, onNodeResolved.bind(null, backendDOMNodeId));
|
| + session.Protocol.DOM.pushNodesByBackendIdsToFrontend(params).then(onNodeResolved.bind(null, backendDOMNodeId));
|
|
|
| }
|
| return new Promise(rewriteRelatedNodePromise);
|
| @@ -323,4 +350,4 @@ function dumpTreeStructure(msg)
|
| InspectorTest.log("\n" + printNodeAndChildren(rootNode));
|
| }
|
|
|
| -}
|
| +})
|
|
|