summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector-protocol/accessibility/accessibility-getAXNode.html
blob: 0759862ff1ab614ef7de6d5d611ba8fb451bcd99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
<script>

function test()
{
    InspectorTest.sendCommand("DOM.getDocument", {}, onGotDocument);

    function onGotDocument(msg)
    {
        if (msg.error) {
            InspectorTest.log(msg.error.message);
            InspectorTest.completeTest();
            return;
        }
        var rootNode = msg.result.root;
        InspectorTest.sendCommand("DOM.querySelector", { "nodeId": rootNode.nodeId, "selector": "input" }, onQuerySelector);
    }

    function onQuerySelector(msg)
    {
        if (msg.error) {
            InspectorTest.log(msg.error.message);
            InspectorTest.completeTest();
            return;
        }
        var node = msg.result;
        InspectorTest.sendCommand("Accessibility.getAXNode", { "nodeId": node.nodeId }, onGotAccessibilityNode.bind(null, node));
    }

    function onGotAccessibilityNode(domNode, msg)
    {
        if (msg.error) {
            InspectorTest.log(msg.error.message);
            InspectorTest.completeTest();
            return;
        }

        // nodeId isn't always the same, so set it to a known value if it's present
        if (msg.result && "accessibilityNode" in msg.result && "nodeId" in msg.result.accessibilityNode)
            msg.result.accessibilityNode.nodeId = "3";

        InspectorTest.log('result: ' + JSON.stringify(msg.result, null, "  "));
        InspectorTest.completeTest();
    }
}

</script>
</head>
<body onLoad="runTest();">
  <input type="text"></input>
</body>
</html>