Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / accessibility / accessibility-getRelationships.html
blob815a158ef58f7ed23b3d70061a2281216f190988
1 <html>
2 <head>
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>
6 <script>
8 function test()
10 InspectorTest.sendCommand("DOM.getDocument", {}, onGotDocument);
12 var numPendingQuerySelectors = 0;
13 var nodeInfo = {};
14 InspectorTest.trackGetChildNodesEvents(nodeInfo);
15 function onGotDocument(msg)
17 if (msg.error) {
18 InspectorTest.log(msg.error.message);
19 InspectorTest.completeTest();
20 return;
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)
32 if (msg.error) {
33 InspectorTest.log(msg.error.message);
34 InspectorTest.completeTest();
35 return;
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");
47 if (p >= 0)
48 description += "#" + nodeData.attributes[p + 1];
50 return description;
53 function rewriteNode(relatedNode)
55 function rewriteNodePromise(resolve, reject) {
56 if (!("backendNodeId" in relatedNode)) {
57 reject("Could not find backendNodeId in " + JSON.stringify(relatedNode));
58 return;
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]";
66 resolve();
67 return;
69 var node = nodeInfo[nodeId];
70 delete relatedNode.backendNodeId;
71 relatedNode.nodeResult = describeNode(node);
72 resolve();
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(".");
82 var currentPath = [];
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)
96 if (condition)
97 return;
98 InspectorTest.log(errorMsg + " in " + JSON.stringify(obj, null, " "));
99 InspectorTest.completeTest();
102 function rewriteNodes(msg)
104 if (msg.error) {
105 InspectorTest.log(msg.error.message);
106 InspectorTest.completeTest();
107 return;
110 checkExists("result.accessibilityNode.properties", msg);
111 var properties = msg.result.accessibilityNode.properties;
112 var promises = [];
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));
128 function onSuccess()
130 function stripIds(key, value) {
131 if (key == "id")
132 return "<int>"
133 if (key == "nodeId")
134 return "<string>"
135 return 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);
156 </script>
157 </head>
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">
162 Thai
163 </li>
164 <li id="rg1-r2" tabindex="-1" role="radio" aria-checked="false">
165 Subway
166 </li>
167 <li id="rg1-r3" tabindex="-1" role="radio" aria-checked="false">
168 Jimmy Johns
169 </li>
170 <li id="rg1-r4" tabindex="-1" role="radio" aria-checked="true">
171 Radio Maria
172 </li>
173 <li id="rg1-r5" tabindex="-1" role="radio" aria-checked="false">
174 Rainbow Gardens
175 </li>
176 </ul>
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">
182 Water
183 </li>
184 <li id="rg2-r2" tabindex="-1" role="radio" aria-checked="false">
186 </li>
187 <li id="rg2-r3" tabindex="-1" role="radio" aria-checked="false">
188 Coffee
189 </li>
190 <li id="rg2-r4" tabindex="-1" role="radio" aria-checked="false">
191 Cola
192 </li>
193 <li id="rg2-r5" tabindex="-1" role="radio" aria-checked="false">
194 Ginger Ale
195 </li>
196 </ul>
197 </body>
198 </html>