2 <body onload=
"autoTest()">
6 var item
= document
.createElement("li");
7 item
.appendChild(document
.createTextNode(message
));
8 document
.getElementById('log').appendChild(item
);
11 function logMouseEvent(evt
)
13 target
= (evt
.target
) ? evt
.target
: evt
.srcElement
;
14 log(evt
.type
+ " on " + target
.id
);
19 <a href=
"https://bugs.webkit.org/show_bug.cgi?id=3439">3439</a>,
20 <a href=
"https://bugs.webkit.org/show_bug.cgi?id=5764">5764</a>,
21 <a href=
"https://bugs.webkit.org/show_bug.cgi?id=7701">7701</a> -
22 Mouse events vs. DOM manipulation.
</p>
23 <p>Move the mouse pointer from left to right:
</p>
25 <!-- 1: Show an element under the mouse -->
26 <div style='height:
50; width:
50; background:red;top:
100;left:
100; position:absolute;' id='t1_1'
27 onMouseOver=
"logMouseEvent(event); document.getElementById('t1_2').style.display = 'block'"
28 onMouseOut=
"logMouseEvent(event);">1 </div>
29 <div style='display: none; height:
50; width:
50; background:white;top:
100;left:
100; position:absolute;' id='t1_2'
30 onMouseOver=
"logMouseEvent(event)"
31 onMouseOut=
"logMouseEvent(event); document.getElementById('t1_2').style.backgroundColor = 'gray'">1 </div>
33 <!-- 2: Hide an element under the mouse -->
34 <div style='height:
50; width:
50; background:white;top:
100;left:
150; position:absolute;' id='t2_2'
35 onMouseOver=
"logMouseEvent(event)"
36 onMouseOut=
"logMouseEvent(event); document.getElementById('t2_2').style.backgroundColor = 'gray'">2</div>
37 <div style='height:
50; width:
50; background:orange;top:
100;left:
150; position:absolute;' id='t2_1'
38 onMouseOver=
"logMouseEvent(event); document.getElementById('t2_1').style.display = 'none'"
39 onMouseOut=
"logMouseEvent(event)">2</div>
41 <!-- 3: Move the element under the mouse into another document -->
42 <div style='height:
50; width:
50; background:white;top:
100;left:
200; position:absolute;' id='t3_2'
43 onMouseOver=
"logMouseEvent(event)"
44 onMouseOut=
"logMouseEvent(event); document.getElementById('t3_2').style.backgroundColor = 'gray'">3</div>
45 <div style='height:
50; width:
50; background:yellow;top:
100;left:
200; position:absolute;' id='t3_1'
48 newDoc = document.getElementById('invisible_frame').contentDocument;
50 newDoc.adoptNode(document.getElementById('t3_1'));
52 newDoc.documentElement.appendChild(document.getElementById('t3_1'));
55 onMouseOut=
"logMouseEvent(event)">3</div>
57 <!-- 4: Move the element under the mouse into another document, and append it -->
58 <div style='height:
50; width:
50; background:white;top:
100;left:
250; position:absolute;' id='t4_2'
59 onMouseOver=
"logMouseEvent(event)"
60 onMouseOut=
"logMouseEvent(event); document.getElementById('t4_2').style.backgroundColor = 'gray'">4</div>
61 <div style='height:
50; width:
50; background:green;top:
100;left:
250; position:absolute;' id='t4_1'
64 newDoc = document.getElementById('invisible_frame').contentDocument;
66 newDoc.documentElement.appendChild(newDoc.adoptNode(document.getElementById('t4_1')));
68 newDoc.documentElement.appendChild(document.getElementById('t4_1'));
71 onMouseOut=
"logMouseEvent(event)">4</div>
73 <!-- 5: Remove the element under the mouse -->
74 <div style='height:
50; width:
50; background:white;top:
100;left:
300; position:absolute;' id='t5_2'
75 onMouseOver=
"logMouseEvent(event)"
76 onMouseOut=
"logMouseEvent(event); document.getElementById('t5_2').style.backgroundColor = 'gray'">5</div>
77 <div style='height:
50; width:
50; background:blue;top:
100;left:
300; position:absolute;' id='t5_1'
80 document.body.removeChild(document.getElementById('t5_1'));
82 onMouseOut=
"logMouseEvent(event)">5</div>
84 <!-- 6: Enter a different document -->
85 <iframe style='height:
50; width:
50; top:
100;left:
350; position:absolute; border-width:
0' src='resources/mouseover-mouseout-iframe.html'
86 onMouseOver=
"logMouseEvent(event)"
87 onMouseOut=
"logMouseEvent(event)"
91 <iframe id=invisible_frame
style=
"width:0; height:0; border-width:0"></iframe>
93 <table border=
1 width=
"100%" style='top:
200; position:absolute'
>
94 <tr><td width=
"50%">Log
</td></tr>
96 <td id=log
style=
"vertical-align:top"></td>
101 function autoTest() {
102 if (window
.testRunner
) {
103 testRunner
.dumpAsText();
105 eventSender
.mouseMoveTo(1,1);
106 eventSender
.mouseDown();
107 eventSender
.mouseUp();
109 eventSender
.mouseMoveTo(125, 125);
110 eventSender
.mouseMoveTo(130, 125);
111 eventSender
.mouseMoveTo(135, 125);
113 eventSender
.mouseMoveTo(175, 125);
114 eventSender
.mouseMoveTo(180, 125);
116 eventSender
.mouseMoveTo(225, 125);
117 eventSender
.mouseMoveTo(230, 125);
119 eventSender
.mouseMoveTo(275, 125);
120 eventSender
.mouseMoveTo(280, 125);
122 eventSender
.mouseMoveTo(325, 125);
123 eventSender
.mouseMoveTo(330, 125);
125 eventSender
.mouseMoveTo(375, 125);
126 eventSender
.mouseMoveTo(380, 125);
127 eventSender
.mouseMoveTo(385, 125);
129 eventSender
.mouseMoveTo(1, 1);