| <!DOCTYPE html> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="../resources/run-after-layout-and-paint.js"></script> |
| |
| <div id="contentEditable" contentEditable="true"> |
| <p>Before</p> |
| <p id="p">One paragraph in a contentEditable</p> |
| <p>After</p> |
| </div> |
| |
| <script> |
| 'use strict'; |
| |
| // Wait until layout has settled to avoid notification spam. |
| async_test_after_layout_and_paint((t) => { |
| const axRootElement = accessibilityController.rootElement; |
| axRootElement.setNotificationListener(t.step_func((notification, intents) => { |
| // Focus notification will come asynchronously. |
| if (notification == 'Focus' || notification == 'LoadStart' || |
| notification == 'LoadComplete' || notification == 'MarkDirty') { |
| return; |
| } |
| |
| if (notification == 'DocumentSelectionChanged') { |
| assert_array_equals(intents, |
| ['AXEventIntent(setSelection,none,character,forward)']); |
| axRootElement.unsetNotificationListener(); |
| t.done(); |
| return; |
| } |
| |
| assert_unreached('Unexpected notification: ' + notification); |
| })); |
| |
| const element = document.getElementById('contentEditable'); |
| element.focus(); |
| const p = document.getElementById('p'); |
| const range = document.createRange(); |
| range.setStart(p.firstChild, 0); |
| range.setEnd(p.firstChild, 1); |
| window.getSelection().removeAllRanges(); |
| window.getSelection().addRange(range); |
| }); |
| |
| </script> |