<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<script src="../../../resources/percent-based-util.js"></script>
<style>
body {
height: 1000px;
}
#fixed {
position:fixed;
right: 20px;
width: 100px;
height: 40px;
background-color: #ace;
}
#text {
font: bold 18pt monospace;
}
</style>
<div id="fixed"></div>
<div id="text">TEXT</div>
<div id="console"></div>
<script>
promise_test (async () => {
// Start a text selection.
await mouseMoveTo(20, 20);
await mouseDownAt(20, 20);
await mouseMoveTo(40, 20);
// Scroll before releasing the mouse.
const expectedScrollY = 40;
const { y: pixelsToScrollY } = calculatePixelsToScroll(
document.scrollingElement, 0, expectedScrollY
);
await gestureScroll(() => {
return smoothScroll(
pixelsToScrollY, 40, 20, GestureSourceType.MOUSE_INPUT, 'down',
SPEED_INSTANT, !isPercentBasedScrollingEnabled()
);
}, document.scrollingElement);
// Windows and Linux values appear to be slightly different
assert_approx_equals(window.scrollY, expectedScrollY, 0.5);
}, "This test verifies that text selection does not prevent smooth " +
"scrolls running on the main thread.");
</script>