Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!doctype html>
<title>releasePointerCapture on pointerup</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 Capture Test - releasePointerCapture on pointerup</h1>
Test Description: This test checks if releasePointerCapture works properly. Complete the following actions:
<li> Press and hold left mouse button over "Set Capture" button
<li> Release left mouse button anywhere over the document
Test passes if the proper behavior of the events is observed.
<div id="target0" style="background:black; color:white"></div>
<input type="button" id="btnCapture" value="Set Capture">
<script type='text/javascript'>
var isPointerCapture = false;
var pointerupGot = false;
var count=0;
var event_log = [];
var actions_promise;
var detected_pointertypes = {};
function end_of_test() {
var target0 = document.getElementById('target0');
var captureButton = document.getElementById('btnCapture');
setup({ explicit_done: true });
window.onload = function() {
on_event(captureButton, 'pointerdown', function(e) {
detected_pointertypes[e.pointerType] = true;
if(isPointerCapture == false) {
isPointerCapture = true;
pointerupGot = false;
on_event(target0, 'gotpointercapture', function(e) {
on_event(target0, 'lostpointercapture', function(e) {
test(function() {
assert_true(pointerupGot, "pointerup was received before lostpointercapture")
}, "pointerup was received before lostpointercapture");
isPointerCapture = false;
// Make sure the test finishes after all the input actions are completed.
actions_promise.then( () => {
on_event(target0, 'pointerup', function(e) {
var thrown = false;
try {
} catch(e) {
thrown = true;
test(function() {
assert_false(thrown, "target0.releasePointerCapture should not throw");
}, "target0.releasePointerCapture should not throw");
pointerupGot = true;
// Inject mouse inputs.
actions_promise = new test_driver.Actions()
.pointerMove(0, 0, {origin: captureButton})
.pointerMove(10, 0, {origin: target0})
<h1>Pointer Events Capture Test</h1>
<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>The following events were logged: <span id="event-log"></span>.</p>
<div id="log"></div>