gecko-dev/layout/base/tests/bug977003_inner_1.html

87 строки
3.0 KiB
HTML

<!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>