Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions html/user-activation/activation-trigger-touch.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<!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>
Loading