Source/JavaScriptCore:
[WebKit-https.git] / LayoutTests / platform / mac / accessibility / selection-element-tabbing-to-link.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 <div>
9 <a href="" id="one">one</a>
10 <a href="" id="two">two</a>
11 </div>
12
13 <p id="description"></p>
14 <div id="console"></div>
15 <div id="notifications"></div>
16
17 <script>
18
19     description("This tests that tabbing between links includes a relevant accessibilityObject in the userInfo when on the boundary between an ignored accessibilityObject and an unignored accessibilityObject.");
20
21     var axTextChangeElement = 0;
22     var webArea = 0;
23     var changeElementOne = 0;
24     var changeElementTwo = 0;
25     var linkTwo = 0;
26     var linkOne = 0;
27     var count = 0;
28
29     function ancestorWithRole(axElement, role) {
30         var ancestor = axElement;
31         while (ancestor) {
32             if (ancestor.role == role)
33                 break;
34             ancestor = ancestor.parentElement();
35         }
36         return ancestor;
37     }
38
39     function notificationCallback(notification, userInfo) {
40         if (notification == "AXSelectedTextChanged") {
41             count++;
42             if (count == 1) {
43                 changeElementOne = userInfo["AXTextChangeElement"];
44                 linkTwo = accessibilityController.accessibleElementById("two");
45                 shouldBe("ancestorWithRole(changeElementOne, \"AXRole: AXLink\").isEqual(linkTwo)", "true");
46             } else if (count == 2) {
47                 changeElementTwo = userInfo["AXTextChangeElement"];
48                 linkOne = accessibilityController.accessibleElementById("one");
49                 shouldBe("ancestorWithRole(changeElementTwo, \"AXRole: AXLink\").isEqual(linkOne)", "true");
50                 webArea.removeNotificationListener();
51                 testRunner.notifyDone();
52             }
53         }
54     }
55
56     if (window.accessibilityController) {
57         testRunner.waitUntilDone();
58         testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
59
60         accessibilityController.enableEnhancedAccessibility(true);
61         webArea = accessibilityController.rootElement.childAtIndex(0);
62         webArea.setBoolAttributeValue("AXCaretBrowsingEnabled", true)
63
64         link = document.getElementById("one");
65         link.focus();
66
67         var addedNotification = webArea.addNotificationListener(notificationCallback);
68         shouldBe("addedNotification", "true");
69
70         eventSender.keyDown("\t");
71         eventSender.keyDown("\t", ["shiftKey"]);
72     }
73
74 </script>
75
76 <script src="../../../resources/js-test-post.js"></script>
77 </body>
78 </html>