Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / text-iterator / selection-to-string-with-auto-fill.html
bloba0ab4cb0766b8d40640546318c3e381ec59d1255
1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <div>foo<input value="initial">bar</div>
5 <div>baz<textarea>initial</textarea>quux</div>
6 <div id="log"></div>
7 <script>
8 var input = document.querySelector('input');
9 var textarea = document.querySelector('textarea');
10 if (window.internals) {
11 internals.setSuggestedValue(input, 'suggested');
12 internals.setAutofilled(input, true);
13 internals.setSuggestedValue(textarea, 'suggested');
14 internals.setAutofilled(textarea, true);
17 // We should emit initial value if control is auto-filled.
18 test(function() {
19 input.select();
20 assert_equals(getSelection().toString(), '');
21 }, 'select input inner whole');
23 test(function() {
24 textarea.select();
25 assert_equals(getSelection().toString(), '');
26 }, 'select textarea inner whole');
28 // We should not put suggested value to toString().
29 test(function() {
30 input.setSelectionRange(2, 5);
31 assert_equals(getSelection().toString(), '');
32 }, 'select input inner');
34 test(function() {
35 textarea.setSelectionRange(2, 5);
36 assert_equals(getSelection().toString(), '');
37 }, 'select textarea inner');
39 // Selection should not have auto-filled value.
40 test(function() {
41 getSelection().selectAllChildren(input.parentNode);
42 assert_equals(getSelection().toString(), 'foobar');
43 }, 'select input outer');
45 test(function() {
46 getSelection().selectAllChildren(textarea.parentNode);
47 assert_equals(getSelection().toString(), 'bazquux');
48 }, 'select textarea outer');
49 </script>