AX: <details> element should allow expand/close through AX API
[WebKit-https.git] / LayoutTests / platform / mac / accessibility / details-summary.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../resources/js-test-pre.js"></script>
5 </head>
6 <body id="body">
7
8 <details open id="details1">
9   <summary>Some open info</summary>
10   <p>Details about the open topic.</p>
11 </details>
12
13 <details id="details2">
14   <summary>Some open info</summary>
15   <p>Details about the open topic.</p>
16 </details>
17
18 <p id="description"></p>
19 <div id="console"></div>
20
21 <script>
22
23     description("This tests some basic attributes about the details element.");
24
25     var callbackCount = 0;
26     if (window.accessibilityController) {
27         window.jsTestIsAsync = true;
28
29         var body = accessibilityController.rootElement.childAtIndex(0);
30         body.addNotificationListener(function(notification) {
31             if (notification == "AXExpandedChanged") {
32                 callbackCount++;
33                 debug("Received " + notification + " notification ");
34
35                 if (callbackCount == 2) {
36                    finishJSTest();
37                 }
38             }
39         });
40
41         var details1 = accessibilityController.accessibleElementById("details1");
42         shouldBe("details1.role", "'AXRole: AXGroup'");
43         shouldBe("details1.subrole", "'AXSubrole: AXDetails'");
44         shouldBeTrue("details1.isExpanded");
45         shouldBe("details1.childAtIndex(0).role", "'AXRole: AXGroup'");
46         shouldBe("details1.childAtIndex(0).subrole", "'AXSubrole: AXSummary'");
47         shouldBeTrue("details1.isAttributeSettable('AXExpanded')");
48
49         // Toggle the expanded state.
50         details1.setBoolAttributeValue("AXExpanded", false);
51         details1 = accessibilityController.accessibleElementById("details1");
52         shouldBeFalse("details1.isExpanded");
53
54         // Give it the same value to make sure we don't expand.
55         details1.setBoolAttributeValue("AXExpanded", false);
56         details1 = accessibilityController.accessibleElementById("details1");
57         shouldBeFalse("details1.isExpanded");
58
59         // Set to expand again.
60         details1.setBoolAttributeValue("AXExpanded", true);
61         details1 = accessibilityController.accessibleElementById("details1");
62         shouldBeTrue("details1.isExpanded");
63
64         // And duplicate the true state to make sure it doesn't toggle off.
65         details1.setBoolAttributeValue("AXExpanded", true);
66         details1 = accessibilityController.accessibleElementById("details1");
67         shouldBeTrue("details1.isExpanded");
68
69         var details2 = accessibilityController.accessibleElementById("details2");
70         shouldBe("details2.subrole", "'AXSubrole: AXDetails'");
71         shouldBeFalse("details2.isExpanded");
72     }
73
74 </script>
75
76 <script src="../../../resources/js-test-post.js"></script>
77 </body>
78 </html>