| <!DOCTYPE html> |
| <html> |
| <head> |
| <style> |
| body { |
| height: 1000px; |
| } |
| #container { |
| position: relative; |
| top: -10px; |
| left: 50px; |
| width: 400px; |
| outline: 1px solid black; |
| font-family: monospace; |
| } |
| </style> |
| <script src="../../resources/js-test-pre.js"></script> |
| <script> |
| window.jsTestIsAsync = true; |
| |
| const eventCount = 50; |
| var scrollCount = 0; |
| |
| var start; |
| var end; |
| var firstRange; |
| |
| async function testComplete() |
| { |
| await eventSender.asyncMouseMoveTo(end.x, 0); |
| await eventSender.asyncMouseUp(); |
| |
| firstRange = window.getSelection().getRangeAt(0); |
| shouldBe('firstRange.startOffset', '18'); |
| shouldBe('firstRange.endOffset', '425'); |
| |
| finishJSTest(); |
| } |
| |
| async function waitForScrolledToTop() |
| { |
| if (window.scrollY == 0) { |
| await testComplete(); |
| return; |
| } |
| |
| window.setTimeout(waitForScrolledToTop, 2); |
| } |
| |
| async function doOneScroll() |
| { |
| if (++scrollCount == eventCount) { |
| await waitForScrolledToTop(); |
| return; |
| } |
| |
| await eventSender.asyncMouseMoveTo(end.x, end.y - scrollCount); |
| window.setTimeout(doOneScroll, 2); |
| } |
| |
| async function doTest() |
| { |
| if (!window.testRunner || !window.eventSender) { |
| debug('This test requires testRunner and eventSender'); |
| return; |
| } |
| |
| var containerRect = document.getElementById('container').getBoundingClientRect(); |
| var lineHeight = containerRect.height / 3; |
| |
| window.scrollTo(0, containerRect.bottom - lineHeight); |
| |
| containerRect = document.getElementById('container').getBoundingClientRect(); // Scrolling changed it. |
| |
| start = { x: containerRect.left + containerRect.width / 2, y: containerRect.bottom - lineHeight / 3 }; |
| end = { x: containerRect.left + containerRect.width / 3, y: 16 }; |
| |
| await eventSender.asyncMouseMoveTo(start.x, start.y); |
| await eventSender.asyncMouseDown(); |
| |
| await doOneScroll(); |
| } |
| |
| window.addEventListener('load', doTest, false); |
| </script> |
| </head> |
| <body> |
| <div id="container"> |
| Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. |
| </div> |
| |
| <p>This test ensures that drag-selecting works correctly in the main frame.</p> |
| |
| <div id="console"></div> |
| |
| <script src="../../resources/js-test-post.js"></script> |
| |
| </body> |
| </html> |