| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset=utf-8> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| </head> |
| <body> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="../utils.js"></script> |
| <script> |
| |
| 'use strict'; |
| |
| function assertNoScroll() |
| { |
| assert_equals(window.pageXOffset, 0, "The page was not scrolled in the x-axis."); |
| assert_equals(window.pageYOffset, 0, "The page was not scrolled in the y-axis."); |
| } |
| |
| target_test({ width: "200px", height: "200px" }, (target, test) => { |
| document.body.style.width = "2000px"; |
| document.body.style.height = "2000px"; |
| |
| target.style.touchAction = "pan-x"; |
| |
| const overlap = document.body.insertBefore(document.createElement("div"), target.nextElementSibling); |
| overlap.setAttribute("style", "position: absolute; left: 50px; top: 50px; width: 100px; height: 100px;"); |
| |
| // Swipe in the y-axis over the "touch-action: pan-x" element and around the overlapping element. |
| ui.swipe({ x: 25, y: 175 }, { x: 25, y: 25 }).then(assertNoScroll) |
| .then(() => ui.swipe({ x: 175, y: 175 }, { x: 175, y: 25 })).then(assertNoScroll) |
| // Now swipe over the overlapping element, this should scroll in both directions. |
| .then(() => ui.swipe({ x: 125, y: 125 }, { x: 75, y: 75 })).then(() => { |
| assert_not_equals(window.pageXOffset, 0, "The page was scrolled in the x-axis."); |
| assert_not_equals(window.pageYOffset, 0, "The page was scrolled in the y-axis."); |
| test.done(); |
| }); |
| }, "Testing that an element overlapping an element with touch-action: pan-x allows for scrolling while the touch-action: pan-x element correctly prevents scrolling in the y-axis."); |
| |
| </script> |
| </body> |
| </html> |