chromium/third_party/blink/web_tests/editing/text-iterator/selection-to-string-with-auto-fill.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<div>foo<input value="initial">bar</div>
<div>baz<textarea>initial</textarea>quux</div>
<div id="log"></div>
<script>
var input = document.querySelector('input');
var textarea = document.querySelector('textarea');
if (window.internals) {
    internals.setSuggestedValue(input, 'suggested');
    internals.setAutofilled(input, true);
    internals.setSuggestedValue(textarea, 'suggested');
    internals.setAutofilled(textarea, true);
}

// We should emit initial value if control is auto-filled.
test(function() {
    input.select();
    assert_equals(getSelection().toString(), '');
}, 'select input inner whole');

test(function() {
    textarea.select();
    assert_equals(getSelection().toString(), '');
}, 'select textarea inner whole');

// We should not put suggested value to toString().
test(function() {
    input.setSelectionRange(2, 5);
    assert_equals(getSelection().toString(), '');
}, 'select input inner');

test(function() {
    textarea.setSelectionRange(2, 5);
    assert_equals(getSelection().toString(), '');
}, 'select textarea inner');

// Selection should not have auto-filled value.
test(function() {
    getSelection().selectAllChildren(input.parentNode);
    assert_equals(getSelection().toString(), 'foobar');
}, 'select input outer');

test(function() {
    getSelection().selectAllChildren(textarea.parentNode);
    assert_equals(getSelection().toString(), 'bazquux');
}, 'select textarea outer');
</script>