1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32

content / test / data / accessibility / aria / aria-textbox-with-selection.html [blame]

<!--
@MAC-ALLOW:AXRoleDescription
@WIN-ALLOW:caret_offset*
@WIN-ALLOW:ia2_hypertext=*
@WIN-ALLOW:IA2_STATE_MULTI_LINE
@WIN-ALLOW:IA2_STATE_SINGLE_LINE
@WIN-ALLOW:n_selections*
@WIN-ALLOW:selection_start*
@WIN-ALLOW:selection_end*
@WIN-ALLOW:xml-roles*
-->
<!DOCTYPE html>
<html>
<body>
  <div id="text1" role="textbox">Single line.</div>
  <!-- Will not expose multiline state because it's not actually editable. -->
  <div id="text2" role="textbox" aria-multiline="true">Multiple<br>lines.</div>

  <script>
    var selection = window.getSelection();
    var selectionRange = document.createRange();
    var text1 = document.getElementById("text1");
    var text2 = document.getElementById("text2");
    // Selection should only affect the text boxes as a whole. No caret should
    // appear within the text boxes.
    selectionRange.setStart(text1, 0);
    selectionRange.setEnd(text2, 1);
    selection.removeAllRanges();
    selection.addRange(selectionRange);
  </script>
</body>
</html>