Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / svg / custom / stroke-width-click.svg
blob88b85abcbbb81fbc1f394c789ca4e9b5de1f0902
1 <?xml version="1.0" encoding="UTF-8"?>
2 <svg xmlns="http://www.w3.org/2000/svg">
3 <script type="text/javascript">
4 <![CDATA[
5 if (window.testRunner)
6 testRunner.dumpAsText();
8 function log(string) {
9 var newDiv = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
10 newDiv.textContent = string;
11 document.getElementById('log').appendChild(newDiv);
14 var lastEvent = null;
16 function testClick(x, y, expected) {
17 eventSender.mouseMoveTo(x, y);
18 eventSender.mouseDown();
19 eventSender.mouseUp();
20 if (expected && lastEvent && lastEvent.clientX == x && lastEvent.clientY == y) {
21 log("SUCCESS: click received at: " + x + ", " + y);
22 } else if (!expected && !lastEvent) {
23 log("SUCCESS: click at " + x + ", " + y + " was correctly ignored");
24 } else if (expected && lastEvent) {
25 log("FAILURE: click received at: " + lastEvent.clientX + ", " + lastEvent.clientY + " but it was expected at: " + x + ", " + y);
26 } else if (!expected && lastEvent) {
27 log("FAILURE: UNEXPECTED click received at: " + lastEvent.clientX + ", " + lastEvent.clientY);
28 } else if (expected && !lastEvent) {
29 log("FAILURE: NO click received at: " + x + ", " + y);
30 } else {
31 log("LOGIC ERORR");
33 lastEvent = null;
36 function gotClick(evt) {
37 lastEvent = evt;
40 function gotMouseEvent(evt, type) {
41 if (!window.testRunner)
42 document.getElementById('mouseover-text').textContent = type + " at " + evt.clientX + ", " + evt.clientY;
44 ]]>
45 </script>
46 <foreignObject y="200" width="600" height="400">
47 <html xmlns="http://www.w3.org/1999/xhtml">
48 <body>
49 <div id="log">
50 </div>
51 </body>
52 </html>
53 </foreignObject>
55 <!-- 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 -->
56 <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')" />
57 <text id="mouseover-text" x="30" y="190"></text>
59 <!-- The following mouse events are spaced explicity to prevent triggering double-click logic -->
60 <script type="text/javascript">
61 <![CDATA[
62 if (window.eventSender) {
63 testClick(30, 100, true);
64 testClick(30, 50, true);
65 testClick(30, 150, true);
66 testClick(300, 100, true);
67 testClick(300, 50, true);
68 testClick(301, 100, true);
69 testClick(300, 150, true);
71 testClick(10, 10, false);
72 testClick(29, 100, false);
73 testClick(30, 49, false);
74 testClick(30, 151, false);
75 testClick(300, 49, false);
76 testClick(300, 151, false);
77 } else {
78 log("ERROR: window.eventSender not found! This test must be run using DumpRenderTree. Mousing over the yellow area will log however.");
80 ]]>
81 </script>
82 </svg>