diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /gfx/layers/apz/test/mochitest/helper_zoom_prevented.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/layers/apz/test/mochitest/helper_zoom_prevented.html')
-rw-r--r-- | gfx/layers/apz/test/mochitest/helper_zoom_prevented.html | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/mochitest/helper_zoom_prevented.html b/gfx/layers/apz/test/mochitest/helper_zoom_prevented.html new file mode 100644 index 0000000000..b756c873f2 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_zoom_prevented.html @@ -0,0 +1,75 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width"> + <title>Checking prevent-default for zooming</title> + <script type="application/javascript" src="apz_test_native_event_utils.js"></script> + <script type="application/javascript" src="apz_test_utils.js"></script> + <script src="/tests/SimpleTest/paint_listener.js"></script> + <script type="application/javascript"> + +async function testPreventDefault(aTouchStartToCancel) { + var initial_resolution = await getResolution(); + ok(initial_resolution > 0, + "The initial_resolution is " + initial_resolution + ", which is some sane value"); + + // preventDefault exactly one touchstart based on the value of aTouchStartToCancel + var touchStartCount = 0; + var canceller = function(e) { + dump("touchstart listener hit, count: " + touchStartCount + "\n"); + touchStartCount++; + if (touchStartCount == aTouchStartToCancel) { + dump("calling preventDefault on touchstart\n"); + e.preventDefault(); + document.documentElement.removeEventListener("touchstart", canceller, {passive: false}); + } + }; + document.documentElement.addEventListener("touchstart", canceller, {passive: false}); + + let touchEndPromise = new Promise(resolve => { + document.documentElement.addEventListener("touchend", resolve, {passive: true, once: true}); + }); + + // Ensure that APZ gets updated hit-test info + await promiseAllPaintsDone(); + + await pinchZoomInTouchSequence(150, 300); + await touchEndPromise; // wait for the touchend listener to fire + + // Flush state and get the resolution we're at now + await promiseApzFlushedRepaints(); + let final_resolution = await getResolution(); + is(final_resolution, initial_resolution, "The final resolution (" + final_resolution + ") matches the initial resolution"); +} + +function transformFailer() { + ok(false, "The test fired an unexpected APZ:TransformEnd"); +} + +async function test() { + // Register a listener that fails the test if the APZ:TransformEnd event fires, + // because this test shouldn't actually be triggering any transforms + SpecialPowers.Services.obs.addObserver(transformFailer, "APZ:TransformEnd"); + + await testPreventDefault(1); + await testPreventDefault(2); +} + +function cleanup() { + SpecialPowers.Services.obs.removeObserver(transformFailer, "APZ:TransformEnd"); +} + +waitUntilApzStable() +.then(test) +.finally(cleanup) +.then(subtestDone, subtestFailed); + + </script> +</head> +<body> + Here is some text to stare at as the test runs. It serves no functional + purpose, but gives you an idea of the zoom level. It's harder to tell what + the zoom level is when the page is just solid white. +</body> +</html> |