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)"
89 if (top.document.getElementById('log').innerHTML == top.document.getElementById('exp').innerHTML) {
90 top.document.getElementById('success').style.display = 'block';
96 <iframe id=invisible_frame style="width:0; height:0; border-width:0"></iframe>
98 <table border=1 width="100%" style='top:200; position:absolute'>
99 <tr><td width="50%">Log</td><td>Expected results</td></tr>
101 <td id=log style="vertical-align:top"></td>
102 <td id=exp style="vertical-align:top"><li>mouseover on t1_1</li><li>mouseout on t1_1</li><li>mouseover on t1_2</li><li>mouseout on t1_2</li><li>mouseover on t2_1</li><li>mouseout on t2_1</li><li>mouseover on t2_2</li><li>mouseout on t2_2</li><li>mouseover on t3_1</li><li>mouseover on t3_2</li><li>mouseout on t3_2</li><li>mouseover on t4_1</li><li>mouseover on t4_2</li><li>mouseout on t4_2</li><li>mouseover on t5_1</li><li>mouseout on t5_1</li><li>mouseover on t5_2</li><li>mouseout on t5_2</li><li>mouseover on frame6</li><li>mouseover on t6</li><li>mouseout on t6</li><li>mouseout on frame6</li></td>
106 <div style='height: 50; width: 300; top:100;left:100; position:absolute; display:none' id='success'><br><center>SUCCESS</center></div>
109 function autoTest() {
110 if (window.layoutTestController) {
111 layoutTestController.dumpAsText();
113 eventSender.mouseMoveTo(1,1);
114 eventSender.mouseDown();
115 eventSender.mouseUp();
117 eventSender.mouseMoveTo(125, 125);
118 eventSender.mouseMoveTo(130, 125);
119 eventSender.mouseMoveTo(135, 125);
121 eventSender.mouseMoveTo(175, 125);
122 eventSender.mouseMoveTo(180, 125);
124 eventSender.mouseMoveTo(225, 125);
125 eventSender.mouseMoveTo(230, 125);
127 eventSender.mouseMoveTo(275, 125);
128 eventSender.mouseMoveTo(280, 125);
130 eventSender.mouseMoveTo(325, 125);
131 eventSender.mouseMoveTo(330, 125);
133 eventSender.mouseMoveTo(375, 125);
134 eventSender.mouseMoveTo(380, 125);
135 eventSender.mouseMoveTo(385, 125);
137 eventSender.mouseMoveTo(1, 1);