Bug 977003 - Test for check async got/lostpointercapture events. r=smaug

This commit is contained in:
Maksim Lebedev 2014-09-16 23:16:00 -04:00
parent d645e05bbd
commit 4954c3b5d4
6 changed files with 402 additions and 0 deletions

View File

@ -0,0 +1,86 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=977003
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 977003</title>
<meta name="author" content="Maksim Lebedev" />
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
#target{ background: yellow; }
</style>
<script type="application/javascript">
var target = undefined;
var test_send_got = 0;
var test_got_async = 0;
var test_send_lost = 0;
var test_lost_async = 0;
function DownHandler(event) {
logger("Receive event: " + event.type);
logger("Send setPointerCapture to target");
target.setPointerCapture(event.pointerId);
logger("setPointerCapture was executed");
test_send_got++;
}
function GotPCHandler(event) {
logger("Receive event: " + event.type);
if(test_send_got)
test_got_async++;
logger("Send releasePointerCapture from target");
target.releasePointerCapture(event.pointerId);
logger("releasePointerCapture was executed");
test_send_lost++;
}
function LostPCHandler(event) {
logger("Received event: " + event.type);
if(test_send_lost)
test_lost_async++;
}
function logger(message) {
console.log(message);
var log = document.getElementById('log');
log.innerHTML = message + "<br>" + log.innerHTML;
}
function prepareTest() {
parent.turnOnPointerEvents(executeTest);
}
function executeTest()
{
logger("executeTest");
target = document.getElementById("target");
target.addEventListener("pointerdown", DownHandler, false);
target.addEventListener("gotpointercapture", GotPCHandler, false);
target.addEventListener("lostpointercapture", LostPCHandler, false);
var rect = target.getBoundingClientRect();
synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown"});
synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerup"});
finishTest();
}
function finishTest() {
setTimeout(function() {
parent.is(test_send_got, 1, "Part 1: gotpointercapture event should be sent once");
parent.is(test_got_async, 1, "Part 1: gotpointercapture event should be asynchronous");
parent.is(test_send_lost, 1, "Part 1: lostpointercapture event should be sent once");
parent.is(test_lost_async, 1, "Part 1: lostpointercapture event should be asynchronous");
logger("finishTest");
parent.finishTest();
}, 1000);
}
</script>
</head>
<body onload="prepareTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=977003">Mozilla Bug 977003</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="target">div id=target</div>
<pre id="log">
</pre>
</body>
</html>

View File

@ -0,0 +1,77 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=977003
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 977003</title>
<meta name="author" content="Maksim Lebedev" />
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
#target, #listener { background: yellow; }
</style>
<script type="application/javascript">
var target = undefined;
var listener = undefined;
var test_down_got = false;
var test_listener = false;
function TargetDownHandler(event) {
logger("Target receive event: " + event.type);
logger("Send setPointerCapture to listener");
listener.setPointerCapture(event.pointerId);
logger("Send releasePointerCapture from listener");
listener.releasePointerCapture(event.pointerId);
logger("set/release was executed");
test_down_got = true;
}
function ListenerHandler(event) {
logger("Receive event on Listener: " + event.type);
test_listener = true;
}
function logger(message) {
console.log(message);
var log = document.getElementById('log');
log.innerHTML = message + "<br>" + log.innerHTML;
}
function prepareTest() {
parent.turnOnPointerEvents(executeTest);
}
function executeTest()
{
logger("executeTest");
target = document.getElementById("target");
listener = document.getElementById("listener");
target.addEventListener("pointerdown", TargetDownHandler, false);
listener.addEventListener("gotpointercapture", ListenerHandler, false);
listener.addEventListener("lostpointercapture", ListenerHandler, false);
var rect = target.getBoundingClientRect();
synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown"});
synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerup"});
finishTest();
}
function finishTest() {
setTimeout(function() {
parent.is(test_down_got, true, "Part 2: pointerdown event should be received by target");
parent.is(test_listener, false, "Part 2: listener shouldn't receive any events");
logger("finishTest");
parent.finishTest();
}, 1000);
}
</script>
</head>
<body onload="prepareTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=977003">Mozilla Bug 977003</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="listener">div id=listener</div>
<div id="target">div id=target</div>
<pre id="log">
</pre>
</body>
</html>

View File

@ -0,0 +1,97 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=977003
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 977003</title>
<meta name="author" content="Maksim Lebedev" />
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
#target, #mediator, #listener { background: yellow; }
</style>
<script type="application/javascript">
var target = undefined;
var mediator = undefined;
var listener = undefined;
var test_down_got = false;
var test_mediator_got = false;
var test_mediator_lost = false;
var test_listener = false;
function TargetDownHandler(event) {
logger("Target receive event: " + event.type);
logger("Send pointerCapture to Mediator");
mediator.setPointerCapture(event.pointerId);
logger("setPointerCapture was executed");
test_down_got = true;
}
function MediatorGotPCHandler(event) {
logger("Mediator receive event: " + event.type);
logger("Try send setPointerCapture on listener");
listener.setPointerCapture(event.pointerId);
logger("Try send releasePointerCapture from listener");
listener.releasePointerCapture(event.pointerId);
test_mediator_got = true;
}
function MediatorLostPCHandler(event) {
logger("Mediator receive event: " + event.type);
test_mediator_lost = true;
}
function ListenerHandler(event) {
logger("Receive event on Listener: " + event.type);
test_listener = true;
}
function logger(message) {
console.log(message);
var log = document.getElementById('log');
log.innerHTML = message + "<br>" + log.innerHTML;
}
function prepareTest() {
parent.turnOnPointerEvents(executeTest);
}
function executeTest()
{
logger("executeTest");
target = document.getElementById("target");
mediator = document.getElementById("mediator");
listener = document.getElementById("listener");
target.addEventListener("pointerdown", TargetDownHandler, false);
mediator.addEventListener("gotpointercapture", MediatorGotPCHandler, false);
mediator.addEventListener("lostpointercapture", MediatorLostPCHandler, false);
listener.addEventListener("gotpointercapture", ListenerHandler, false);
listener.addEventListener("lostpointercapture", ListenerHandler, false);
var rect = target.getBoundingClientRect();
synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown"});
synthesizePointer(target, rect.width/3, rect.height/3, {type: "pointermove"});
synthesizePointer(target, rect.width/4, rect.height/4, {type: "pointermove"});
finishTest();
}
function finishTest() {
setTimeout(function() {
parent.is(test_down_got, true, "Part 3: pointerdown event should be received");
parent.is(test_mediator_got, true, "Part 3: gotpointercapture event should be received by Mediator");
parent.is(test_mediator_lost, true, "Part 3: lostpointercapture event should be received by Mediator");
parent.is(test_listener, false, "Part 3: listener shouldn't receive any events");
logger("finishTest");
parent.finishTest();
}, 1000);
}
</script>
</head>
<body onload="prepareTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=977003">Mozilla Bug 977003</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="listener">div id=listener</div>
<div id="mediator">div id=mediator</div>
<div id="target">div id=target</div>
<pre id="log">
</pre>
</body>
</html>

View File

@ -0,0 +1,97 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=977003
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 977003</title>
<meta name="author" content="Maksim Lebedev" />
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
#target, #mediator, #listener { background: yellow; }
</style>
<script type="application/javascript">
var target = undefined;
var mediator = undefined;
var listener = undefined;
var test_down_got = false;
var test_mediator_got = false;
var test_mediator_lost = false;
var test_listener = false;
function TargetDownHandler(event) {
logger("Target receive event: " + event.type);
logger("Send pointerCapture to Mediator");
mediator.setPointerCapture(event.pointerId);
logger("setPointerCapture was executed");
test_down_got = true;
}
function MediatorGotPCHandler(event) {
logger("Mediator receive event: " + event.type);
logger("Try send setPointerCapture on listener");
listener.setPointerCapture(event.pointerId);
logger("Try send releasePointerCapture from Mediator");
mediator.releasePointerCapture(event.pointerId);
test_mediator_got = true;
}
function MediatorLostPCHandler(event) {
logger("Mediator receive event: " + event.type);
test_mediator_lost = true;
}
function ListenerHandler(event) {
logger("Receive event on Listener: " + event.type);
test_listener = true;
}
function logger(message) {
console.log(message);
var log = document.getElementById('log');
log.innerHTML = message + "<br>" + log.innerHTML;
}
function prepareTest() {
parent.turnOnPointerEvents(executeTest);
}
function executeTest()
{
logger("executeTest");
target = document.getElementById("target");
mediator = document.getElementById("mediator");
listener = document.getElementById("listener");
target.addEventListener("pointerdown", TargetDownHandler, false);
mediator.addEventListener("gotpointercapture", MediatorGotPCHandler, false);
mediator.addEventListener("lostpointercapture", MediatorLostPCHandler, false);
listener.addEventListener("gotpointercapture", ListenerHandler, false);
listener.addEventListener("lostpointercapture", ListenerHandler, false);
var rect = target.getBoundingClientRect();
synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown"});
synthesizePointer(target, rect.width/3, rect.height/3, {type: "pointermove"});
synthesizePointer(target, rect.width/4, rect.height/4, {type: "pointermove"});
finishTest();
}
function finishTest() {
setTimeout(function() {
parent.is(test_down_got, true, "Part 4: pointerdown event should be received");
parent.is(test_mediator_got, true, "Part 4: gotpointercapture event should be received by Mediator");
parent.is(test_mediator_lost, true, "Part 4: lostpointercapture event should be received by Mediator");
parent.is(test_listener, false, "Part 4: listener shouldn't receive any events");
logger("finishTest");
parent.finishTest();
}, 1000);
}
</script>
</head>
<body onload="prepareTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=977003">Mozilla Bug 977003</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="listener">div id=listener</div>
<div id="mediator">div id=mediator</div>
<div id="target">div id=target</div>
<pre id="log">
</pre>
</body>
</html>

View File

@ -217,6 +217,12 @@ support-files = bug851445_helper.html
support-files = bug970964_inner.html
[test_bug976963.html]
support-files = bug976963_inner.html
[test_bug977003.html]
support-files =
bug977003_inner_1.html
bug977003_inner_2.html
bug977003_inner_3.html
bug977003_inner_4.html
[test_emulateMedium.html]
[test_getClientRects_emptytext.html]
[test_bug858459.html]

View File

@ -0,0 +1,39 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=977003
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 977003</title>
<meta name="author" content="Maksim Lebedev" />
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript">
var number = 0;
var iframe = undefined;
function prepareTest() {
SimpleTest.waitForExplicitFinish();
iframe = document.getElementById("testFrame");
turnOnPointerEvents(finishTest);
}
function turnOnPointerEvents(callback) {
SpecialPowers.pushPrefEnv({
"set": [
["dom.w3c_pointer_events.enabled", true]
]
}, callback);
}
function finishTest() {
// Try to run several tests named as bug977003_inner_<number>.html
if(++number < 5)
iframe.src = "bug977003_inner_" + number + ".html";
else
SimpleTest.finish();
}
</script>
</head>
<body onload="prepareTest()">
<iframe id="testFrame" height="700" width="700"></iframe>
</body>
</html>