<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg">
<script type="text/javascript">
<![CDATA[
if (window.testRunner)
testRunner.dumpAsText();
function log(string) {
var newDiv = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
newDiv.textContent = string;
document.getElementById('log').appendChild(newDiv);
}
var lastEvent = null;
function testClick(x, y, expected) {
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseUp();
if (expected && lastEvent && lastEvent.clientX == x && lastEvent.clientY == y) {
log("SUCCESS: click received at: " + x + ", " + y);
} else if (!expected && !lastEvent) {
log("SUCCESS: click at " + x + ", " + y + " was correctly ignored");
} else if (expected && lastEvent) {
log("FAILURE: click received at: " + lastEvent.clientX + ", " + lastEvent.clientY + " but it was expected at: " + x + ", " + y);
} else if (!expected && lastEvent) {
log("FAILURE: UNEXPECTED click received at: " + lastEvent.clientX + ", " + lastEvent.clientY);
} else if (expected && !lastEvent) {
log("FAILURE: NO click received at: " + x + ", " + y);
} else {
log("LOGIC ERORR");
}
lastEvent = null;
}
function gotClick(evt) {
lastEvent = evt;
}
function gotMouseEvent(evt, type) {
if (!window.testRunner)
document.getElementById('mouseover-text').textContent = type + " at " + evt.clientX + ", " + evt.clientY;
}
]]>
</script>
<foreignObject y="200" width="600" height="400">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<div id="log">
</div>
</body>
</html>
</foreignObject>
<!-- Paths only seem to stroke from startX to endX - 1 pixels. I was not aware of that before writing this test. Firefox and Opera match our behavior -->
<path d="M 30 100 L 301 100" stroke-width="100" stroke="yellow" onclick="gotClick(evt)" onmouseover="gotMouseEvent(evt, 'mouseover')" onmouseout="gotMouseEvent(evt, 'mouseout')" onmousemove="gotMouseEvent(evt, 'mousemove')" />
<text id="mouseover-text" x="30" y="190"></text>
<!-- The following mouse events are spaced explicity to prevent triggering double-click logic -->
<script type="text/javascript">
<![CDATA[
if (window.eventSender) {
testClick(30, 100, true);
testClick(30, 50, true);
testClick(30, 150, true);
testClick(300, 100, true);
testClick(300, 50, true);
testClick(301, 100, true);
testClick(300, 150, true);
testClick(10, 10, false);
testClick(29, 100, false);
testClick(30, 49, false);
testClick(30, 151, false);
testClick(300, 49, false);
testClick(300, 151, false);
} else {
log("ERROR: window.eventSender not found! This test must be run using DumpRenderTree. Mousing over the yellow area will log however.");
}
]]>
</script>
</svg>