blob: 0cbce7c15968febc1787e31afc584c75213edb42 [file] [log] [blame]
<head>
<script src="../../../resources/js-test-pre.js"></script>
<script>
var nrmouseclicks = 0; // small hack to distinguish between clicks
var ev;
function mouseev(event) {
if (nrmouseclicks == 0) {
shouldBe("event.clientX", "50");
shouldBe("event.clientY", "50");
shouldBe("event.pageX", "50");
shouldBe("event.pageY", "50");
shouldBe("event.layerX", "50");
shouldBe("event.layerY", "50");
shouldBe("event.offsetX", "42");
shouldBe("event.offsetY", "42");
nrmouseclicks++;
} else if (nrmouseclicks == 1) {
shouldBe("event.clientX", "50");
shouldBe("event.clientY", "50");
shouldBe("event.pageX", "50");
shouldBe("event.pageY", "550");
shouldBe("event.layerX", "50");
shouldBe("event.layerY", "550");
shouldBe("event.offsetX", "42");
shouldBe("event.offsetY", "542");
nrmouseclicks++;
} else if (nrmouseclicks == 2) {
shouldBe("event.clientX", "50");
shouldBe("event.clientY", "50");
shouldBe("event.pageX", "550");
shouldBe("event.pageY", "50");
shouldBe("event.layerX", "550");
shouldBe("event.layerY", "50");
shouldBe("event.offsetX", "542");
shouldBe("event.offsetY", "42");
nrmouseclicks++;
// test initMouseEvent
window.scrollTo(500, 500);
ev = document.createEvent("MouseEvent");
ev.initMouseEvent("mousedown", true, true, document.defaultView, 1, 50, 50, 50, 50, false, false, false, false, 0, document);
var child = document.getElementById('target');
child.dispatchEvent(ev);
} else {
shouldBe("ev.clientX", "50");
shouldBe("ev.clientY", "50");
shouldBe("ev.pageX", "550");
shouldBe("ev.pageY", "550");
shouldBe("ev.layerX", "550");
shouldBe("ev.layerY", "550");
shouldBe("ev.offsetX", "542");
shouldBe("ev.offsetY", "542");
}
}
function test() {
if (window.testRunner) {
testRunner.dumpAsText();
// test a normal mouse to
eventSender.mouseMoveTo(50, 50);
eventSender.mouseDown();
eventSender.mouseUp();
// now scroll a bit down and verify that clientY does not change
window.scrollTo(0, 500);
eventSender.mouseDown();
eventSender.mouseUp();
// now scroll a bit to the right and verify that clientX does not change
window.scrollTo(500, 0);
eventSender.mouseDown();
eventSender.mouseUp();
}
}
</script>
</head>
<body onload="test()">
<div id="target" style="background: red; width:2000px; height: 2000px" onmousedown="mouseev(event)">
</div>
<div id="console"></div>
</body>