summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_bug1162771.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /gfx/layers/apz/test/mochitest/helper_bug1162771.html
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/layers/apz/test/mochitest/helper_bug1162771.html')
-rw-r--r--gfx/layers/apz/test/mochitest/helper_bug1162771.html107
1 files changed, 107 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/mochitest/helper_bug1162771.html b/gfx/layers/apz/test/mochitest/helper_bug1162771.html
new file mode 100644
index 0000000000..3503341d41
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_bug1162771.html
@@ -0,0 +1,107 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width; initial-scale=1.0">
+ <title>Test for touchend on media elements</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 handleTouchStart() {
+ let v = document.getElementById("video");
+ let d = document.getElementById("div");
+
+ let e = await new Promise(resolve => {
+ document.body.addEventListener("touchstart", resolve, {once: true});
+ });
+
+ if (e.target === v || e.target === d) {
+ e.target.style.display = "none";
+ ok(true, "Set display to none on #" + e.target.id);
+ } else {
+ ok(false, "Got unexpected touchstart on " + e.target);
+ }
+ await promiseAllPaintsDone();
+}
+
+async function handleTouchEnd() {
+ let v = document.getElementById("video");
+ let d = document.getElementById("div");
+
+ let e = await new Promise(resolve => {
+ document.body.addEventListener("touchend", resolve, {once: true});
+ });
+
+ if (e.target === v || e.target === d) {
+ e.target._gotTouchend = true;
+ ok(true, "Got touchend event on #" + e.target.id);
+ }
+}
+
+async function test() {
+ var v = document.getElementById("video");
+ var d = document.getElementById("div");
+
+ var utils = SpecialPowers.getDOMWindowUtils(window);
+
+ let startHandledPromise = handleTouchStart();
+ let endHandledPromise = handleTouchEnd();
+ var pt = await coordinatesRelativeToScreen({ offsetX: 25, offsetY: 5, target: v });
+ utils.sendNativeTouchPoint(0, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT, pt.x, pt.y, 1, 90, null);
+ await startHandledPromise;
+ utils.sendNativeTouchPoint(0, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE, pt.x, pt.y, 1, 90, null);
+ await endHandledPromise;
+ ok(v._gotTouchend, "Touchend was received on video element");
+
+ startHandledPromise = handleTouchStart();
+ endHandledPromise = handleTouchEnd();
+ pt = await coordinatesRelativeToScreen({ offsetX: 25, offsetY: 5, target: d });
+ utils.sendNativeTouchPoint(0, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT, pt.x, pt.y, 1, 90, null);
+ await startHandledPromise;
+ utils.sendNativeTouchPoint(0, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE, pt.x, pt.y, 1, 90, null);
+ await endHandledPromise;
+ ok(d._gotTouchend, "Touchend was received on div element");
+}
+
+waitUntilApzStable()
+.then(test)
+.then(subtestDone, subtestFailed);
+
+ </script>
+ <style>
+ * {
+ font-size: 24px;
+ box-sizing: border-box;
+ }
+
+ #video {
+ display:block;
+ position:absolute;
+ top: 100px;
+ left:0;
+ width: 50%;
+ height: 100px;
+ border:solid black 1px;
+ background-color: #8a8;
+ }
+
+ #div {
+ display:block;
+ position:absolute;
+ top: 100px;
+ left: 50%;
+ width: 50%;
+ height: 100px;
+ border:solid black 1px;
+ background-color: #88a;
+ }
+ </style>
+</head>
+<body>
+ <p>Tap on the colored boxes to hide them.</p>
+ <video id="video"></video>
+ <div id="div"></div>
+</body>
+</html>