OLD | NEW |
| (Empty) |
1 <script> | |
2 if (window.layoutTestController) | |
3 layoutTestController.dumpEditingCallbacks(); | |
4 </script> | |
5 <style> | |
6 td { | |
7 border: 1px solid #aaa; | |
8 } | |
9 </style> | |
10 | |
11 <body onload="runTest()" style="border: 1px solid red;" contenteditable="true"><
table id="table" style="margin: 25px; border:10px solid #ccc; padding: 10px;"><t
r><td>cell one</td><td>cell two</td></tr></table> | |
12 <ul id="console"></ul> | |
13 <script> | |
14 function log(message) { | |
15 var console = document.getElementById("console"); | |
16 var li = document.createElement("li"); | |
17 var text = document.createTextNode(message); | |
18 | |
19 console.appendChild(li); | |
20 li.appendChild(text); | |
21 } | |
22 function runTest() { | |
23 if (!window.layoutTestController) | |
24 log("This test uses the eventSender to do mouse clicks. To run it manuall
y, click after the table, the caret should appear there (and not inside the tabl
e). Then click inside the table. The caret should appear inside it."); | |
25 else { | |
26 window.layoutTestController.dumpAsText(); | |
27 var s, x, y, e, top, bottom, left, right; | |
28 table = document.getElementById("table"); | |
29 | |
30 top = table.offsetTop; | |
31 left = table.offsetLeft; | |
32 bottom = top + table.offsetHeight; | |
33 right = left + table.offsetWidth; | |
34 | |
35 x = right + 5; | |
36 y = (top + bottom) / 2; | |
37 eventSender.mouseMoveTo(x, y); | |
38 eventSender.mouseDown(); | |
39 eventSender.mouseUp(); | |
40 s = window.getSelection(); | |
41 if (!(s.anchorNode == document.body && s.anchorOffset == 1)) | |
42 log("Failure: Clicking after the table didn't put the caret after it."
); | |
43 | |
44 x = right - 5; | |
45 y = (top + bottom) / 2; | |
46 eventSender.leapForward(1000); | |
47 eventSender.mouseMoveTo(x, y); | |
48 eventSender.mouseDown(); | |
49 eventSender.mouseUp(); | |
50 s = window.getSelection(); | |
51 if (s.anchorNode == document.body) | |
52 log("Failure: Clicking inside the table put the caret before or after
it."); | |
53 | |
54 x = left - 5; | |
55 y = (top + bottom) / 2; | |
56 eventSender.leapForward(1000); | |
57 eventSender.mouseMoveTo(x, y); | |
58 eventSender.mouseDown(); | |
59 eventSender.mouseUp(); | |
60 s = window.getSelection(); | |
61 if (s.anchorNode != table || s.anchorOffset != 0) | |
62 if (!(s.anchorNode == document.body && s.anchorOffset == 0)) | |
63 log("Failure: Clicking before the table should be the caret before it.
"); | |
64 | |
65 x = left + 5; | |
66 y = (top + bottom) / 2; | |
67 eventSender.leapForward(1000); | |
68 eventSender.mouseMoveTo(x, y); | |
69 eventSender.mouseDown(); | |
70 eventSender.mouseUp(); | |
71 s = window.getSelection(); | |
72 if (s.anchorNode == document.body) | |
73 log("Failure: Clicking inside the table put the caret before or after
it."); | |
74 } | |
75 } | |
76 </script> | |
77 </body> | |
OLD | NEW |