Commit 7b1acf8e authored by Liviu Tinta's avatar Liviu Tinta Committed by Commit Bot

Replace eventSender in popup-menu-scrollbar-button-scrolls

After we finish the scroll unification, the scrolls happens mainly on
the compositor thread, and the scroll code in the main thread will be
removed. eventSender sends the scroll events to main thread, so it
would not work after the scroll unification.

Bug: 1047176, 1113863
Change-Id: I839d0856887188000ef57963083f013d8c6f9cf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2498862Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Reviewed-by: default avatarLan Wei <lanwei@chromium.org>
Commit-Queue: Liviu Tinta <liviutinta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822277}
parent 9b7dace7
......@@ -93,6 +93,7 @@ function openPickerHelper(element) {
return internals.pagePopupWindow;
}
// TODO(crbug.com/1047176) - use clickToOpenPickerWithPromise instead
function clickToOpenPicker(x, y, callback, errorCallback) {
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
......@@ -104,6 +105,28 @@ function clickToOpenPicker(x, y, callback, errorCallback) {
errorCallback();
}
// Uses test_driver to open the picker.
function clickToOpenPickerWithPromise(x, y, callback, errorCallback) {
return new Promise((resolve, reject)=>{
var actions = new test_driver.Actions();
actions
.pointerMove(x, y)
.pointerDown()
.pointerUp()
.send();
waitUntil(()=>internals.pagePopupWindow).then(()=>{
popupWindow = internals.pagePopupWindow;
if (typeof callback === "function")
setPopupOpenCallback(callback);
resolve();
}).catch((err)=>{
if (typeof errorCallback === "function" && !popupWindow)
errorCallback();
reject();
});
});
}
function setPopupOpenCallback(callback) {
console.assert(popupWindow);
popupOpenCallback = callback;
......
......@@ -3,7 +3,11 @@
<head>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/testdriver.js"></script>
<script src="../../../resources/testdriver-actions.js"></script>
<script src="../../../resources/testdriver-vendor.js"></script>
<script src="../resources/common.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<script src="../resources/picker-common.js"></script>
</head>
<body>
......@@ -41,27 +45,27 @@
internals.settings.setScrollAnimatorEnabled(false);
let test = async_test(function(test) {
openPicker(menu, test.step_func(testScrollbarScroll),
var selectRect = menu.getBoundingClientRect();
clickToOpenPickerWithPromise(selectRect.left, selectRect.top, test.step_func(testScrollbarScroll),
test.unreached_func('Picker failed to open'));
}, "Scrollbar clicks in a popup must scroll");
function testScrollbarScroll() {
async function testScrollbarScroll() {
let picker = internals.pagePopupWindow.global.picker;
let scrollEvents = 0;
// Click on the scrollbar forward button, and then validate with
// a pixel test that the scrollbar/scrollable area scrolled.
//
// Note: when there is an active popup, eventSender's events are sent with
// coordinates relative to the popup itself, so we don't need to take the
// outer select element's position into account.
// Click on the scrollbar forward button, and then validate
// that the scrollbar/scrollable area scrolled.
let selectElement = internals.pagePopupWindow.global.picker._selectElement;
let innerSelectRect = selectElement.getBoundingClientRect();
let scrollbarX = innerSelectRect.x + innerSelectRect.width - 5;
let scrollbarY = innerSelectRect.y + innerSelectRect.height - 10;
eventSender.mouseMoveTo(scrollbarX, scrollbarY);
eventSender.mouseDown();
eventSender.mouseUp();
let scrollbarX = innerSelectRect.x + innerSelectRect.width - 5 + popupWindow.screenX;
let scrollbarY = innerSelectRect.y + innerSelectRect.height - 10 + popupWindow.screenY;
let actions = new test_driver.Actions();
await actions
.pointerMove(scrollbarX, scrollbarY)
.pointerDown()
.pointerUp()
.send();
requestAnimationFrame(test.step_func(function() {
requestAnimationFrame(test.step_func(function() {
assert_greater_than(selectElement.scrollTop, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment