diff options
Diffstat (limited to 'gfx/layers/apz/test/mochitest/helper_scroll_linked_effect_by_wheel.html')
-rw-r--r-- | gfx/layers/apz/test/mochitest/helper_scroll_linked_effect_by_wheel.html | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/mochitest/helper_scroll_linked_effect_by_wheel.html b/gfx/layers/apz/test/mochitest/helper_scroll_linked_effect_by_wheel.html new file mode 100644 index 0000000000..f9303253b8 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_scroll_linked_effect_by_wheel.html @@ -0,0 +1,65 @@ +<!DOCTYPE html> +<html> +<meta charset="utf-8"> +<script src="/tests/SimpleTest/EventUtils.js"></script> +<script src="/tests/SimpleTest/paint_listener.js"></script> +<script src="apz_test_utils.js"></script> +<script src="apz_test_native_event_utils.js"></script> +<title>A scroll linked effect scrolled by wheel events</title> +<style> +html, body { margin: 0; } +body { + height: 1000vh; +} +#target { + position: absolute; + height: 800px; + background-color: #cc00cc; + top: 0; + left: 0; + right: 0; +} +</style> +<div id="target"></div> +<script> +// Set up a scroll linked effect element. +window.addEventListener("scroll", () => { + target.style.top = window.scrollY + "px"; +}); + +async function test() { + let rect = rectRelativeToScreen(target); + // We only care the top 10px here since the scroll linked effect on the + // main-thread can't keep up with the async scrolling by wheel events so that + // the position absolute element is often partially scrolled out. + rect.height = 10.0; + const initialSnapshot = await getSnapshot(rect); + + let snapshots = []; + for (let i = 0; i < 10; i++) { + await synthesizeNativeWheel(window, 50, 50, 0, -10); + snapshots.push(await getSnapshot(rect)); + } + + const sampledData = collectSampledScrollOffsets(document.scrollingElement); + const hasPoint5FractionalOffset = sampledData.some(data => { + return SpecialPowers.wrap(data).scrollOffsetY.toString().split(".")?.[1] === "5" + }); + + if (hasPoint5FractionalOffset) { + todo(false, "Bug 1752789: There's at least one sampled scroll offset " + + "having .5 fractional part in such cases scroll linked effects can " + + "not be rendered at the same position of the async scroll offset"); + return; + } + + snapshots.forEach(snapshot => { + is(initialSnapshot, snapshot); + }); +} + +pushPrefs([["apz.test.logging_enabled", true]]) +.then(waitUntilApzStable) +.then(test) +.then(subtestDone, subtestFailed); +</script> |