| <!DOCTYPE HTML> |
| <html> |
| <head> |
| <script src="../../resources/accessibility-helper.js"></script> |
| <script src="../../resources/js-test.js"></script> |
| </head> |
| <body> |
| |
| <div id="content"> |
| |
| <div role="combobox" id="combobox" tabindex=0 /> |
| |
| <div id="list" role="list"> |
| <div id="item1" role="listitem">1</ldiv> |
| <div id="item2" role="listitem">2</div> |
| <div id="item3" role="listitem">3</div> |
| </div> |
| |
| </div> |
| |
| <script> |
| let output = "Tests that for a combobox, ActiveElement and SelectedChildren return the same object.\n\n"; |
| window.jsTestIsAsync = true; |
| |
| if (window.accessibilityController) { |
| var combobox = document.getElementById("combobox"); |
| combobox.focus(); |
| var axCombobox = accessibilityController.accessibleElementById("combobox"); |
| output += expect("axCombobox.activeElement", "null"); |
| output += expect("axCombobox.selectedChildren().length", "0"); |
| |
| var activeElementChangeCount = 0; |
| var selectedChildrenChangeCount = 0; |
| accessibilityController.addNotificationListener((target, notification) => { |
| if (notification === "AXActiveElementChanged") { |
| output += `notification: ${notification}\n`; |
| output += ` activeElement: ${axCombobox.activeElement.domIdentifier}\n`; |
| ++activeElementChangeCount; |
| } |
| |
| if (notification == "AXSelectedChildrenChanged") { |
| output += `notification: ${notification}\n`; |
| outputSelectedChildren(axCombobox); |
| ++selectedChildrenChangeCount; |
| } |
| }); |
| |
| setTimeout(async () => { |
| output += "Setting activedescendant to 1 and selected to 2:\n"; |
| combobox.setAttribute("aria-activedescendant", "item1"); |
| document.getElementById("item2").setAttribute("aria-selected", "true"); |
| await waitFor(() => { |
| return activeElementChangeCount == 1 && selectedChildrenChangeCount == 1; |
| }); |
| |
| output += "Setting activedescendant to 2:\n"; |
| combobox.setAttribute("aria-activedescendant", "item2"); |
| await waitFor(() => { |
| return activeElementChangeCount == 2; |
| }); |
| |
| output += "Setting activedescendant to 3:\n"; |
| combobox.setAttribute("aria-activedescendant", "item3"); |
| await waitFor(() => { |
| return activeElementChangeCount == 3; |
| }); |
| |
| output += "Selecting 3:\n"; |
| document.getElementById("item3").setAttribute("aria-selected", "true"); |
| await waitFor(() => { |
| return selectedChildrenChangeCount == 2; |
| }); |
| |
| document.getElementById("content").style.visibility = "hidden"; |
| debug(output); |
| finishJSTest(); |
| }, 0); |
| } |
| </script> |
| </body> |
| </html> |