Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / accessibility / selection-change-notification-contenteditable.html
blobb8554593a615af4ada2031fcc422d166d509d053
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="contentEditable" contentEditable="true">
9 <p>Before</p>
10 <p id="p">One paragraph in a contentEditable</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 contentEditable element 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('contentEditable');
25 var axElement = accessibilityController.accessibleElementById('contentEditable');
26 element.focus();
28 axElement.addNotificationListener(function(notification) {
29 if (notification == 'SelectedTextChanged') {
30 debug('Got SelectedTextChanged notification on contentEditable element.');
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>