Skip to content

Commit

Permalink
Remove redundant test for scrollend
Browse files Browse the repository at this point in the history
Modify scrollend-event-fired-after-sequence-of-scrolls.tentative.html
to support horizontal scrolling and delete
scrollend-event-for-user-scroll.html

Bug: 1271170
Change-Id: I36682fd7ac68bef767c9cfdf563bf6754dded0fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4219313
Reviewed-by: Kevin Ellis <kevers@chromium.org>
Commit-Queue: Mehdi Kazemi <mehdika@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1100471}
  • Loading branch information
mehdi-kazemi authored and Chromium LUCI CQ committed Feb 2, 2023
1 parent cf24750 commit 290e3f2
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ async function verifyScrollStopped(test, target_div) {
});
}

async function resetTargetScrollState(test, target_div) {
if (target_div.scrollTop != 0 || target_div.scrollLeft != 0) {
target_div.scrollTop = 0;
target_div.scrollLeft = 0;
return waitForScrollendEvent(test, target_div);
}
}

const MAX_FRAME = 700;
const MAX_UNCHANGED_FRAMES = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

#innerDiv {
width: 500px;
width: 4000px;
height: 4000px;
}
</style>
Expand All @@ -29,46 +29,63 @@
<script>
const target_div = document.getElementById('targetDiv');

function runTest() {
promise_test (async (t) => {
// Skip the test on a Mac as they do not support touch screens.
const isMac = navigator.platform.toUpperCase().indexOf('MAC')>=0;
if (isMac)
return;
async function testWithMovePath(t, move_path) {
// Skip the test on a Mac as they do not support touch screens.
const isMac = navigator.platform.toUpperCase().indexOf('MAC')>=0;
if (isMac)
return;

await resetTargetScrollState(t, target_div);
await waitForCompositorReady();

verifyNoScrollendOnDocument(t);

verifyNoScrollendOnDocument(t);
await waitForCompositorReady();
let scrollend_count = 0;
const scrollend_listener = () => { scrollend_count += 1; };
target_div.addEventListener("scrollend", scrollend_listener);
t.add_cleanup(() => { target_div.removeEventListener('scrollend', scrollend_listener); });

let scrollend_count = 0;
const scrollend_listener = () => { scrollend_count += 1; };
target_div.addEventListener("scrollend", scrollend_listener);
t.add_cleanup(() => { target_div.removeEventListener('scrollend', scrollend_listener); });
const pointercancel_listener = () => {
assert_equals(scrollend_count, 0, 'scrollend should happen after pointercancel.');
};
target_div.addEventListener("pointercancel", pointercancel_listener);
t.add_cleanup(() => { target_div.removeEventListener('pointercancel', pointercancel_listener); });

const pointercancel_listener = () => {
assert_equals(scrollend_count, 0, 'scrollend should happen after pointercancel.');
};
target_div.addEventListener("pointercancel", pointercancel_listener);
t.add_cleanup(() => { target_div.removeEventListener('pointercancel', pointercancel_listener); });
// Because we have several pointer moves, we choose bigger timeout.
const timeoutMs = 1000;
const targetPointercancelPromise = waitForPointercancelEvent(t, target_div, timeoutMs);
const targetScrollendPromise = createScrollendPromiseForTarget(t, target_div, timeoutMs);

// Because we have several pointer moves, we choose bigger timeout.
const timeoutMs = 1000;
const targetPointercancelPromise = waitForPointercancelEvent(t, target_div, timeoutMs);
const targetScrollendPromise = createScrollendPromiseForTarget(t, target_div, timeoutMs);
await touchScrollInTargetSequentiallyWithPause(target_div, move_path);

// Because we start scrolling after pointerdown, there is no pointerup, instead the target
// will receive a pointercancel, so we wait for pointercancel, and then continue.
await targetPointercancelPromise;
await targetScrollendPromise;
await verifyScrollStopped(t, target_div);
assert_equals(scrollend_count, 1, 'Only one scrollend event should be fired');
}

function runTest() {
promise_test (async (t) => {
// Scroll down & up & down on target div and wait for the target_div to get scrollend event.
const move_path = [
{ x: 0, y: -80 }, // Scroll down
{ x: 0, y: -40 }, // Scroll up
{ x: 0, y: -80 }, // Scroll down
];
await touchScrollInTargetSequentiallyWithPause(target_div, move_path);

// Because we start scrolling after pointerdown, there is no pointerup, instead the target
// will receive a pointercancel, so we wait for pointercancel, and then continue.
await targetPointercancelPromise;
await targetScrollendPromise;
await verifyScrollStopped(t, target_div);
assert_equals(scrollend_count, 1, 'Only one scrollend event should be fired');
await testWithMovePath(t, move_path);
}, "Move down, up and down again, receive scrollend event only once");

promise_test (async (t) => {
// Scroll right & left & right on target div and wait for the target_div to get scrollend event.
const move_path = [
{ x: -80, y: 0 }, // Scroll right
{ x: -40, y: 0 }, // Scroll left
{ x: -80, y: 0 }, // Scroll right
];
await testWithMovePath(t, move_path);
}, "Move right, left and right again, receive scrollend event only once");

}
</script>

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,14 @@
<script>
var target_div = document.getElementById('targetDiv');

async function resetTargetScrollState(test) {
if (target_div.scrollTop != 0 || target_div.scrollLeft != 0) {
target_div.scrollTop = 0;
target_div.scrollLeft = 0;
return waitForScrollendEvent(test, target_div);
}
}

function runTest() {
promise_test(async (t) => {
// Skip the test on a Mac as they do not support touch screens.
const isMac = navigator.platform.toUpperCase().indexOf('MAC')>=0;
if (isMac)
return;

await resetTargetScrollState(t);
await resetTargetScrollState(t, target_div);
await waitForCompositorReady();

const timeout = 1000; // Because we have two pauses we need longer timeout
Expand Down Expand Up @@ -92,7 +84,7 @@
if (scrollbar_width == 0)
return;

await resetTargetScrollState(t);
await resetTargetScrollState(t, target_div);
await waitForCompositorReady();

const targetScrollendPromise = createScrollendPromiseForTarget(t, target_div);
Expand Down Expand Up @@ -123,7 +115,7 @@
if (scrollbar_width == 0)
return;

await resetTargetScrollState(t);
await resetTargetScrollState(t, target_div);
await waitForCompositorReady();

const targetScrollendPromise = createScrollendPromiseForTarget(t, target_div);
Expand All @@ -149,7 +141,7 @@
'scrollbar thumb.');

promise_test(async (t) => {
await resetTargetScrollState(t);
await resetTargetScrollState(t, target_div);
await waitForCompositorReady();

const targetScrollendPromise = createScrollendPromiseForTarget(t, target_div);
Expand All @@ -171,7 +163,7 @@
'scrolling.');

promise_test(async (t) => {
await resetTargetScrollState(t);
await resetTargetScrollState(t, target_div);
await waitForCompositorReady();

verifyNoScrollendOnDocument(t);
Expand Down

0 comments on commit 290e3f2

Please sign in to comment.