Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!doctype html>
<title>Lostpointercapture fires on document when target is removed</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
<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="pointerevent_support.js"></script>
<h1>Pointer Events - lostpointercapture when capturing element is removed</h1>
Test Description:
This test checks if lostpointercapture is fired at the document when the capturing node is removed from the document.
Complete the following actions:
<li>Press and hold left mouse button over "Set Capture" button. "gotpointercapture" should be logged inside of the black rectangle.
<li>"lostpointercapture" should be logged inside of the black rectangle after a short delay.
<div id="target0"></div>
<div id="target1" style="background:black; color:white"></div>
<input type="button" id="btnCapture" value="Set Capture">
<script type='text/javascript'>
var isDisconnected = false;
var count = 0;
var event_log = [];
var detected_pointertypes = {};
function end_of_test() {
var target0 = document.getElementById('target0');
var target1 = document.getElementById('target1');
var captureButton = document.getElementById('btnCapture');
var test_lostpointercapture = async_test("lostpointercapture event received");
window.onload = function() {
var actions_promise;
on_event(captureButton, 'pointerdown', function(event) {
detected_pointertypes[event.pointerType] = true;
on_event(target0, 'gotpointercapture', function(e) {
isDisconnected = true;
on_event(target0, 'lostpointercapture', function(e) {
test(function() {
// TA: 11.3
assert_unreached("lostpointercapture must be fired on the document, not the capturing element");
}, "lostpointercapture must not be dispatched on the disconnected node");
on_event(document, 'lostpointercapture', function(e) {
test(function() {
// TA: 11.3
assert_true(isDisconnected, "lostpointercapture must be fired on the document");
}, "lostpointercapture is dispatched on the document");
actions_promise.then( () => {
// Inject mouse inputs.
actions_promise = new test_driver.Actions()
.pointerMove(0, 0, {origin: captureButton})
.pointerMove(2, 0, {origin: captureButton})
.pointerMove(5, 0, {origin: captureButton})
.pointerMove(8, 0, {origin: captureButton})
.pointerMove(10, 0, {origin: captureButton})
<h1>Pointer Events Capture Test</h1>
<div id="complete-notice">
<p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
<p>The following events were logged: <span id="event-log"></span>.</p>
<div id="log"></div>