Bug 1678505 - Add an additional test case that touch events are handled in non root scroll container having overscroll-behavior: none. r=botond

overscroll-behavior-none-on-non-root.html is a test case that the document has
a 100vh scrollable element and its overscroll-behavior is `none`, thus all
touch events are consumed by the non-root scroll container. But with dynamic
toolbar, it will be notified as if it's consumed by the root container to move
the dynamic toolbar if the scroll position in the scrollable element is at the
bottom edge.

Differential Revision: https://phabricator.services.mozilla.com/D105712
This commit is contained in:
Hiroyuki Ikezoe 2021-02-26 04:15:20 +00:00
Родитель f83e9fbb57
Коммит 3fb4d533c8
3 изменённых файлов: 111 добавлений и 17 удалений

Просмотреть файл

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no">
<style>
html {
height: 100%;
width: 100%;
/* background contains one extra transparent.gif because we want trick the
contentful paint detection; We want to make sure the background is loaded
before the test starts so we always wait for the contentful paint timestamp
to exist, however, gradient isn't considered as contentful per spec, so Gecko
wouldn't generate a timestamp for it. Hence, we added a transparent gif
to the image list to trick the detection. */
background: url('/assets/www/transparent.gif'), linear-gradient(135deg, red, white);
}
body {
width: 100%;
margin: 0px;
padding: 0px;
}
</style>
<body>
<div id="scroll" style="width: 100%; height: 100vh; overscroll-behavior: none; overflow-y: scroll;">
<div style="height: 200vh;"></div>
</div>
</body>
</html>

Просмотреть файл

@ -96,6 +96,7 @@ open class BaseSessionTest(noErrorCollector: Boolean = false) {
const val OVERSCROLL_BEHAVIOR_AUTO_HTML_PATH = "/assets/www/overscroll-behavior-auto.html"
const val OVERSCROLL_BEHAVIOR_AUTO_NONE_HTML_PATH = "/assets/www/overscroll-behavior-auto-none.html"
const val OVERSCROLL_BEHAVIOR_NONE_AUTO_HTML_PATH = "/assets/www/overscroll-behavior-none-auto.html"
const val OVERSCROLL_BEHAVIOR_NONE_NON_ROOT_HTML_PATH = "/assets/www/overscroll-behavior-none-on-non-root.html"
const val SCROLL_HANDOFF_HTML_PATH = "/assets/www/scroll-handoff.html"
const val TEST_ENDPOINT = GeckoSessionTestRule.TEST_ENDPOINT

Просмотреть файл

@ -159,20 +159,8 @@ class InputResultDetailTest : BaseSessionTest() {
PanZoomController.OVERSCROLL_FLAG_VERTICAL)
}
@WithDisplay(width = 100, height = 100)
@Test
fun testScrollHandoff() {
sessionRule.display?.run { setDynamicToolbarMaxHeight(20) }
setupDocument(SCROLL_HANDOFF_HTML_PATH);
var value = sessionRule.waitForResult(sendDownEvent(50f, 50f))
// There is a child scroll container and its overscroll-behavior is `contain auto`
assertResultDetail("handoff", value,
PanZoomController.INPUT_RESULT_HANDLED_CONTENT,
PanZoomController.SCROLLABLE_FLAG_BOTTOM,
PanZoomController.OVERSCROLL_FLAG_VERTICAL)
// NOTE: This function requires #scroll element in the target document.
private fun scrollToBottom() {
// Prepare a scroll event listener.
val scrollPromise = mainSession.evaluatePromiseJS("""
new Promise(resolve => {
@ -188,11 +176,26 @@ class InputResultDetailTest : BaseSessionTest() {
const scroll = document.getElementById('scroll');
scroll.scrollTo(0, scroll.scrollHeight);
""".trimIndent())
// Wait a scroll event to make sure the scroll operation has happened.
assertThat("scroll", scrollPromise.value as Boolean, equalTo(true));
sessionRule.session.flushApzRepaints()
}
@WithDisplay(width = 100, height = 100)
@Test
fun testScrollHandoff() {
sessionRule.display?.run { setDynamicToolbarMaxHeight(20) }
setupDocument(SCROLL_HANDOFF_HTML_PATH);
var value = sessionRule.waitForResult(sendDownEvent(50f, 50f))
// There is a child scroll container and its overscroll-behavior is `contain auto`
assertResultDetail("handoff", value,
PanZoomController.INPUT_RESULT_HANDLED_CONTENT,
PanZoomController.SCROLLABLE_FLAG_BOTTOM,
PanZoomController.OVERSCROLL_FLAG_VERTICAL)
// Scroll to the bottom edge
scrollToBottom()
value = sessionRule.waitForResult(sendDownEvent(50f, 50f))
@ -202,4 +205,66 @@ class InputResultDetailTest : BaseSessionTest() {
PanZoomController.SCROLLABLE_FLAG_BOTTOM,
(PanZoomController.OVERSCROLL_FLAG_HORIZONTAL or PanZoomController.OVERSCROLL_FLAG_VERTICAL))
}
@WithDisplay(width = 100, height = 100)
@Test
fun testOverscrollBehaviorNoneOnNonRoot() {
var files = arrayOf(
OVERSCROLL_BEHAVIOR_NONE_NON_ROOT_HTML_PATH)
for (file in files) {
setupDocument(file)
var value = sessionRule.waitForResult(sendDownEvent(50f, 50f))
assertResultDetail("`overscroll-behavior: none` on non root scroll container", value,
PanZoomController.INPUT_RESULT_HANDLED_CONTENT,
PanZoomController.SCROLLABLE_FLAG_BOTTOM,
PanZoomController.OVERSCROLL_FLAG_NONE)
// Scroll to the bottom edge so that the container is no longer scrollable downwards.
scrollToBottom()
value = sessionRule.waitForResult(sendDownEvent(50f, 50f))
// The touch event should be handled in the scroll container content.
assertResultDetail("`overscroll-behavior: none` on non root scroll container", value,
PanZoomController.INPUT_RESULT_HANDLED_CONTENT,
PanZoomController.SCROLLABLE_FLAG_TOP,
PanZoomController.OVERSCROLL_FLAG_NONE)
}
}
@WithDisplay(width = 100, height = 100)
@Test
fun testOverscrollBehaviorNoneOnNonRootWithDynamicToolbar() {
sessionRule.display?.run { setDynamicToolbarMaxHeight(20) }
var files = arrayOf(
OVERSCROLL_BEHAVIOR_NONE_NON_ROOT_HTML_PATH)
for (file in files) {
setupDocument(file)
var value = sessionRule.waitForResult(sendDownEvent(50f, 50f))
assertResultDetail("`overscroll-behavior: none` on non root scroll container", value,
PanZoomController.INPUT_RESULT_HANDLED_CONTENT,
PanZoomController.SCROLLABLE_FLAG_BOTTOM,
PanZoomController.OVERSCROLL_FLAG_NONE)
// Scroll to the bottom edge so that the container is no longer scrollable downwards.
scrollToBottom()
value = sessionRule.waitForResult(sendDownEvent(50f, 50f))
// Now the touch event should be handed to the root scroller even if
// the scroll container's `overscroll-behavior` is none to move
// the dynamic toolbar.
assertResultDetail("`overscroll-behavior: none, none`", value,
PanZoomController.INPUT_RESULT_HANDLED,
PanZoomController.SCROLLABLE_FLAG_BOTTOM,
(PanZoomController.OVERSCROLL_FLAG_HORIZONTAL or PanZoomController.OVERSCROLL_FLAG_VERTICAL))
}
}
}