blob: eb0385fc41a4803ccceda02d6be0faaafd71682a [file] [log] [blame]
<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
// This tests interaction with user-triggered SelectAll command and selection.
// When selection is hidden, user-triggered SelectAll should act as if there is
// no selection at all.
test(() => {
assert_own_property(window, 'testRunner', 'This test requires testRunner');
assert_selection(
'foo<textarea>bar|</textarea><a href="http://www.example.com">baz</a>',
selection => {
selection.document.querySelector('a').focus();
testRunner.execCommand('selectAll');
},
'^foo<textarea>bar</textarea><a href="http://www.example.com">baz|</a>')
}, 'User-triggered SelectAll selects entire document when there is unfocused caret selection hidden in text control');
test(() => {
assert_own_property(window, 'testRunner', 'This test requires testRunner');
assert_selection(
'foo<textarea>^ba|r</textarea><a href="http://www.example.com">baz</a>',
selection => {
selection.document.querySelector('a').focus();
testRunner.execCommand('selectAll');
},
'^foo<textarea>bar</textarea><a href="http://www.example.com">baz|</a>')
}, 'User-triggered SelectAll selects entire document when there is unfocused range selection hidden in text control');
test(() => {
assert_own_property(window, 'testRunner', 'This test requires testRunner');
assert_selection(
'foo<div contenteditable>bar|</div><a href="http://www.example.com">baz</a>',
selection => {
selection.document.querySelector('a').focus();
testRunner.execCommand('selectAll');
},
'^foo<div contenteditable>bar</div><a href="http://www.example.com">baz|</a>')
}, 'User-triggered SelectAll selects entire document when there is unfocused caret selection hidden in contenteditable div');
test(() => {
assert_own_property(window, 'testRunner', 'This test requires testRunner');
assert_selection(
'foo<div contenteditable>^ba|r</div><a href="http://www.example.com">baz</a>',
selection => {
selection.document.querySelector('a').focus();
testRunner.execCommand('selectAll');
},
'foo<div contenteditable>^bar|</div><a href="http://www.example.com">baz</a>')
}, 'User-triggered SelectAll extends existing selection when there is unfocused range selection shown in contenteditable div');
</script>