description("This tests the ability to search for accessible elements by key or text.");
if (window.accessibilityController) {
+ jsTestIsAsync = true;
window.testRunner.keepWebHistory();
document.getElementById("body").focus();
// Visited link.
accessibilityController.focusedElement.childAtIndex(14).childAtIndex(0).press();
- startElement = accessibilityController.focusedElement.childAtIndex(0);
- resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXVisitedLinkSearchKey", "", false);
- shouldBe("resultElement.boolAttributeValue('AXVisited')", "true");
- shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: link'");
-
- // Previous text search.
- startElement = accessibilityController.focusedElement.childAtIndex(10);
- resultElement = containerElement.uiElementForSearchPredicate(startElement, false, "", "sans-serif black bold text with underline", false);
- shouldBe("resultElement.role", "'AXRole: AXStaticText'");
- shouldBe("resultElement.stringValue", "'AXValue: sans-serif black bold text with underline'");
-
- // Execute a search for the next heading level 2 or the next link.
- startElement = accessibilityController.focusedElement.childAtIndex(0);
- resultElement = containerElement.uiElementForSearchPredicate(startElement, true, ["AXHeadingLevel2SearchKey", "AXLinkSearchKey"], "", false);
- shouldBe("resultElement.role", "'AXRole: AXHeading'");
- shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: heading level 2'");
-
- // After finding the heading, execute the search again and we should find the link.
- resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, ["AXHeadingLevel2SearchKey", "AXLinkSearchKey"], "", false);
- shouldBe("resultElement.role", "'AXRole: AXLink'");
- shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: link'");
+ setTimeout(function() {
+
+ startElement = accessibilityController.focusedElement.childAtIndex(0);
+ resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXVisitedLinkSearchKey", "", false);
+ shouldBe("resultElement.boolAttributeValue('AXVisited')", "true");
+ shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: link'");
+
+ // Previous text search.
+ startElement = accessibilityController.focusedElement.childAtIndex(10);
+ resultElement = containerElement.uiElementForSearchPredicate(startElement, false, "", "sans-serif black bold text with underline", false);
+ shouldBe("resultElement.role", "'AXRole: AXStaticText'");
+ shouldBe("resultElement.stringValue", "'AXValue: sans-serif black bold text with underline'");
+
+ // Execute a search for the next heading level 2 or the next link.
+ startElement = accessibilityController.focusedElement.childAtIndex(0);
+ resultElement = containerElement.uiElementForSearchPredicate(startElement, true, ["AXHeadingLevel2SearchKey", "AXLinkSearchKey"], "", false);
+ shouldBe("resultElement.role", "'AXRole: AXHeading'");
+ shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: heading level 2'");
+
+ // After finding the heading, execute the search again and we should find the link.
+ resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, ["AXHeadingLevel2SearchKey", "AXLinkSearchKey"], "", false);
+ shouldBe("resultElement.role", "'AXRole: AXLink'");
+ shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: link'");
- // From the link, execute the search in reverse and we should land back on the heading.
- resultElement = containerElement.uiElementForSearchPredicate(resultElement, false, ["AXHeadingLevel2SearchKey", "AXLinkSearchKey"], "", false);
- shouldBe("resultElement.role", "'AXRole: AXHeading'");
- shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: heading level 2'");
+ // From the link, execute the search in reverse and we should land back on the heading.
+ resultElement = containerElement.uiElementForSearchPredicate(resultElement, false, ["AXHeadingLevel2SearchKey", "AXLinkSearchKey"], "", false);
+ shouldBe("resultElement.role", "'AXRole: AXHeading'");
+ shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: heading level 2'");
- // Now, we need to test isVisible. Save off the first object
- startElement = accessibilityController.focusedElement.childAtIndex(0);
-
- // Scroll all the way to the bottom of the content
- resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "", "test button 3", false);
- shouldBe("resultElement.role", "'AXRole: AXButton'");
- shouldBe("resultElement.title", "'AXTitle: test button 3'");
- resultElement.scrollToMakeVisible();
-
- // find the start of the isVisible test section
- resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "", "isVisible test start", false);
- shouldBe("resultElement.role", "'AXRole: AXHeading'");
- shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: isVisible test start'");
-
- // save away the "isVisible test start" heading as the start element
- startElement = resultElement;
-
- // If we don't care about visible only, then we should easily find 3 buttons
- resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXButtonSearchKey", "", false);
- shouldBe("resultElement.role", "'AXRole: AXButton'");
- shouldBe("resultElement.title", "'AXTitle: test button 1'");
-
- resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXButtonSearchKey", "", false);
- shouldBe("resultElement.role", "'AXRole: AXButton'");
- shouldBe("resultElement.title", "'AXTitle: test button 2'");
-
- // save away testButton2 so we can make it visible later
- testButton2 = resultElement;
+ // Now, we need to test isVisible. Save off the first object
+ startElement = accessibilityController.focusedElement.childAtIndex(0);
+
+ // Scroll all the way to the bottom of the content
+ resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "", "test button 3", false);
+ shouldBe("resultElement.role", "'AXRole: AXButton'");
+ shouldBe("resultElement.title", "'AXTitle: test button 3'");
+ resultElement.scrollToMakeVisible();
+
+ // find the start of the isVisible test section
+ resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "", "isVisible test start", false);
+ shouldBe("resultElement.role", "'AXRole: AXHeading'");
+ shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: isVisible test start'");
+
+ // save away the "isVisible test start" heading as the start element
+ startElement = resultElement;
+
+ // If we don't care about visible only, then we should easily find 3 buttons
+ resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXButtonSearchKey", "", false);
+ shouldBe("resultElement.role", "'AXRole: AXButton'");
+ shouldBe("resultElement.title", "'AXTitle: test button 1'");
+
+ resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXButtonSearchKey", "", false);
+ shouldBe("resultElement.role", "'AXRole: AXButton'");
+ shouldBe("resultElement.title", "'AXTitle: test button 2'");
+
+ // save away testButton2 so we can make it visible later
+ testButton2 = resultElement;
- resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXButtonSearchKey", "", false);
- shouldBe("resultElement.role", "'AXRole: AXButton'");
- shouldBe("resultElement.title", "'AXTitle: test button 3'");
+ resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXButtonSearchKey", "", false);
+ shouldBe("resultElement.role", "'AXRole: AXButton'");
+ shouldBe("resultElement.title", "'AXTitle: test button 3'");
- // if we care about visible only, then we should not find "test button 2"
- resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXButtonSearchKey", "", true);
- shouldBe("resultElement.role", "'AXRole: AXButton'");
- shouldBe("resultElement.title", "'AXTitle: test button 1'");
+ // if we care about visible only, then we should not find "test button 2"
+ resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXButtonSearchKey", "", true);
+ shouldBe("resultElement.role", "'AXRole: AXButton'");
+ shouldBe("resultElement.title", "'AXTitle: test button 1'");
- resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXButtonSearchKey", "", true);
- shouldBe("resultElement.role", "'AXRole: AXButton'");
- shouldBe("resultElement.title", "'AXTitle: test button 3'");
+ resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXButtonSearchKey", "", true);
+ shouldBe("resultElement.role", "'AXRole: AXButton'");
+ shouldBe("resultElement.title", "'AXTitle: test button 3'");
- // now, scroll to the second button, and confirm that we don't see the first button
- testButton2.scrollToMakeVisible();
+ // now, scroll to the second button, and confirm that we don't see the first button
+ testButton2.scrollToMakeVisible();
- resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXButtonSearchKey", "", true);
- shouldBe("resultElement.role", "'AXRole: AXButton'");
- shouldBe("resultElement.title", "'AXTitle: test button 2'");
-
- resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXButtonSearchKey", "", true);
- shouldBe("resultElement.role", "'AXRole: AXButton'");
- shouldBe("resultElement.title", "'AXTitle: test button 3'");
-
- // Now since the page is scrolled to the bottom, the first visible button should be #2
- startElement = accessibilityController.focusedElement.childAtIndex(0);
- resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXButtonSearchKey", "", true);
- shouldBe("resultElement.role", "'AXRole: AXButton'");
- shouldBe("resultElement.title", "'AXTitle: test button 2'");
-
- // lets scroll to the top of the page and ensure that the submit button is visible
- startElement.scrollToMakeVisible();
- resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXButtonSearchKey", "", true);
- shouldBe("resultElement.role", "'AXRole: AXButton'");
- shouldBe("resultElement.title", "'AXTitle: Submit'");
-
- // there should be no more visible buttons
- resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXButtonSearchKey", "", true);
- shouldBeUndefined("resultElement");
-
+ resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXButtonSearchKey", "", true);
+ shouldBe("resultElement.role", "'AXRole: AXButton'");
+ shouldBe("resultElement.title", "'AXTitle: test button 2'");
+
+ resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXButtonSearchKey", "", true);
+ shouldBe("resultElement.role", "'AXRole: AXButton'");
+ shouldBe("resultElement.title", "'AXTitle: test button 3'");
+
+ // Now since the page is scrolled to the bottom, the first visible button should be #2
+ startElement = accessibilityController.focusedElement.childAtIndex(0);
+ resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXButtonSearchKey", "", true);
+ shouldBe("resultElement.role", "'AXRole: AXButton'");
+ shouldBe("resultElement.title", "'AXTitle: test button 2'");
+
+ // lets scroll to the top of the page and ensure that the submit button is visible
+ startElement.scrollToMakeVisible();
+ resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXButtonSearchKey", "", true);
+ shouldBe("resultElement.role", "'AXRole: AXButton'");
+ shouldBe("resultElement.title", "'AXTitle: Submit'");
+
+ // there should be no more visible buttons
+ resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXButtonSearchKey", "", true);
+ shouldBeUndefined("resultElement");
+
+ finishJSTest();
+ }, 50);
}
</script>