3 <script type=
"text/javascript" src=
"../../http/tests/inspector-protocol/dom-protocol-test.js"></script>
4 <script type=
"text/javascript" src=
"../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
5 <script type=
"text/javascript" src=
"../../http/tests/inspector-protocol/inspector-test.js"></script>
10 InspectorTest
.sendCommand("DOM.getDocument", {}, onGotDocument
);
12 var numPendingQuerySelectors
= 0;
14 InspectorTest
.trackGetChildNodesEvents(nodeInfo
);
15 function onGotDocument(msg
)
18 InspectorTest
.log(msg
.error
.message
);
19 InspectorTest
.completeTest();
22 var rootNode
= msg
.result
.root
;
24 InspectorTest
.sendCommand("DOM.querySelector", { "nodeId": rootNode
.nodeId
, "selector": "ul#rg1" }, onQuerySelector
);
25 numPendingQuerySelectors
++;
26 InspectorTest
.sendCommand("DOM.querySelector", { "nodeId": rootNode
.nodeId
, "selector": "ul#rg2" }, onQuerySelector
);
27 numPendingQuerySelectors
++;
30 function onQuerySelector(msg
)
33 InspectorTest
.log(msg
.error
.message
);
34 InspectorTest
.completeTest();
37 var node
= msg
.result
;
38 InspectorTest
.sendCommand("Accessibility.getAXNode", { "nodeId": node
.nodeId
}, rewriteNodes
);
41 function describeNode(nodeData
)
43 var description
= nodeData
.nodeName
.toLowerCase();
44 switch (nodeData
.nodeType
) {
45 case Node
.ELEMENT_NODE
:
46 var p
= nodeData
.attributes
.indexOf("id");
48 description
+= "#" + nodeData
.attributes
[p
+ 1];
53 function rewriteNode(relatedNode
)
55 function rewriteNodePromise(resolve
, reject
) {
56 if (!("backendNodeId" in relatedNode
)) {
57 reject("Could not find backendNodeId in " + JSON
.stringify(relatedNode
));
60 var backendNodeId
= relatedNode
.backendNodeId
;
62 function onNodeResolved(backendNodeId
, message
) {
63 var nodeId
= message
.result
.nodeIds
[0];
64 if (!(nodeId
in nodeInfo
)) {
65 relatedNode
.nodeResult
= "[NODE NOT FOUND]";
69 var node
= nodeInfo
[nodeId
];
70 delete relatedNode
.backendNodeId
;
71 relatedNode
.nodeResult
= describeNode(node
);
74 InspectorTest
.sendCommand("DOM.pushNodesByBackendIdsToFrontend", { "backendNodeIds": [ backendNodeId
] }, onNodeResolved
.bind(null, backendNodeId
));
76 return new Promise(rewriteNodePromise
);
79 function checkExists(path
, obj
)
81 var pathComponents
= path
.split(".");
83 var currentObject
= obj
;
84 for (var component
of pathComponents
) {
85 currentPath
.push(component
);
86 if (!(component
in currentObject
)) {
87 InspectorTest
.log("Could not find " + currentPath
.join(".") + " in " + JSON
.stringify(obj
, null, " "));
88 InspectorTest
.completeTest();
90 currentObject
= currentObject
[component
];
94 function check(condition
, errorMsg
, obj
)
98 InspectorTest
.log(errorMsg
+ " in " + JSON
.stringify(obj
, null, " "));
99 InspectorTest
.completeTest();
102 function rewriteNodes(msg
)
105 InspectorTest
.log(msg
.error
.message
);
106 InspectorTest
.completeTest();
110 checkExists("result.accessibilityNode.properties", msg
);
111 var properties
= msg
.result
.accessibilityNode
.properties
;
113 for (var property
of properties
) {
114 if (property
.value
.type
=== "idrefList") {
115 checkExists("value.relatedNodeArrayValue", property
);
116 var relatedNodeArray
= property
.value
.relatedNodeArrayValue
;
117 check(Array
.isArray(relatedNodeArray
), "value.relatedNodeArrayValue should be an array", JSON
.stringify(property
));
118 for (var relatedNode
of relatedNodeArray
) {
119 promises
.push(rewriteNode(relatedNode
));
121 } else if (property
.value
.type
=== "idref") {
122 checkExists("value.relatedNodeValue", property
);
123 var relatedNode
= property
.value
.relatedNodeValue
;
124 promises
.push(rewriteNode(relatedNode
));
130 function stripIds(key
, value
) {
137 InspectorTest
.log(JSON
.stringify(msg
, stripIds
, " "));
138 numPendingQuerySelectors
--;
140 if (!numPendingQuerySelectors
)
141 InspectorTest
.completeTest();
144 function onError(err
)
146 InpectorTest
.log("error: " + JSON
.stringify(err
, null, " "));
147 numPendingQuerySelectors
--;
149 if (!numPendingQuerySelectors
)
150 InspectorTest
.completeTest();
152 Promise
.all(promises
).then(onSuccess
, onError
);
158 <body onLoad=
"runTest();">
159 <h3 id=
"rg1_label">Lunch Options
</h3>
160 <ul id=
"rg1" class=
"radiogroup" role=
"radiogroup" aria-labelledby=
"rg1_label" aria-activedescendant=
"rg1-r4" tabindex=
"0">
161 <li id=
"rg1-r1" tabindex=
"-1" role=
"radio" aria-checked=
"false">
164 <li id=
"rg1-r2" tabindex=
"-1" role=
"radio" aria-checked=
"false">
167 <li id=
"rg1-r3" tabindex=
"-1" role=
"radio" aria-checked=
"false">
170 <li id=
"rg1-r4" tabindex=
"-1" role=
"radio" aria-checked=
"true">
173 <li id=
"rg1-r5" tabindex=
"-1" role=
"radio" aria-checked=
"false">
178 <!-- Start of second Radio Group -->
179 <h3 id=
"rg2_label">Drink Options
</h3>
180 <ul id=
"rg2" role=
"radiogroup" aria-labelledby=
"rg2_label" aria-activedescendant=
"" tabindex=
"0">
181 <li id=
"rg2-r1" tabindex=
"-1" role=
"radio" aria-checked=
"false">
184 <li id=
"rg2-r2" tabindex=
"-1" role=
"radio" aria-checked=
"false">
187 <li id=
"rg2-r3" tabindex=
"-1" role=
"radio" aria-checked=
"false">
190 <li id=
"rg2-r4" tabindex=
"-1" role=
"radio" aria-checked=
"false">
193 <li id=
"rg2-r5" tabindex=
"-1" role=
"radio" aria-checked=
"false">