1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
<!doctype html>
<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="/dom/events/scrolling/scroll_support.js"></script>
<script src="/css/css-scroll-snap/support/common.js"></script>
<link rel="help" href="https://drafts.csswg.org/css-overscroll-behavior">
<style>
body {
margin: 0;
width: 150vw;
height: 150vh;
}
#container {
width: 500px;
height: 300px;
border: 2px solid orange;
border-radius: 5px;
overflow: scroll;
}
#content {
background: repeating-linear-gradient(to bottom right, blue 15%, white 30%);
width: 400px;
height: 200px;
}
</style>
<body>
<div id="container">
<div id="content"></div>
</div>
</body>
<script>
const container = document.getElementById('container');
const content = document.getElementById('content');
const scrollAmount = 120;
const scrollRight = { dx: scrollAmount, dy: 0 };
const scrollDown = { dx: 0, dy: scrollAmount };
const startPosition = { x: 200, y: 100 };
async function performGestureScroll(posX, posY, deltaX, deltaY) {
await new test_driver.Actions()
.scroll(posX, posY, deltaX, deltaY)
.send();
await waitForCompositorCommit();
}
promise_test(async (t) => {
window.scrollTo(0, 0);
container.style.overflow = 'hidden';
container.style.overscrollBehaviorX = 'none';
container.style.overscrollBehaviorY = 'auto';
await waitForCompositorCommit();
assert_equals(window.scrollX, 0);
assert_equals(window.scrollY, 0);
await performGestureScroll(
startPosition.x, startPosition.y, scrollRight.dx, scrollRight.dy);
assert_equals(window.scrollX, 0);
await performGestureScroll(
startPosition.x, startPosition.y, scrollDown.dx, scrollDown.dy);
assert_greater_than(window.scrollY, 100);
}, 'overflow: hidden and overscroll-behavior-x: none should only prevent ' +
'scroll propagation on x axis.');
promise_test(async (t) => {
window.scrollTo(0, 0);
container.style.overflow = 'hidden';
container.style.overscrollBehaviorX = 'auto';
container.style.overscrollBehaviorY = 'none';
await waitForCompositorCommit();
assert_equals(window.scrollX, 0);
assert_equals(window.scrollY, 0);
await performGestureScroll(
startPosition.x, startPosition.y, scrollRight.dx, scrollRight.dy);
assert_greater_than(window.scrollX, 100);
await performGestureScroll(
startPosition.x, startPosition.y, scrollDown.dx, scrollDown.dy);
assert_equals(window.scrollY, 0);
}, 'overflow: hidden and overscroll-behavior-y: none should only prevent ' +
'scroll propagation on y axis.');
promise_test(async (t) => {
window.scrollTo(0, 0);
container.style.overflow = 'auto';
container.style.overscrollBehaviorX = 'none';
container.style.overscrollBehaviorY = 'auto';
await waitForCompositorCommit();
assert_equals(window.scrollX, 0);
assert_equals(window.scrollY, 0);
await performGestureScroll(
startPosition.x, startPosition.y, scrollRight.dx, scrollRight.dy);
assert_equals(window.scrollX, 0);
await performGestureScroll(
startPosition.x, startPosition.y, scrollDown.dx, scrollDown.dy);
assert_greater_than(window.scrollY, 100);
}, 'overflow: auto and overscroll-behavior-x: none should only prevent ' +
'scroll propagation on x axis.');
promise_test(async (t) => {
window.scrollTo(0, 0);
container.style.overflow = 'auto';
container.style.overscrollBehaviorX = 'auto';
container.style.overscrollBehaviorY = 'none';
await waitForCompositorCommit();
assert_equals(window.scrollX, 0);
assert_equals(window.scrollY, 0);
await performGestureScroll(
startPosition.x, startPosition.y,
scrollRight.dx, scrollRight.dy);
assert_greater_than(window.scrollX, 100);
await performGestureScroll(
startPosition.x, startPosition.y,
scrollDown.dx, scrollDown.dy);
assert_equals(window.scrollY, 0);
}, 'overflow: auto and overscroll-behavior-y: none should only prevent ' +
'scroll propagation on y axis.');
</script>
|