Source code

Revision control

Copy as Markdown

Other Tools

<meta charset="utf-8">
<title>Test for Bugs 977003, 1073563</title>
<meta name="author" content="Maksim Lebedev" />
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
#target, #listener { background: yellow; }
<script type="application/javascript">
var target = undefined;
var listener = undefined;
var test_target = false;
var test_move = false;
var test_over = false;
var test_listener = false;
var receive_lostpointercapture = false;
function TargetDownHandler(event) {
logger("Target receive event: " + event.type);
logger("Send setPointerCapture to listener");
logger("set/release was executed");
test_target = true;
function ListenerHandler(event) {
logger("Receive event on Listener: " + event.type);
if("gotpointercapture" == event.type) {
logger("Send releasePointerCapture from listener");
} else if(event.type == "lostpointercapture") {
// Set/release pointer capture in the event listeners of got/lostpointercapture won't take effect immediately, false, "Part 6: listener should receive only one lostpointercapture");
if (!receive_lostpointercapture) {
receive_lostpointercapture = true;
logger("Send setPointerCapture to listener");
} else if(event.type == "pointermove") {
test_move = true;
} else if(event.type == "pointerover") {
test_over = true;
} else {
test_listener = true;
function logger(message) {
var log = document.getElementById('log');
log.innerHTML = message + "<br>" + log.innerHTML;
function prepareTest() {
function executeTest()
target = document.getElementById("target");
listener = document.getElementById("listener");
target.addEventListener("pointerdown", TargetDownHandler);
listener.addEventListener("gotpointercapture", ListenerHandler);
listener.addEventListener("pointerdown", ListenerHandler);
listener.addEventListener("pointerover", ListenerHandler);
listener.addEventListener("pointermove", ListenerHandler);
listener.addEventListener("pointerup", ListenerHandler);
listener.addEventListener("pointerout", ListenerHandler);
listener.addEventListener("lostpointercapture", ListenerHandler);
var rect = target.getBoundingClientRect();
synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousedown"});
synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousemove"});
synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mouseup"});
function finishTest() {, true, "Part 6: pointerdown event should be received by target");
// PE level 2 defines that the pending pointer capture is processed when firing next pointer events.
// In this test case, pointer capture release is processed when firing pointermove, true, "Part 6: gotpointercapture should be triggered by pointermove");, true, "Part 6: pointerover should be received when capturing pointer");, false, "Part 6: no other pointerevents should be fired before gotpointercapture except pointerover");
<body onload="prepareTest()">
<a target="_blank" href="">Mozilla Bug 977003 Test 6</a>
<br><a target="_blank" href="">Mozilla Bug 1073563</a>
<p id="display"></p>
<div id="content" style="display: none">
<div id="listener">div id=listener</div>
<div id="target">div id=target</div>
<pre id="log">