Clean up asynchronous behavior in some accessibility tests
[WebKit-https.git] / LayoutTests / accessibility / mac / select-element-selection-with-optgroups.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test-pre.js"></script>
5 </head>
6 <body id="body">
7
8 <select name="suite" id="suite" multiple="multiple" size="24">
9
10 <optgroup label="main">
11 <option value="881">Item1</option>
12 <option value="938">Item2</option>
13 </optgroup>
14 <optgroup label="primary">
15 <option value="1027">Item3</option>
16 <option value="1049">Item4</option>
17 <option value="1050">Item5</option>
18 </optgroup>
19 </select>
20
21 <p id="description"></p>
22 <div id="console"></div>
23
24 <script>
25 description("This tests that setting selection within a list box works correctly if there are optgroups");
26
27 if (window.accessibilityController) {
28     window.jsTestIsAsync = true;
29     document.getElementById("suite").focus();
30     var selectElement = accessibilityController.focusedElement;
31
32     shouldBe("selectElement.selectedChildrenCount", "0");
33
34     var option1 = selectElement.childAtIndex(1);
35     var option2 = selectElement.childAtIndex(2);
36     var option3 = selectElement.childAtIndex(4);
37
38     // Selection operations happen after a delay so they don't hang. Check the result on a timeout.
39     selectElement.setSelectedChild(option1);
40     shouldBecomeEqual("selectElement.selectedChildrenCount", "1", function() {
41         shouldBeTrue("selectElement.selectedChildAtIndex(0).isEqual(option1)");
42
43         selectElement.setSelectedChild(option2);
44         shouldBecomeEqual("selectElement.selectedChildrenCount", "1", function() {
45            shouldBeTrue("selectElement.selectedChildAtIndex(0).isEqual(option2)");
46
47             selectElement.setSelectedChild(option3);
48             shouldBecomeEqual("selectElement.selectedChildrenCount", "1", function() {
49                 shouldBeTrue("selectElement.selectedChildAtIndex(0).isEqual(option3)");
50                 finishJSTest();
51             });
52         });
53     });
54 } else
55     debug("window.accessibilityController is not present");
56 </script>
57
58 <script src="../../resources/js-test-post.js"></script>
59 </body>
60 </html>