<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
.test::first-letter{
color: red;
}
</style>
<div class="test">Foo bar</div>
<script>
const div = document.querySelector('.test');
const text = div.firstChild;
const xLeft = div.offsetLeft;
const xRight = xLeft + div.offsetWidth;
const y = div.offsetTop + (div.offsetHeight / 2);
// Regression test for https://crbug.com/918349
promise_test(() => {
return new Promise((resolve, reject) => {
assert_own_property(window, 'chrome');
assert_own_property(window.chrome, 'gpuBenchmarking');
// Mouse drag from left to right to select the complete text.
chrome.gpuBenchmarking.pointerActionSequence([{
source: 'mouse',
actions: [
{name: 'pointerDown', x: xLeft, y: y},
{name: 'pointerMove', x: xRight, y: y},
{name: 'pointerUp'}
]
}], resolve);
}).then(() => {
const selection = getSelection();
assert_equals(selection.anchorNode, text);
assert_equals(selection.anchorOffset, 0);
assert_equals(selection.focusNode, text);
assert_equals(selection.focusOffset, 7);
});
}, 'Dragging through the text should select the text completely');
</script>