blob: f3991d98d74de44a370adc23efe295bf10efdcb2 [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>Pointer Event: releasePointerCapture() - subsequent events follow normal hitting testing mechanisms</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<link rel="author" title="Microsoft" href="http://www.microsoft.com/"/>
<meta name="assert" content="After invoking the releasePointerCapture method on an element, subsequent events for the specified pointer must follow normal hit testing mechanisms for determining the event target"/>
<link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- Additional helper script for common checks across event types -->
<script type="text/javascript" src="pointerevent_support.js"></script>
<script type="text/javascript">
var detected_pointertypes = {};
var test_pointerEvent = async_test("lostpointercapture: subsequent events to target."); // set up test harness
var suppressedEventsFail = false;
// showPointerTypes is defined in pointerevent_support.js
// Requirements: the callback function will reference the test_pointerEvent object and
// will fail unless the async_test is created with the var name "test_pointerEvent".
add_completion_callback(showPointerTypes);
var captured_event;
var f_gotPointerCapture = false;
var f_lostPointerCapture = false;
function listenerEventHandler(event) {
detected_pointertypes[event.pointerType] = true;
if (event.type == "gotpointercapture") {
f_gotPointerCapture = true;
check_PointerEvent(event);
}
else if (event.type == "lostpointercapture") {
f_lostPointerCapture = true;
f_gotPointerCapture = false;
check_PointerEvent(event);
}
else if(event.type == "pointerover" || event.type == "pointerenter" || event.type == "pointerout" || event.type == "pointerleave") {
if(!suppressedEventsFail) {
test(function() {
assert_true(false, "Suppressed events were received");
}, "Suppressed events were received");
suppressedEventsFail = true;
}
}
else if (event.pointerId == captured_event.pointerId) {
if (f_gotPointerCapture && event.type == "pointermove") {
// on first event received for capture, release capture
listener.releasePointerCapture(event.pointerId);
}
else {
// if any other events are received after releaseCapture, then the test fails
test_pointerEvent.step(function () {
assert_true(false, event.target.id + "-" + event.type + " should be handled by target element handler");
});
}
}
}
function targetEventHandler(event) {
if (f_gotPointerCapture) {
if(event.type != "pointerout" && event.type != "pointerleave") {
test_pointerEvent.step(function () {
assert_true(false, "The Target element should not have received any events while capture is active. Event recieved:" + event.type + ". ");
});
}
}
if (event.type == "pointerdown") {
// pointerdown event received will be used to capture events.
listener.setPointerCapture(event.pointerId);
captured_event = event;
}
if (f_lostPointerCapture) {
test_pointerEvent.step(function () {
assert_equals(event.pointerId, captured_event.pointerId, "pointerID is same for event captured and after release");
});
if (event.type == "pointerup") {
test_pointerEvent.done(); // complete test
}
}
}
function run() {
var listener = document.getElementById("listener");
var target0 = document.getElementById("target0");
target0.style["touchAction"] = "none";
// target0 and listener - handle all events
for (var i = 0; i < All_Pointer_Events.length; i++) {
on_event(target0, All_Pointer_Events[i], targetEventHandler);
on_event(listener, All_Pointer_Events[i], listenerEventHandler);
}
}
</script>
</head>
<body onload="run()">
<div id="listener"></div>
<h1>Pointer Event: releasePointerCapture() - subsequent events follow normal hitting testing mechanisms</h1>
<h4>
Test Description:
After invoking the releasePointerCapture method on an element, subsequent events for the specified
pointer must follow normal hit testing mechanisms for determining the event target
</h4>
<br />
<div id="target0">
Use mouse, touch or pen to contact here and move around.
</div>
<div id="complete-notice">
<p>Test complete: Scroll to Summary to view Pass/Fail Results.</p>
<p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
<p>Refresh the page to run the tests again with a different pointer type.</p>
</div>
<div id="log"></div>
</body>
</html>