If the touch action causes scrolling or panning, there is no pointerup event; a pointercancel event is fired instead. So we don't need to do additional checks. Differential Revision: https://phabricator.services.mozilla.com/D304738
89 lines
3.5 KiB
HTML
89 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#activation-triggering-input-event">
|
|
<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="resources/utils.js"></script>
|
|
</head>
|
|
<body onload="runTests()">
|
|
<p>Tests user activation from a touch actions.</p>
|
|
<div id="scroller" style="width: 100%; height: 500px; overflow-y: scroll;">
|
|
<div id="content" style="width: 100%; height: 2000px;"></div>
|
|
</div>
|
|
<script>
|
|
|
|
async function onEventReceived(event) {
|
|
let shouldResultInActivation = event.type === "pointerup";
|
|
assert_equals(navigator.userActivation.isActive, shouldResultInActivation,
|
|
`${event.type} event should ${shouldResultInActivation ? "" : "not "}result in activation`);
|
|
await consumeTransientActivation();
|
|
}
|
|
|
|
async function onEventUnreached(event) {
|
|
assert_unreached(`should not receive ${event.type} event`);
|
|
}
|
|
|
|
function touchScrollInTarget(target) {
|
|
const deltaY = -1;
|
|
const x = 0;
|
|
|
|
let currentY = 0;
|
|
let actions = new test_driver.Actions()
|
|
.addPointer("TestPointer", "touch")
|
|
.pointerMove(x, currentY, {origin: target, sourceName: "TestPointer"})
|
|
.pointerDown({sourceName: "TestPointer"});
|
|
|
|
for (let i = 0; i < 20; i++) {
|
|
actions = actions.pointerMove(x, currentY, {origin: target, sourceName: "TestPointer"});
|
|
currentY += deltaY;
|
|
}
|
|
|
|
return actions.pause(100)
|
|
.pointerUp({sourceName: "TestPointer"})
|
|
.send();
|
|
}
|
|
|
|
function runTests() {
|
|
promise_test(async () => {
|
|
document.body.addEventListener("pointerdown", onEventReceived);
|
|
document.body.addEventListener("pointerup", onEventUnreached);
|
|
document.body.addEventListener("pointercancel", onEventReceived);
|
|
document.body.addEventListener("touchend", onEventReceived);
|
|
|
|
const touchend_event = getEvent('touchend');
|
|
await touchScrollInTarget(document.getElementById("scroller"));
|
|
await touchend_event;
|
|
|
|
document.body.removeEventListener("pointerdown", onEventReceived);
|
|
document.body.removeEventListener("pointerup", onEventUnreached);
|
|
document.body.removeEventListener("pointercancel", onEventReceived);
|
|
document.body.removeEventListener("touchend", onEventReceived);
|
|
}, "Activation through touch actions which cause scrolling");
|
|
|
|
promise_test(async () => {
|
|
document.body.addEventListener("pointerdown", onEventReceived);
|
|
document.body.addEventListener("pointerup", onEventUnreached);
|
|
document.body.addEventListener("pointercancel", onEventReceived);
|
|
document.body.addEventListener("touchend", onEventReceived);
|
|
|
|
document.body.addEventListener("touchmove", (event) => {
|
|
event.preventDefault();
|
|
}, {once: true, passive: false});
|
|
const touchend_event = getEvent('touchend');
|
|
await touchScrollInTarget(document.getElementById("scroller"));
|
|
await touchend_event;
|
|
|
|
document.body.removeEventListener("pointerdown", onEventReceived);
|
|
document.body.removeEventListener("pointerup", onEventReceived);
|
|
document.body.removeEventListener("pointercancel", onEventUnreached);
|
|
document.body.removeEventListener("touchend", onEventReceived);
|
|
}, "Activation through touch actions which doesn't cause scrolling");
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|