Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / accessibility / selection-change-notification-aria-textbox.html
blob1b2642702667bda43947ae639cf9d56a97e790f4
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 </head>
6 <body id="static_eventTarget">
8 <div id="ariaTextbox" role="textbox" tabIndex="0">
9 <p>Before</p>
10 <p id="p">One paragraph in an ARIA textbox</p>
11 <p>After</p>
12 </div>
14 <div id="console"></div>
15 <script>
16 description("Tests that a 'selected text changed' notification fires on a focusable element with role=textbox when the user moves the cursor within it.");
17 window.jsTestIsAsync = true;
19 function runTest() {
20 // This forces building the accessibility tree, because selection change
21 // events only fire on elements that already exist.
22 accessibilityController.accessibleElementById('dummy');
24 var element = document.getElementById('ariaTextbox');
25 var axElement = accessibilityController.accessibleElementById('ariaTextbox');
26 element.focus();
28 axElement.addNotificationListener(function(notification) {
29 if (notification == 'SelectedTextChanged') {
30 debug('Got SelectedTextChanged notification on focusable element with role=textbox.');
31 axElement.removeNotificationListener();
32 finishJSTest();
34 });
36 var p = document.getElementById('p');
37 var range = document.createRange();
38 range.setStart(p.firstChild, 0);
39 range.setEnd(p.firstChild, 1);
40 window.getSelection().removeAllRanges();
41 window.getSelection().addRange(range);
44 if (window.testRunner && window.accessibilityController) {
45 testRunner.dumpAsText();
46 window.onload = runTest();
49 </script>
51 </body>
52 </html>